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
|
|
|
...
|
2024-05-05 12:38:40 +02:00
|
|
|
}: let
|
2023-10-13 21:04:24 +02:00
|
|
|
cfg = config.myOptions.programs.git;
|
2024-04-14 18:49:29 +02:00
|
|
|
inherit (config.myOptions.other.system) username;
|
2024-05-05 12:38:40 +02:00
|
|
|
|
|
|
|
inherit (lib) mkEnableOption mkIf mkOption;
|
|
|
|
inherit (lib.types) nullOr str;
|
2023-10-13 21:04:24 +02:00
|
|
|
in {
|
|
|
|
options.myOptions.programs.git = {
|
|
|
|
enable = mkEnableOption "git";
|
|
|
|
userName = mkOption {
|
2024-05-05 12:38:40 +02:00
|
|
|
type = nullOr str;
|
2024-05-03 18:54:03 +02:00
|
|
|
default = null;
|
2023-10-13 21:04:24 +02:00
|
|
|
description = "git username";
|
|
|
|
};
|
|
|
|
userEmail = mkOption {
|
2024-05-05 12:38:40 +02:00
|
|
|
type = nullOr str;
|
2024-05-03 18:54:03 +02:00
|
|
|
default = null;
|
2023-10-13 21:04:24 +02:00
|
|
|
description = "git email";
|
|
|
|
};
|
|
|
|
signingKey = mkOption {
|
2024-05-05 12:38:40 +02:00
|
|
|
type = nullOr str;
|
2024-05-03 18:54:03 +02:00
|
|
|
default = null;
|
2023-10-13 21:04:24 +02:00
|
|
|
description = "git commit signing key";
|
|
|
|
};
|
|
|
|
editor = mkOption {
|
2024-05-05 12:38:40 +02:00
|
|
|
type = 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 {
|
2024-05-05 12:38:40 +02:00
|
|
|
type = 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 {
|
2024-02-29 00:29:56 +01:00
|
|
|
home-manager.users.${username} = {
|
2023-10-13 21:04:24 +02:00
|
|
|
programs.git = {
|
|
|
|
inherit (cfg) enable userName userEmail;
|
2024-03-03 01:45:09 +01:00
|
|
|
extraConfig = {
|
2024-03-03 09:40:34 +01:00
|
|
|
core = {
|
2024-04-14 18:49:29 +02:00
|
|
|
inherit (cfg) editor;
|
2024-03-03 09:40:34 +01:00
|
|
|
pager = "${pkgs.delta}/bin/delta";
|
2024-03-03 01:45:09 +01:00
|
|
|
};
|
2024-03-03 09:40:34 +01:00
|
|
|
init.defaultBranch = cfg.defaultBranch;
|
|
|
|
push.autoSetupRemote = true;
|
|
|
|
commit = {
|
|
|
|
verbose = true;
|
2024-05-03 18:54:03 +02:00
|
|
|
gpgsign = cfg.signingKey != null;
|
2024-03-03 09:40:34 +01:00
|
|
|
};
|
|
|
|
gpg.format = "ssh";
|
2024-05-03 18:54:03 +02:00
|
|
|
user.signingkey = mkIf (cfg.signingKey != null) "key::${cfg.signingKey}";
|
2024-03-03 09:40:34 +01:00
|
|
|
merge.conflictstyle = "zdiff3";
|
|
|
|
interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
|
|
|
|
diff.algorithm = "histogram";
|
|
|
|
transfer.fsckobjects = true;
|
|
|
|
fetch.fsckobjects = true;
|
|
|
|
receive.fsckobjects = true;
|
2024-03-03 01:45:09 +01:00
|
|
|
};
|
2023-10-13 21:04:24 +02:00
|
|
|
};
|
2023-09-08 16:10:15 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|