diff options
| author | Silvan Mosberger <contact@infinisil.com> | 2023-12-11 17:46:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-11 17:46:48 +0100 |
| commit | 04efefaa4c0ee3ff165b634d57625164c85f250a (patch) | |
| tree | e978d6843e80da7ae9aa44ad8ca645d1e21b1c01 /lib/strings.nix | |
| parent | Merge pull request #273470 from adisbladis/lib-tohexstring-static-values (diff) | |
| parent | lib.isConvertibleToString: Statically compute types list (diff) | |
| download | nixpkgs-04efefaa4c0ee3ff165b634d57625164c85f250a.tar.gz | |
Merge pull request #273473 from adisbladis/lib-isConvertibleToString-static-list
lib.isConvertibleToString: Statically compute types list
Diffstat (limited to 'lib/strings.nix')
| -rw-r--r-- | lib/strings.nix | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 93247cfcf35e..49654d8abaa7 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -978,9 +978,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. |
