diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-03-14 23:29:08 +0100 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-03-15 19:42:45 +0100 |
commit | 5e8b9de7285497e4ef749eb9c55916dd26fecb88 (patch) | |
tree | f50d4841588ffdbc9e411db506159b201e256aab /lib/strings.nix | |
parent | 99bc90e3019cd79de82b41481fe1cc2ef4900caa (diff) |
lib.strings.normalizePath: Deprecate for path values
There's no need to call this function on path data types, and it's confusing with the new lib.path library functions
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 963d937947f2b..be4e8ece59361 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -207,7 +207,20 @@ rec { normalizePath "/a//b///c/" => "/a/b/c/" */ - normalizePath = s: (builtins.foldl' (x: y: if y == "/" && hasSuffix "/" x then x else x+y) "" (stringToCharacters s)); + normalizePath = s: + warnIf + (isPath s) + '' + lib.strings.normalizePath: The argument (${toString s}) is a path value, but only strings are supported. + Path values are always normalised in Nix, so there's no need to call this function on them. + This function also copies the path to the Nix store and returns the store path, the same as "''${path}" will, which may not be what you want. + This behavior is deprecated and will throw an error in the future.'' + ( + builtins.foldl' + (x: y: if y == "/" && hasSuffix "/" x then x else x+y) + "" + (stringToCharacters s) + ); /* Depending on the boolean `cond', return either the given string or the empty string. Useful to concatenate against a bigger string. |