about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-05-08 10:15:11 +0300
committerGitHub <noreply@github.com>2024-05-08 10:15:11 +0300
commit20f90ebed6495fb2bb09b551e9dca5ddcec72623 (patch)
treeffa3c80649ee39110d9516c7a136cdbaa34bd1a0 /nixos
parent69058c0c5e9bfce09660c9d047aae0f219560195 (diff)
parent38907ef84d72b0ff253c7e996a9d5ca83db029b4 (diff)
Merge pull request #309608 from jmbaur/systemd-lib-range-or-one-of
nixos/systemd-lib: fix assertRangeOrOneOf when value is not comparable
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/systemd-lib.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix
index eef49f8c4ef38..0641da8e77517 100644
--- a/nixos/lib/systemd-lib.nix
+++ b/nixos/lib/systemd-lib.nix
@@ -18,6 +18,7 @@ let
     flip
     head
     isInt
+    isFloat
     isList
     isPath
     length
@@ -152,7 +153,7 @@ in rec {
       "Systemd ${group} field `${name}' is outside the range [${toString min},${toString max}]";
 
   assertRangeOrOneOf = name: min: max: values: group: attr:
-    optional (attr ? ${name} && !((min <= attr.${name} && max >= attr.${name}) || elem attr.${name} values))
+    optional (attr ? ${name} && !(((isInt attr.${name} || isFloat attr.${name}) && min <= attr.${name} && max >= attr.${name}) || elem attr.${name} values))
       "Systemd ${group} field `${name}' is not a value in range [${toString min},${toString max}], or one of ${toString values}";
 
   assertMinimum = name: min: group: attr: