From 56605b468868b834e44a9700907b734428cb120a Mon Sep 17 00:00:00 2001 From: regnat Date: Thu, 20 May 2021 13:55:00 +0200 Subject: Make `nix-shell` support content-addressed derivations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve the derivation before trying to load its environment − essentially reproducing what the build loop does − so that we can effectively access our dependencies (and not just their placeholders). Fix #4821 --- src/nix-build/nix-build.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nix-build') diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 9acbedda2..05eb7e234 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -387,6 +387,13 @@ static void main_nix_build(int argc, char * * argv) if (dryRun) return; + if (settings.isExperimentalFeatureEnabled("ca-derivations")) { + auto resolvedDrv = drv.tryResolve(*store); + if (!resolvedDrv) + throw Error("unable to resolve the derivation '%s'. nix-shell can’t continue", drvInfo.queryDrvPath()); + drv = *resolvedDrv; + } + // Set the environment. auto env = getEnv(); -- cgit v1.2.3 From 3b58dbb3561e02dc94e88b531d0942a7f8ccf8ea Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 22 Jun 2021 11:29:55 +0200 Subject: nix-shell: Replace resolving failure error by an assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This shouldn’t happen in practice, so better make it explicit --- src/nix-build/nix-build.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nix-build') diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 05eb7e234..3fec2c06c 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -389,8 +389,7 @@ static void main_nix_build(int argc, char * * argv) if (settings.isExperimentalFeatureEnabled("ca-derivations")) { auto resolvedDrv = drv.tryResolve(*store); - if (!resolvedDrv) - throw Error("unable to resolve the derivation '%s'. nix-shell can’t continue", drvInfo.queryDrvPath()); + assert(resolvedDrv && "Successfully resolved the derivation"); drv = *resolvedDrv; } -- cgit v1.2.3