72 lines
2.2 KiB
Nix
72 lines
2.2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
cfg = config.myOptions.programs.git;
|
|
inherit (config.myOptions.other.system) username;
|
|
|
|
inherit (lib) getExe mkEnableOption mkIf mkOption;
|
|
inherit (lib.types) nullOr str;
|
|
|
|
delta = getExe pkgs.delta;
|
|
in {
|
|
options.myOptions.programs.git = {
|
|
enable = mkEnableOption "git";
|
|
userName = mkOption {
|
|
type = nullOr str;
|
|
default = null;
|
|
description = "git username";
|
|
};
|
|
userEmail = mkOption {
|
|
type = nullOr str;
|
|
default = null;
|
|
description = "git email";
|
|
};
|
|
signingKey = mkOption {
|
|
type = nullOr str;
|
|
default = null;
|
|
description = "git commit signing key";
|
|
};
|
|
editor = mkOption {
|
|
type = str;
|
|
default = "$EDITOR";
|
|
description = "commit message editor";
|
|
};
|
|
defaultBranch = mkOption {
|
|
type = str;
|
|
default = "master";
|
|
description = "default git branch";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home-manager.users.${username} = {
|
|
programs.git = {
|
|
enable = true;
|
|
inherit (cfg) userName userEmail;
|
|
extraConfig = {
|
|
core = {
|
|
inherit (cfg) editor;
|
|
pager = "${delta}";
|
|
};
|
|
init.defaultBranch = cfg.defaultBranch;
|
|
push.autoSetupRemote = true;
|
|
commit = {
|
|
verbose = true;
|
|
gpgsign = cfg.signingKey != null;
|
|
};
|
|
gpg.format = "ssh";
|
|
user.signingkey = mkIf (cfg.signingKey != null) "key::${cfg.signingKey}";
|
|
merge.conflictstyle = "zdiff3";
|
|
interactive.diffFilter = "${delta} --color-only";
|
|
diff.algorithm = "histogram";
|
|
transfer.fsckobjects = true;
|
|
fetch.fsckobjects = true;
|
|
receive.fsckobjects = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|