From 5753fc14f5a24b2c4d5f4c76ed22d28a1be67c2a Mon Sep 17 00:00:00 2001 From: sterni Date: Thu, 20 Oct 2022 15:46:40 +0200 Subject: refactor(nix/dependency-analyzer): use unsafeDiscardOutputDependency 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 --- nix/dependency-analyzer/default.nix | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'nix/dependency-analyzer') diff --git a/nix/dependency-analyzer/default.nix b/nix/dependency-analyzer/default.nix index e127c82d7777..54ff72912ea8 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; -- cgit 1.4.1