mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
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.
This commit is contained in:
parent
0590c2a4f6
commit
445c0b1482
3 changed files with 50 additions and 30 deletions
|
@ -6,6 +6,12 @@ let
|
||||||
|
|
||||||
cfg = config.programs.git;
|
cfg = config.programs.git;
|
||||||
|
|
||||||
|
gitIniType = with types;
|
||||||
|
let
|
||||||
|
primitiveType = either bool (either int str);
|
||||||
|
in
|
||||||
|
attrsOf (attrsOf primitiveType);
|
||||||
|
|
||||||
signModule = types.submodule {
|
signModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
key = mkOption {
|
key = mkOption {
|
||||||
|
@ -80,8 +86,9 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
aliases = mkOption {
|
aliases = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrsOf types.str;
|
||||||
default = {};
|
default = {};
|
||||||
|
example = { co = "checkout"; };
|
||||||
description = "Git aliases to define.";
|
description = "Git aliases to define.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,13 +99,16 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
type = types.either types.attrs types.lines;
|
type = types.either types.lines gitIniType;
|
||||||
default = {};
|
default = {};
|
||||||
|
example = {
|
||||||
|
core = { whitespace = "trailing-space,space-before-tab"; };
|
||||||
|
};
|
||||||
description = "Additional configuration to add.";
|
description = "Additional configuration to add.";
|
||||||
};
|
};
|
||||||
|
|
||||||
iniContent = mkOption {
|
iniContent = mkOption {
|
||||||
type = types.attrsOf types.attrs;
|
type = gitIniType;
|
||||||
internal = true;
|
internal = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
[alias]
|
[alias]
|
||||||
a1=foo
|
a1=foo
|
||||||
a2=bar
|
a2=baz
|
||||||
|
|
||||||
[commit]
|
[commit]
|
||||||
gpgSign=true
|
gpgSign=true
|
||||||
|
|
||||||
[extra]
|
[extra]
|
||||||
|
boolean=true
|
||||||
|
integer=38
|
||||||
name=value
|
name=value
|
||||||
|
|
||||||
[gpg]
|
[gpg]
|
||||||
|
|
|
@ -4,33 +4,41 @@ with lib;
|
||||||
|
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
programs.git = {
|
programs.git = mkMerge [
|
||||||
enable = true;
|
{
|
||||||
aliases = {
|
enable = true;
|
||||||
a1 = "foo";
|
aliases = {
|
||||||
a2 = "bar";
|
a1 = "foo";
|
||||||
};
|
a2 = "bar";
|
||||||
extraConfig = {
|
|
||||||
extra = {
|
|
||||||
name = "value";
|
|
||||||
};
|
};
|
||||||
};
|
extraConfig = {
|
||||||
ignores = [ "*~" "*.swp" ];
|
extra = {
|
||||||
includes = [
|
name = "value";
|
||||||
{ path = "~/path/to/config.inc"; }
|
};
|
||||||
{
|
};
|
||||||
path = "~/path/to/conditional.inc";
|
ignores = [ "*~" "*.swp" ];
|
||||||
condition = "gitdir:~/src/dir";
|
includes = [
|
||||||
}
|
{ path = "~/path/to/config.inc"; }
|
||||||
];
|
{
|
||||||
signing = {
|
path = "~/path/to/conditional.inc";
|
||||||
gpgPath = "path-to-gpg";
|
condition = "gitdir:~/src/dir";
|
||||||
key = "00112233445566778899AABBCCDDEEFF";
|
}
|
||||||
signByDefault = true;
|
];
|
||||||
};
|
signing = {
|
||||||
userEmail = "user@example.org";
|
gpgPath = "path-to-gpg";
|
||||||
userName = "John Doe";
|
key = "00112233445566778899AABBCCDDEEFF";
|
||||||
};
|
signByDefault = true;
|
||||||
|
};
|
||||||
|
userEmail = "user@example.org";
|
||||||
|
userName = "John Doe";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
aliases.a2 = mkForce "baz";
|
||||||
|
extraConfig.extra.boolean = true;
|
||||||
|
extraConfig.extra.integer = 38;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/git/config
|
assertFileExists home-files/.config/git/config
|
||||||
|
|
Loading…
Reference in a new issue