1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

git: aliases / user options -> settings

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-10-18 10:44:26 -05:00
parent ac7c05a90c
commit a709427248
9 changed files with 98 additions and 59 deletions

View file

@ -48,27 +48,6 @@ in
''; '';
}; };
userName = mkOption {
type = types.nullOr types.str;
default = null;
description = "Default user name to use.";
};
userEmail = mkOption {
type = types.nullOr types.str;
default = null;
description = "Default user email to use.";
};
aliases = mkOption {
type = types.attrsOf types.str;
default = { };
example = {
co = "checkout";
};
description = "Git aliases to define.";
};
signing = { signing = {
key = mkOption { key = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -296,17 +275,55 @@ in
}; };
}; };
imports = [ imports =
(lib.mkRenamedOptionModule let
[ "programs" "git" "signing" "gpgPath" ] oldPrefix = [
[
"programs" "programs"
"git" "git"
"signing" ];
"signer" newPrefix = [
"programs"
"git"
"settings"
];
in
[
(lib.mkRenamedOptionModule
[ "programs" "git" "signing" "gpgPath" ]
[
"programs"
"git"
"signing"
"signer"
]
)
(lib.mkRenamedOptionModule [ "programs" "git" "extraConfig" ] [ "programs" "git" "settings" ])
]
++ (lib.hm.deprecations.mkSettingsRenamedOptionModules oldPrefix newPrefix
{
transform = x: x;
}
[
{
old = [ "userName" ];
new = [
"user"
"name"
];
}
{
old = [ "userEmail" ];
new = [
"user"
"email"
];
}
{
old = [ "aliases" ];
new = [ "alias" ];
}
] ]
) );
];
config = mkIf cfg.enable ( config = mkIf cfg.enable (
lib.mkMerge [ lib.mkMerge [
@ -331,11 +348,6 @@ in
} }
]; ];
programs.git.iniContent.user = {
name = mkIf (cfg.userName != null) cfg.userName;
email = mkIf (cfg.userEmail != null) cfg.userEmail;
};
xdg.configFile = { xdg.configFile = {
"git/config".text = lib.generators.toGitINI cfg.iniContent; "git/config".text = lib.generators.toGitINI cfg.iniContent;
@ -438,8 +450,6 @@ in
}; };
}) })
(mkIf (cfg.aliases != { }) { programs.git.iniContent.alias = cfg.aliases; })
(mkIf (cfg.settings != { }) { (mkIf (cfg.settings != { }) {
programs.git.iniContent = cfg.settings; programs.git.iniContent = cfg.settings;
}) })

View file

@ -7,8 +7,12 @@
programs.git = { programs.git = {
enable = true; enable = true;
userEmail = "hm@example.com"; settings = {
userName = "H. M. Test"; user = {
email = "hm@example.com";
name = "H. M. Test";
};
};
}; };
home.stateVersion = "20.09"; home.stateVersion = "20.09";

View file

@ -1,8 +1,12 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userName = "John Doe"; settings = {
userEmail = "user@example.org"; user = {
name = "John Doe";
email = "user@example.org";
};
};
lfs = { lfs = {
enable = true; enable = true;

View file

@ -8,8 +8,12 @@
programs.git = { programs.git = {
enable = true; enable = true;
signing.signer = "path-to-gpg"; signing.signer = "path-to-gpg";
userEmail = "hm@example.com"; settings = {
userName = "H. M. Test"; user = {
email = "hm@example.com";
name = "H. M. Test";
};
};
}; };
home.stateVersion = "20.09"; home.stateVersion = "20.09";

View file

@ -3,8 +3,12 @@
config = { config = {
programs.git = { programs.git = {
enable = true; enable = true;
userName = "John Doe"; settings = {
userEmail = "user@example.org"; user = {
name = "John Doe";
email = "user@example.org";
};
};
signing = { signing = {
gpgPath = "path-to-gpg"; gpgPath = "path-to-gpg";

View file

@ -1,8 +1,12 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userName = "John Doe"; settings = {
userEmail = "user@example.org"; user = {
name = "John Doe";
email = "user@example.org";
};
};
signing = { signing = {
signer = "path-to-ssh"; signer = "path-to-ssh";

View file

@ -1,8 +1,12 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userName = "John Doe"; settings = {
userEmail = "user@example.org"; user = {
name = "John Doe";
email = "user@example.org";
};
};
signing = { signing = {
signer = "path-to-gpg"; signer = "path-to-gpg";

View file

@ -1,8 +1,12 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userName = "John Doe"; settings = {
userEmail = "user@example.org"; user = {
name = "John Doe";
email = "user@example.org";
};
};
}; };
home.stateVersion = "25.05"; home.stateVersion = "25.05";

View file

@ -29,16 +29,20 @@ in
{ {
enable = true; enable = true;
package = pkgs.gitMinimal; package = pkgs.gitMinimal;
aliases = { settings = {
a1 = "foo"; alias = {
a2 = "bar"; a1 = "foo";
escapes = ''"\n ''; a2 = "bar";
}; escapes = ''"\n '';
extraConfig = { };
extra = { extra = {
name = "value"; name = "value";
multiple = [ 1 ]; multiple = [ 1 ];
}; };
user = {
email = "user@example.org";
name = "John Doe";
};
}; };
ignores = [ ignores = [
"*~" "*~"
@ -66,13 +70,10 @@ in
key = "00112233445566778899AABBCCDDEEFF"; key = "00112233445566778899AABBCCDDEEFF";
signByDefault = true; signByDefault = true;
}; };
userEmail = "user@example.org";
userName = "John Doe";
lfs.enable = true; lfs.enable = true;
} }
{ {
aliases.a2 = lib.mkForce "baz";
settings.alias.a2 = lib.mkForce "baz"; settings.alias.a2 = lib.mkForce "baz";
settings."extra \"backcompat.with.dots\"".previously = "worked"; settings."extra \"backcompat.with.dots\"".previously = "worked";
settings.extra.boolean = true; settings.extra.boolean = true;