niksos/modules/cli/git.nix

58 lines
1.5 KiB
Nix
Raw Normal View History

2023-09-08 16:10:15 +02:00
{
2023-10-13 21:04:24 +02:00
config,
config',
lib,
2023-09-08 16:10:15 +02:00
...
2023-10-13 21:04:24 +02:00
}: with lib; let
cfg = config.myOptions.programs.git;
in {
options.myOptions.programs.git = {
enable = mkEnableOption "git";
userName = mkOption {
type = types.str;
description = "git username";
};
userEmail = mkOption {
type = types.str;
description = "git email";
};
signingKey = mkOption {
type = types.str;
description = "git commit signing key";
};
editor = mkOption {
type = types.str;
default = "nvim";
description = "commit message editor";
};
defaultBranch = mkOption {
type = types.str;
default = "main";
description = "default git branch";
};
};
config = mkIf cfg.enable {
home-manager.users.${config'.username} = {
programs.git = {
inherit (cfg) enable userName userEmail;
signing = {
key = cfg.signingKey;
signByDefault = true;
};
includes = [
{
contents = { core.editor = cfg.editor; };
}
{
contents = { init.defaultBranch = cfg.defaultBranch; };
}
{
contents = { push.autoSetupRemote = true; };
}
];
};
2023-09-08 16:10:15 +02:00
};
};
}