aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2021-05-20 13:55:00 +0200
committerregnat <rg@regnat.ovh>2021-06-11 13:32:49 +0200
commit56605b468868b834e44a9700907b734428cb120a (patch)
treeb0117083df01f50aafd8186cc048082721e99ef1 /src/nix-build
parent8e6ee1b9e924fbbbeb5594eb89e7a570f36ab6e1 (diff)
Make `nix-shell` support content-addressed derivations
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
Diffstat (limited to 'src/nix-build')
-rwxr-xr-xsrc/nix-build/nix-build.cc7
1 files changed, 7 insertions, 0 deletions
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();