git: change extraConfig from lines to attrs
This commit is contained in:
parent
db55e596d2
commit
0f096f9ad4
|
@ -192,6 +192,34 @@ in
|
|||
A new service is available: 'services.screen-locker'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2017-09-22T12:09:01+00:00";
|
||||
condition = isString config.programs.git.extraConfig;
|
||||
message = ''
|
||||
The 'programs.git.extraConfig' parameter now accepts
|
||||
attributes instead of strings which allows more flexible
|
||||
configuration.
|
||||
|
||||
The string parameter type will be deprecated in the future,
|
||||
please change your configuration file accordingly.
|
||||
|
||||
For example, if your configuration includes
|
||||
|
||||
programs.git.extraConfig = '''
|
||||
[core]
|
||||
editor = vim
|
||||
''';
|
||||
|
||||
then you can now change it to
|
||||
|
||||
programs.git.extraConfig = {
|
||||
core = {
|
||||
editor = "vim";
|
||||
};
|
||||
};
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -65,34 +65,51 @@ in
|
|||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
type = types.either types.attrs types.lines;
|
||||
default = {};
|
||||
description = "Additional configuration to add.";
|
||||
};
|
||||
|
||||
iniContent = mkOption {
|
||||
type = types.attrsOf types.attrs;
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
ini = {
|
||||
user = {
|
||||
name = cfg.userName;
|
||||
email = cfg.userEmail;
|
||||
} // optionalAttrs (cfg.signing != null) {
|
||||
signingKey = cfg.signing.key;
|
||||
};
|
||||
} // optionalAttrs (cfg.signing != null) {
|
||||
commit.gpgSign = cfg.signing.signByDefault;
|
||||
gpg.program = cfg.signing.gpgPath;
|
||||
} // optionalAttrs (cfg.aliases != {}) {
|
||||
alias = cfg.aliases;
|
||||
};
|
||||
in
|
||||
mkMerge [
|
||||
{
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs.git.iniContent.user = {
|
||||
name = cfg.userName;
|
||||
email = cfg.userEmail;
|
||||
};
|
||||
|
||||
home.file.".gitconfig".text =
|
||||
generators.toINI {} ini + "\n" + cfg.extraConfig;
|
||||
generators.toINI {} cfg.iniContent;
|
||||
}
|
||||
|
||||
(mkIf (cfg.signing != null) {
|
||||
programs.git.iniContent = {
|
||||
user.signingKey = cfg.signing.key;
|
||||
commit.gpgSign = cfg.signing.signByDefault;
|
||||
gpg.program = cfg.signing.gpgPath;
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.aliases != {}) {
|
||||
programs.git.iniContent.alias = cfg.aliases;
|
||||
})
|
||||
|
||||
(mkIf (lib.isAttrs cfg.extraConfig) {
|
||||
programs.git.iniContent = cfg.extraConfig;
|
||||
})
|
||||
|
||||
(mkIf (lib.isString cfg.extraConfig) {
|
||||
home.file.".gitconfig".text = cfg.extraConfig;
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue