From 80074809ee1fa4e89f5c7e0bfe6df8151dee755d Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Sun, 4 Aug 2024 13:44:18 -0600 Subject: [PATCH] fix: work inside a flake While we don't want to encourage it, it would be helpful to ease adoption if users could call this module function from inside their flake.nix. The only thing preventing that was the path referencing becoming a pure /nix/store path reference implicitly (via the flake) and so failing because of the string context. Fix this by simply removing the string context. This isn't actually unsafe since if the absolute path literal refers to a store path and is ever coerced back to a string, nix will readd the context automatically. --- std/path/strToPath.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/std/path/strToPath.nix b/std/path/strToPath.nix index dcfb15f..bb20f37 100644 --- a/std/path/strToPath.nix +++ b/std/path/strToPath.nix @@ -1,7 +1,10 @@ str: let # strip off the first `/` of an absolute path - frag = std.substring 1 (-1) str; + # disgarding the string context of a store path should be safe here + # since if the path refers to a store path, the context will be readded + # if/when the path is turned back into a string + frag = std.unsafeDiscardStringContext (std.substring 1 (-1) str); # will fail if the string does not represent an absolute path # which is what we want since this function makes little sense otherwise validate = std.toPath str;