tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/git: allow lists for config to keep things in order
figsoda
3 years ago
a0a6d4da
d0486aaa
+32
-6
1 changed file
expand all
collapse all
unified
split
nixos
modules
programs
git.nix
+32
-6
nixos/modules/programs/git.nix
···
20
20
};
21
21
22
22
config = mkOption {
23
23
-
type = with types; attrsOf (attrsOf anything);
24
24
-
default = { };
23
23
+
type =
24
24
+
with types;
25
25
+
let
26
26
+
gitini = attrsOf (attrsOf anything);
27
27
+
in
28
28
+
either gitini (listOf gitini) // {
29
29
+
merge = loc: defs:
30
30
+
let
31
31
+
config = foldl'
32
32
+
(acc: { value, ... }@x: acc // (if isList value then {
33
33
+
ordered = acc.ordered ++ value;
34
34
+
} else {
35
35
+
unordered = acc.unordered ++ [ x ];
36
36
+
}))
37
37
+
{
38
38
+
ordered = [ ];
39
39
+
unordered = [ ];
40
40
+
}
41
41
+
defs;
42
42
+
in
43
43
+
[ (gitini.merge loc config.unordered) ] ++ config.ordered;
44
44
+
};
45
45
+
default = [ ];
25
46
example = {
26
47
init.defaultBranch = "main";
27
48
url."https://github.com/".insteadOf = [ "gh:" "github:" ];
28
49
};
29
50
description = lib.mdDoc ''
30
30
-
Configuration to write to /etc/gitconfig. See the CONFIGURATION FILE
31
31
-
section of git-config(1) for more information.
51
51
+
Configuration to write to /etc/gitconfig. A list can also be
52
52
+
specified to keep the configuration in order. For example, setting
53
53
+
`config` to `[ { foo.x = 42; } { bar.y = 42; }]` will put the `foo`
54
54
+
section before the `bar` section unlike the default alphabetical
55
55
+
order, which can be helpful for sections such as `include` and
56
56
+
`includeIf`. See the CONFIGURATION FILE section of git-config(1) for
57
57
+
more information.
32
58
'';
33
59
};
34
60
···
48
74
config = mkMerge [
49
75
(mkIf cfg.enable {
50
76
environment.systemPackages = [ cfg.package ];
51
51
-
environment.etc.gitconfig = mkIf (cfg.config != {}) {
52
52
-
text = generators.toGitINI cfg.config;
77
77
+
environment.etc.gitconfig = mkIf (cfg.config != [ ]) {
78
78
+
text = concatMapStringsSep "\n" generators.toGitINI cfg.config;
53
79
};
54
80
})
55
81
(mkIf (cfg.enable && cfg.lfs.enable) {