about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-10-20T13·46+0200
committersterni <sternenseemann@systemli.org>2022-10-20T18·21+0000
commit5753fc14f5a24b2c4d5f4c76ed22d28a1be67c2a (patch)
treea4f6a65c1f763c2907393c5d61ec04baa7a55794 /nix
parentb410655a5e50c8365bcdd85194d9ef9b5ef786bb (diff)
refactor(nix/dependency-analyzer): use unsafeDiscardOutputDependency r/5171
Turns out that pathContextDrvPath already exists as a builtin which
is very convenient. Actually somewhat embarassing that I missed this
for so long.

Change-Id: Ieb5e113d70dec548b3053911ff9dbe9ed48402be
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7050
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'nix')
-rw-r--r--nix/dependency-analyzer/default.nix20
1 files changed, 2 insertions, 18 deletions
diff --git a/nix/dependency-analyzer/default.nix b/nix/dependency-analyzer/default.nix
index e127c82d77..54ff72912e 100644
--- a/nix/dependency-analyzer/default.nix
+++ b/nix/dependency-analyzer/default.nix
@@ -7,22 +7,6 @@ let
   # Utilities
   #
 
-  # Manipulate string context of the given string so that it only carries a
-  # `path` reference to itself (so it needs to be a string representation of
-  # a store path).
-  #
-  # This is intended for use on the `drvPath` attribute of derivations which by
-  # default carries a reference to the corresponding outputs. If we only want to
-  # read from the `drvPath`, having only a `path` reference makes sure we don't
-  # need to realise the derivation first.
-  #
-  # Type: str -> str
-  pathContextDrvPath = drvPath:
-    let
-      drvPath' = unsafeDiscardStringContext drvPath;
-    in
-    appendContext drvPath' { ${drvPath'} = { path = true; }; };
-
   # Determine all paths a derivation depends on, i.e. input derivations and
   # files imported into the Nix store.
   #
@@ -61,7 +45,7 @@ let
   #
   # Type: [drv] -> [str]
   drvsToPaths = drvs:
-    builtins.map (drv: pathContextDrvPath drv.drvPath) drvs;
+    builtins.map (drv: builtins.unsafeDiscardOutputDependency drv.drvPath) drvs;
 
   #
   # Calculate map of direct derivation dependencies
@@ -78,7 +62,7 @@ let
       # key may not refer to a store path, …
       key = unsafeDiscardStringContext drvPath;
       # but we must read from the .drv file.
-      path = pathContextDrvPath drvPath;
+      path = builtins.unsafeDiscardOutputDependency drvPath;
     in
     {
       inherit key;