diff options
Diffstat (limited to 'modules/networkd')
-rw-r--r-- | modules/networkd/default.nix | 1 | ||||
-rw-r--r-- | modules/networkd/systemd-lib.nix | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/modules/networkd/default.nix b/modules/networkd/default.nix index 007f14c6..f78a9aee 100644 --- a/modules/networkd/default.nix +++ b/modules/networkd/default.nix | |||
@@ -96,6 +96,7 @@ let | |||
96 | "MACAddress" | 96 | "MACAddress" |
97 | ]) | 97 | ]) |
98 | (assertHasField "Name") | 98 | (assertHasField "Name") |
99 | (assertMaxLength "Name" 15) | ||
99 | (assertHasField "Kind") | 100 | (assertHasField "Kind") |
100 | (assertValueOneOf "Kind" [ | 101 | (assertValueOneOf "Kind" [ |
101 | "bond" | 102 | "bond" |
diff --git a/modules/networkd/systemd-lib.nix b/modules/networkd/systemd-lib.nix index 2dbf1503..c5b5b7cb 100644 --- a/modules/networkd/systemd-lib.nix +++ b/modules/networkd/systemd-lib.nix | |||
@@ -90,6 +90,10 @@ in rec { | |||
90 | optional (attr ? ${name} && !isInt attr.${name}) | 90 | optional (attr ? ${name} && !isInt attr.${name}) |
91 | "Systemd ${group} field `${name}' is not an integer"; | 91 | "Systemd ${group} field `${name}' is not an integer"; |
92 | 92 | ||
93 | assertMaxLength = name: max: group: attr: | ||
94 | optional (attr ? ${name} && stringLength attr.${name} > max) | ||
95 | "Systemd ${group} field `${name}' is too long (max of ${max})"; | ||
96 | |||
93 | checkUnitConfig = group: checks: attrs: let | 97 | checkUnitConfig = group: checks: attrs: let |
94 | # We're applied at the top-level type (attrsOf unitOption), so the actual | 98 | # We're applied at the top-level type (attrsOf unitOption), so the actual |
95 | # unit options might contain attributes from mkOverride and mkIf that we need to | 99 | # unit options might contain attributes from mkOverride and mkIf that we need to |