about summary refs log tree commit diff
path: root/nix/utils/default.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-12-16T16·28+0100
committerclbot <clbot@tvl.fyi>2021-12-17T10·47+0000
commit887ac4d3d479b2c5c991ed718792bba7a38b4948 (patch)
treef399ee4b83137c117723a6e7d62726d58c94c85b /nix/utils/default.nix
parente25ef08c4515999f26d73fffd3a0eb779eacbbf5 (diff)
feat(nix/utils): handle toString-able sets produced by builtins.path r/3285
When preparing cl/4381 I noticed that we actually handle this case
properly. depot.nix.utils.storePathName depot.path now works as
expected.

Change-Id: Ice9329c67b2e2210852012f5abe82fbbb13193de
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4382
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Autosubmit: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'nix/utils/default.nix')
-rw-r--r--nix/utils/default.nix7
1 files changed, 4 insertions, 3 deletions
diff --git a/nix/utils/default.nix b/nix/utils/default.nix
index f65d4712a03d..258e372a2a2d 100644
--- a/nix/utils/default.nix
+++ b/nix/utils/default.nix
@@ -21,17 +21,18 @@ let
     then p.name
     else if builtins.isPath p
     then builtins.baseNameOf p
-    else if builtins.isString p
+    else if builtins.isString p || (builtins.isAttrs p && (p ? outPath || p ? __toString))
     then
       let
+        strPath = toString p;
         # strip leading storeDir and trailing slashes
         noStoreDir = lib.removeSuffix "/"
-          (lib.removePrefix "${builtins.storeDir}/" p);
+          (lib.removePrefix "${builtins.storeDir}/" strPath);
         # a basename of a child of a store path isn't really
         # referring to a store path, so removing the string
         # context is safe (e. g. "hello" for "${hello}/bin/hello").
         basename = builtins.unsafeDiscardStringContext
-          (builtins.baseNameOf p);
+          (builtins.baseNameOf strPath);
       in
         # If p is a direct child of storeDir, we need to remove
         # the leading hash as well to make sure that: