git: use attrsOf
instead of attrs
This makes sure that values added to
programs.git.aliases
or
programs.git.extraConfig
are merged as expected.
Also add a few option examples.
(cherry picked from commit 445c0b1482
)
This commit is contained in:
parent
7772158ac4
commit
f89522362f
|
@ -6,6 +6,12 @@ let
|
|||
|
||||
cfg = config.programs.git;
|
||||
|
||||
gitIniType = with types;
|
||||
let
|
||||
primitiveType = either bool (either int str);
|
||||
in
|
||||
attrsOf (attrsOf primitiveType);
|
||||
|
||||
signModule = types.submodule {
|
||||
options = {
|
||||
key = mkOption {
|
||||
|
@ -80,8 +86,9 @@ in
|
|||
};
|
||||
|
||||
aliases = mkOption {
|
||||
type = types.attrs;
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
example = { co = "checkout"; };
|
||||
description = "Git aliases to define.";
|
||||
};
|
||||
|
||||
|
@ -92,13 +99,16 @@ in
|
|||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.either types.attrs types.lines;
|
||||
type = types.either types.lines gitIniType;
|
||||
default = {};
|
||||
example = {
|
||||
core = { whitespace = "trailing-space,space-before-tab"; };
|
||||
};
|
||||
description = "Additional configuration to add.";
|
||||
};
|
||||
|
||||
iniContent = mkOption {
|
||||
type = types.attrsOf types.attrs;
|
||||
type = gitIniType;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
[alias]
|
||||
a1=foo
|
||||
a2=bar
|
||||
a2=baz
|
||||
|
||||
[commit]
|
||||
gpgSign=true
|
||||
|
||||
[extra]
|
||||
boolean=true
|
||||
integer=38
|
||||
name=value
|
||||
|
||||
[gpg]
|
||||
|
|
|
@ -4,7 +4,8 @@ with lib;
|
|||
|
||||
{
|
||||
config = {
|
||||
programs.git = {
|
||||
programs.git = mkMerge [
|
||||
{
|
||||
enable = true;
|
||||
aliases = {
|
||||
a1 = "foo";
|
||||
|
@ -30,7 +31,14 @@ with lib;
|
|||
};
|
||||
userEmail = "user@example.org";
|
||||
userName = "John Doe";
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
aliases.a2 = mkForce "baz";
|
||||
extraConfig.extra.boolean = true;
|
||||
extraConfig.extra.integer = 38;
|
||||
}
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/git/config
|
||||
|
|
Loading…
Reference in a new issue