about summary refs log tree commit diff
path: root/nix/readTree/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-27T00·50+0100
committertazjin <mail@tazj.in>2020-08-31T00·46+0000
commit29613e749465c1498d93bbb501949810eef3eec7 (patch)
treecdfc65db8acf51efc1fe8aa106ae9453aecc386d /nix/readTree/default.nix
parent9b4986c5edcf3f03be68c83c0ef246fb71f27e54 (diff)
feat(readTree): Use tree location as the value of `__readTree` r/1742
Change-Id: I6a087279b5d819db475f2179cb77c0f55cbd0ac6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1860
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Diffstat (limited to 'nix/readTree/default.nix')
-rw-r--r--nix/readTree/default.nix10
1 files changed, 8 insertions, 2 deletions
diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix
index 3ceb03299190..dedef5724063 100644
--- a/nix/readTree/default.nix
+++ b/nix/readTree/default.nix
@@ -6,6 +6,7 @@ let
   inherit (builtins)
     attrNames
     baseNameOf
+    concatStringsSep
     filter
     hasAttr
     head
@@ -31,12 +32,17 @@ let
       value = children.${name};
     }) names);
 
+  # Create a mark containing the location of this attribute.
+  marker = parts: {
+    __readTree = parts;
+  };
+
   # The marker is added to every set that was imported directly by
   # readTree.
   importWithMark = path: parts:
     let imported = import path (argsWithPath parts);
     in if (isAttrs imported)
-      then imported // { __readTree = true; }
+      then imported // (marker parts)
       else imported;
 
   nixFileName = file:
@@ -70,5 +76,5 @@ let
       }) nixFiles;
     in if dir ? "default.nix"
       then (if isAttrs self then self // (listToAttrs children) else self)
-      else (listToAttrs (nixChildren ++ children) // { __readTree = true; });
+      else (listToAttrs (nixChildren ++ children) // (marker parts));
 in readTree initPath [ (baseNameOf initPath) ]