diff options
author | Ben Wolsieffer <benwolsieffer@gmail.com> | 2018-08-28 18:31:45 -0400 |
---|---|---|
committer | Ben Wolsieffer <benwolsieffer@gmail.com> | 2018-08-28 19:31:10 -0400 |
commit | 442681cc2ae35755171adbf49b4da709692d63ec (patch) | |
tree | d1fc2e9601c1a977b8ced7632c44489c898898ba /nixos | |
parent | c748ac5bdd4891bc837885b63e0144b9ef0e5ac3 (diff) |
nixos/networkd: fix range assertions on 32 bit Nix
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/boot/networkd.nix | 15 | ||||
-rw-r--r-- | nixos/modules/system/boot/systemd-lib.nix | 8 |
2 files changed, 18 insertions, 5 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index c11aaeaeb6dcd..4bacf0f126a4b 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -30,10 +30,14 @@ let (assertValueOneOf "UDPSegmentationOffload" boolValues) (assertValueOneOf "GenericReceiveOffload" boolValues) (assertValueOneOf "LargeReceiveOffload" boolValues) - (assertRange "RxChannels" 1 4294967295) - (assertRange "TxChannels" 1 4294967295) - (assertRange "OtherChannels" 1 4294967295) - (assertRange "CombinedChannels" 1 4294967295) + (assertInt "RxChannels") + (assertMinimum "RxChannels" 1) + (assertInt "TxChannels") + (assertMinimum "TxChannels" 1) + (assertInt "OtherChannels") + (assertMinimum "OtherChannels" 1) + (assertInt "CombinedChannels") + (assertMinimum "CombinedChannels" 1) ]; checkNetdev = checkUnitConfig "Netdev" [ @@ -226,7 +230,8 @@ let (assertValueOneOf "UseTimezone" boolValues) (assertValueOneOf "CriticalConnection" boolValues) (assertValueOneOf "RequestBroadcast" boolValues) - (assertRange "RouteTable" 0 4294967295) + (assertInt "RouteTable") + (assertMinimum "RouteTable" 0) (assertValueOneOf "RapidCommit" boolValues) ]; diff --git a/nixos/modules/system/boot/systemd-lib.nix b/nixos/modules/system/boot/systemd-lib.nix index 8b37bf8d35d81..9c8d4a026b4af 100644 --- a/nixos/modules/system/boot/systemd-lib.nix +++ b/nixos/modules/system/boot/systemd-lib.nix @@ -73,11 +73,19 @@ in rec { optional (attr ? ${name} && !(min <= attr.${name} && max >= attr.${name})) "Systemd ${group} field `${name}' is outside the range [${toString min},${toString max}]"; + assertMinimum = name: min: group: attr: + optional (attr ? ${name} && attr.${name} < min) + "Systemd ${group} field `${name}' must be greater than or equal to ${toString min}"; + assertOnlyFields = fields: group: attr: let badFields = filter (name: ! elem name fields) (attrNames attr); in optional (badFields != [ ]) "Systemd ${group} has extra fields [${concatStringsSep " " badFields}]."; + assertInt = name: group: attr: + optional (attr ? ${name} && !isInt attr.${name}) + "Systemd ${group} field `${name}' is not an integer"; + checkUnitConfig = group: checks: attrs: let # We're applied at the top-level type (attrsOf unitOption), so the actual # unit options might contain attributes from mkOverride that we need to |