niksos/modules/cli/git.nix

66 lines
2.1 KiB
Nix
Raw Normal View History

2023-09-08 16:10:15 +02:00
{
2023-10-13 21:04:24 +02:00
config,
lib,
2024-02-17 17:43:17 +01:00
pkgs,
2023-09-08 16:10:15 +02:00
...
2023-10-13 21:04:24 +02:00
}: with lib; let
cfg = config.myOptions.programs.git;
username = config.myOptions.other.system.username;
2023-10-13 21:04:24 +02:00
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.${username} = {
2023-10-13 21:04:24 +02:00
programs.git = {
inherit (cfg) enable userName userEmail;
extraConfig = {
contents = {
core = {
editor = cfg.editor;
pager = "${pkgs.delta}/bin/delta";
2024-02-17 15:57:57 +01:00
};
init.defaultBranch = cfg.defaultBranch;
push.autoSetupRemote = true;
2024-03-03 01:55:00 +01:00
commit = {
verbose = true;
2024-03-03 09:32:08 +01:00
gpgSign = true;
2024-03-03 01:55:00 +01:00
};
2024-03-03 09:32:08 +01:00
gpg.format = "ssh";
user.signingKey = "key::ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHXD1EM4mQz99vJhmZX1r7kwMd8yewogOuoTUuv1xWZB";
merge.conflictstyle = "zdiff3";
interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
diff.algorithm = "histogram";
transfer.fsckobjects = true;
fetch.fsckobjects = true;
receive.fsckobjects = true;
};
};
2023-10-13 21:04:24 +02:00
};
2023-09-08 16:10:15 +02:00
};
};
}