git: support multiple values

Closes #614
This commit is contained in:
arcnmx 2019-03-12 01:35:55 -07:00 committed by Robert Helgesson
parent 28f2dd612e
commit 472d7731d6
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 19 additions and 4 deletions

View file

@ -6,11 +6,22 @@ let
cfg = config.programs.git;
# generation for multiple ini values
mkKeyValue = k: v:
let
mkKeyValue = generators.mkKeyValueDefault {} "=" k;
in
concatStringsSep "\n" (map mkKeyValue (toList v));
gitToIni = generators.toINI { inherit mkKeyValue; };
gitIniType = with types;
let
primitiveType = either bool (either int str);
primitiveType = either str (either bool int);
multipleType = either primitiveType (listOf primitiveType);
sectionType = attrsOf multipleType;
in
attrsOf (attrsOf primitiveType);
attrsOf sectionType;
signModule = types.submodule {
options = {
@ -64,7 +75,7 @@ let
};
config.path = mkIf (config.contents != {}) (
mkDefault (pkgs.writeText "contents" (generators.toINI {} config.contents))
mkDefault (pkgs.writeText "contents" (gitToIni config.contents))
);
});
@ -175,7 +186,7 @@ in
};
xdg.configFile = {
"git/config".text = generators.toINI {} cfg.iniContent;
"git/config".text = gitToIni cfg.iniContent;
"git/ignore" = mkIf (cfg.ignores != []) {
text = concatStringsSep "\n" cfg.ignores + "\n";