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

git: extraConfig -> settings

Remove string support and convert to rfc42 settings option

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-10-18 10:43:20 -05:00
parent 85cd07b8b0
commit ac7c05a90c
10 changed files with 17 additions and 65 deletions

View file

@ -64,7 +64,7 @@ in
programs.git.attributes = lib.mkIf (cfg.enableGitIntegration && (cfg.package != null)) [ programs.git.attributes = lib.mkIf (cfg.enableGitIntegration && (cfg.package != null)) [
"*.lockb binary diff=lockb" "*.lockb binary diff=lockb"
]; ];
programs.git.extraConfig.diff.lockb = lib.mkIf (cfg.enableGitIntegration && (cfg.package != null)) { programs.git.settings.diff.lockb = lib.mkIf (cfg.enableGitIntegration && (cfg.package != null)) {
textconv = lib.getExe cfg.package; textconv = lib.getExe cfg.package;
binary = true; binary = true;
}; };

View file

@ -188,7 +188,7 @@ in
fi fi
''; '';
programs.git.extraConfig.credential = mkIf cfg.gitCredentialHelper.enable ( programs.git.settings.credential = mkIf cfg.gitCredentialHelper.enable (
builtins.listToAttrs ( builtins.listToAttrs (
map ( map (
host: host:

View file

@ -35,7 +35,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
programs.git.extraConfig.credential = programs.git.settings.credential =
let let
helperConfig = helperConfig =
let let

View file

@ -35,7 +35,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
programs.git.extraConfig.credential.helper = lib.mkAfter [ programs.git.settings.credential.helper = lib.mkAfter [
( (
"${cfg.package}/bin/git-credential-oauth" "${cfg.package}/bin/git-credential-oauth"
+ lib.optionalString (cfg.extraFlags != [ ]) " ${lib.strings.concatStringsSep " " cfg.extraFlags}" + lib.optionalString (cfg.extraFlags != [ ]) " ${lib.strings.concatStringsSep " " cfg.extraFlags}"

View file

@ -111,8 +111,8 @@ in
}; };
}; };
extraConfig = mkOption { settings = mkOption {
type = types.either types.lines gitIniType; type = gitIniType;
default = { }; default = { };
example = { example = {
core = { core = {
@ -121,8 +121,8 @@ in
url."ssh://git@host".insteadOf = "otherhost"; url."ssh://git@host".insteadOf = "otherhost";
}; };
description = '' description = ''
Additional configuration to add. The use of string values is Configuration written to {file}`$XDG_CONFIG_HOME/git/config`.
deprecated and will be removed in the future. See {manpage}`git-config(1)` for details.
''; '';
}; };
@ -440,20 +440,8 @@ in
(mkIf (cfg.aliases != { }) { programs.git.iniContent.alias = cfg.aliases; }) (mkIf (cfg.aliases != { }) { programs.git.iniContent.alias = cfg.aliases; })
(mkIf (lib.isAttrs cfg.extraConfig) { (mkIf (cfg.settings != { }) {
programs.git.iniContent = cfg.extraConfig; programs.git.iniContent = cfg.settings;
})
(mkIf (lib.isString cfg.extraConfig) {
warnings = [
''
Using programs.git.extraConfig as a string option is
deprecated and will be removed in the future. Please
change to using it as an attribute set instead.
''
];
xdg.configFile."git/config".text = cfg.extraConfig;
}) })
(mkIf (cfg.includes != [ ]) { (mkIf (cfg.includes != [ ]) {

View file

@ -29,7 +29,7 @@ in
programs.git = { programs.git = {
attributes = [ "* merge=mergiraf" ]; attributes = [ "* merge=mergiraf" ];
extraConfig = { settings = {
merge = { merge = {
mergiraf = { mergiraf = {
name = "mergiraf"; name = "mergiraf";

View file

@ -2,7 +2,6 @@
git-with-email = ./git-with-email.nix; git-with-email = ./git-with-email.nix;
git-with-most-options = ./git.nix; git-with-most-options = ./git.nix;
git-with-msmtp = ./git-with-msmtp.nix; git-with-msmtp = ./git-with-msmtp.nix;
git-with-str-extra-config = ./git-with-str-extra-config.nix;
git-with-signing-key-id-legacy = ./git-with-signing-key-id-legacy.nix; git-with-signing-key-id-legacy = ./git-with-signing-key-id-legacy.nix;
git-with-signing-key-id = ./git-with-signing-key-id.nix; git-with-signing-key-id = ./git-with-signing-key-id.nix;
git-without-signing-key-id = ./git-without-signing-key-id.nix; git-without-signing-key-id = ./git-without-signing-key-id.nix;

View file

@ -1,11 +0,0 @@
This can be anything.
[gpg]
format = "openpgp"
[gpg "openpgp"]
program = "path-to-gpg"
[user]
email = "user@example.org"
name = "John Doe"

View file

@ -1,25 +0,0 @@
{
programs.git = {
enable = true;
signing.signer = "path-to-gpg";
extraConfig = ''
This can be anything.
'';
userEmail = "user@example.org";
userName = "John Doe";
};
test.asserts.warnings.expected = [
''
Using programs.git.extraConfig as a string option is
deprecated and will be removed in the future. Please
change to using it as an attribute set instead.
''
];
nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${./git-with-str-extra-config-expected.conf}
'';
}

View file

@ -73,11 +73,12 @@ in
{ {
aliases.a2 = lib.mkForce "baz"; aliases.a2 = lib.mkForce "baz";
extraConfig."extra \"backcompat.with.dots\"".previously = "worked"; settings.alias.a2 = lib.mkForce "baz";
extraConfig.extra.boolean = true; settings."extra \"backcompat.with.dots\"".previously = "worked";
extraConfig.extra.integer = 38; settings.extra.boolean = true;
extraConfig.extra.multiple = [ 2 ]; settings.extra.integer = 38;
extraConfig.extra.subsection.value = "test"; settings.extra.multiple = [ 2 ];
settings.extra.subsection.value = "test";
} }
]; ];