From 7c4a71081cb4a52e5fac535f6a27143bb354ec77 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Thu, 14 Mar 2024 10:46:35 -0700 Subject: [PATCH] Avoid top-level `with ...;` in pkgs/build-support/replace-dependency.nix --- pkgs/build-support/replace-dependency.nix | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/replace-dependency.nix b/pkgs/build-support/replace-dependency.nix index 5b4c127cdd8e..7912d21bfd69 100644 --- a/pkgs/build-support/replace-dependency.nix +++ b/pkgs/build-support/replace-dependency.nix @@ -19,9 +19,20 @@ # (and all of its dependencies) without rebuilding further. { drv, oldDependency, newDependency, verbose ? true }: -with lib; - let + inherit (lib) + any + attrNames + concatStringsSep + elem + filter + filterAttrs + listToAttrs + mapAttrsToList + stringLength + substring + ; + warn = if verbose then builtins.trace else (x: y: y); references = import (runCommandLocal "references.nix" { exportReferencesGraph = [ "graph" drv ]; } '' (echo { @@ -54,7 +65,7 @@ let (drv: { name = discard (toString drv); value = elem oldStorepath (referencesOf drv) || any dependsOnOld (referencesOf drv); - }) (builtins.attrNames references)); + }) (attrNames references)); dependsOnOld = drv: dependsOnOldMemo.${discard (toString drv)}; @@ -74,9 +85,9 @@ let rewriteMemo = listToAttrs (map (drv: { name = discard (toString drv); value = rewriteHashes (builtins.storePath drv) - (filterAttrs (n: v: builtins.elem (builtins.storePath (discard (toString n))) (referencesOf drv)) rewriteMemo); + (filterAttrs (n: v: elem (builtins.storePath (discard (toString n))) (referencesOf drv)) rewriteMemo); }) - (filter dependsOnOld (builtins.attrNames references))) // rewrittenDeps; + (filter dependsOnOld (attrNames references))) // rewrittenDeps; drvHash = discard (toString drv); in assert (stringLength (drvName (toString oldDependency)) == stringLength (drvName (toString newDependency)));