niksos/modules/cli/git.nix
jacekpoz 59febb2149
move the config' arg to a custom module (big)
shoutout to raf for pointing out how retarded this was
this was needed very much
2024-02-29 00:29:56 +01:00

66 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
...
}: with lib; let
cfg = config.myOptions.programs.git;
username = config.myOptions.other.system.username;
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 = "$EDITOR";
description = "commit message editor";
};
defaultBranch = mkOption {
type = types.str;
default = "master";
description = "default git branch";
};
};
config = mkIf cfg.enable {
home-manager.users.${username} = {
programs.git = {
inherit (cfg) enable userName userEmail;
signing = {
key = cfg.signingKey;
signByDefault = true;
};
includes = [
{
contents = {
core = {
editor = cfg.editor;
pager = "${pkgs.delta}/bin/delta";
};
init.defaultBranch = cfg.defaultBranch;
push.autoSetupRemote = true;
commit.verbose = true;
merge.conflictstyle = "zdiff3";
interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
diff.algorithm = "histogram";
transfer.fsckobjects = true;
fetch.fsckobjects = true;
receive.fsckobjects = true;
};
}
];
};
};
};
}