diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2020-09-03 07:31:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 07:31:22 +0100 |
commit | 02a2649220887363e7730cfb2f0dcc3c4cf17f06 (patch) | |
tree | b63251fecca0a41f28cf43e6b93e178ba8a15d9a /nixos | |
parent | 742c7340d2b998065c5e03355e657ee338057658 (diff) | |
parent | 0bee87c40085c396607b431afcc743b253567607 (diff) |
Merge pull request #89748 from heinic/krb5-lists
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/config/krb5/default.nix | 34 | ||||
-rw-r--r-- | nixos/tests/krb5/example-config.nix | 8 |
2 files changed, 24 insertions, 18 deletions
diff --git a/nixos/modules/config/krb5/default.nix b/nixos/modules/config/krb5/default.nix index ff16ffcf9c65b..c2302451d702f 100644 --- a/nixos/modules/config/krb5/default.nix +++ b/nixos/modules/config/krb5/default.nix @@ -41,31 +41,30 @@ let value) else value; - mkIndent = depth: concatStrings (builtins.genList (_: " ") (2 * depth)); + indent = " "; - mkRelation = name: value: "${name} = ${mkVal { inherit value; }}"; + mkRelation = name: value: + if (isList value) then + concatMapStringsSep "\n" (mkRelation name) value + else "${name} = ${mkVal value}"; - mkVal = { value, depth ? 0 }: + mkVal = value: if (value == true) then "true" else if (value == false) then "false" else if (isInt value) then (toString value) - else if (isList value) then - concatMapStringsSep " " mkVal { inherit value depth; } else if (isAttrs value) then - (concatStringsSep "\n${mkIndent (depth + 1)}" - ([ "{" ] ++ (mapAttrsToList - (attrName: attrValue: let - mappedAttrValue = mkVal { - value = attrValue; - depth = depth + 1; - }; - in "${attrName} = ${mappedAttrValue}") - value))) + "\n${mkIndent depth}}" + let configLines = concatLists + (map (splitString "\n") + (mapAttrsToList mkRelation value)); + in + (concatStringsSep "\n${indent}" + ([ "{" ] ++ configLines)) + + "\n}" else value; mkMappedAttrsOrString = value: concatMapStringsSep "\n" (line: if builtins.stringLength line > 0 - then "${mkIndent 1}${line}" + then "${indent}${line}" else line) (splitString "\n" (if isAttrs value then @@ -114,7 +113,10 @@ in { { "ATHENA.MIT.EDU" = { admin_server = "athena.mit.edu"; - kdc = "athena.mit.edu"; + kdc = [ + "athena01.mit.edu" + "athena02.mit.edu" + ]; }; }; ''; diff --git a/nixos/tests/krb5/example-config.nix b/nixos/tests/krb5/example-config.nix index be195b5139352..e2e10a9fda892 100644 --- a/nixos/tests/krb5/example-config.nix +++ b/nixos/tests/krb5/example-config.nix @@ -18,7 +18,10 @@ import ../make-test-python.nix ({ pkgs, ...} : { realms = { "ATHENA.MIT.EDU" = { admin_server = "athena.mit.edu"; - kdc = "athena.mit.edu"; + kdc = [ + "athena01.mit.edu" + "athena02.mit.edu" + ]; }; }; domain_realm = { @@ -65,7 +68,8 @@ import ../make-test-python.nix ({ pkgs, ...} : { [realms] ATHENA.MIT.EDU = { admin_server = athena.mit.edu - kdc = athena.mit.edu + kdc = athena01.mit.edu + kdc = athena02.mit.edu } [domain_realm] |