summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-12-28 23:34:15 +0100
committerRobert Hensing <robert@roberthensing.nl>2022-12-31 01:03:24 +0100
commit68b6443ed635a3e87a62a5a8dcfd05e952c93192 (patch)
treea1d17b532edbd1317667b40e58f79288ecf75570
parentlib.types.anything: Use isSimpleCoercibleToString (diff)
downloadnixpkgs-68b6443ed635a3e87a62a5a8dcfd05e952c93192.tar.gz
lib.strings: Rename isCoercibleToString -> isMoreCoercibleToString
-rw-r--r--lib/strings.nix13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index edc31b4e9e36..897fa3e3a204 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -798,8 +798,17 @@ rec {
in lib.warnIf (!precise) "Imprecise conversion from float to string ${result}"
result;
- /* Check whether a value can be coerced to a string */
- isCoercibleToString = x:
+ /* Soft-deprecated name for isMoreCoercibleToString */
+ isCoercibleToString = lib.warnIf (lib.isInOldestRelease 2305)
+ "lib.strings.isCoercibleToString is deprecated in favor of either isSimpleCoercibleToString or isMoreCoercibleString. Only use the latter if it needs to return true for null, numbers, booleans and list of similarly coercibles."
+ isMoreCoercibleToString;
+
+ /* Check whether a list or other value can be passed to toString.
+
+ Many types of value are coercible to string this way, including int, float,
+ null, bool, list of similarly coercible values.
+ */
+ isMoreCoercibleToString = x:
elem (typeOf x) [ "path" "string" "null" "int" "float" "bool" ] ||
(isList x && lib.all isCoercibleToString x) ||
x ? outPath ||