summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoradisbladis <adisbladis@gmail.com>2023-12-11 16:42:13 +1300
committeradisbladis <adisbladis@gmail.com>2023-12-11 16:42:13 +1300
commita128a3f234afb3d0a1d67b8b36e93cc629d0186d (patch)
treeb420154d76bf784af04e7aa1b4e9e9e6aa92cd8b /lib
parentMerge pull request #273084 from l0b0/fix-web-ext (diff)
downloadnixpkgs-a128a3f234afb3d0a1d67b8b36e93cc629d0186d.tar.gz
lib.isConvertibleToString: Statically compute types list
Diffstat (limited to 'lib')
-rw-r--r--lib/strings.nix6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index 3403f9f32bb6..0e357daf8d9b 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -977,9 +977,11 @@ rec {
Many types of value are coercible to string this way, including int, float,
null, bool, list of similarly coercible values.
*/
- isConvertibleWithToString = x:
+ isConvertibleWithToString = let
+ types = [ "null" "int" "float" "bool" ];
+ in x:
isStringLike x ||
- elem (typeOf x) [ "null" "int" "float" "bool" ] ||
+ elem (typeOf x) types ||
(isList x && lib.all isConvertibleWithToString x);
/* Check whether a value can be coerced to a string.