niksos/modules/cli/git.nix

62 lines
1.8 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;
2024-02-15 10:50:45 +01:00
default = "$EDITOR";
2023-10-13 21:04:24 +02:00
description = "commit message editor";
};
defaultBranch = mkOption {
type = types.str;
2024-02-14 23:48:38 +01:00
default = "master";
2023-10-13 21:04:24 +02:00
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 = [
{
2024-02-17 15:57:57 +01:00
contents = {
2024-02-17 16:14:55 +01:00
core = {
editor = cfg.editor;
pager = "${pkgs.delta}/bin/delta";
};
2024-02-17 15:57:57 +01:00
init.defaultBranch = cfg.defaultBranch;
push.autoSetupRemote = true;
commit.verbose = true;
2024-02-17 16:15:33 +01:00
merge.conflictstyle = "zdiff3";
2024-02-17 16:14:55 +01:00
interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
2024-02-17 15:57:57 +01:00
};
2023-10-13 21:04:24 +02:00
}
];
};
2023-09-08 16:10:15 +02:00
};
};
}