aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2021-11-26 09:56:48 +0100
committerregnat <rg@regnat.ovh>2021-11-26 09:56:48 +0100
commit05081bedc156c8e6556b66fe2470fec14e074caf (patch)
treeb88b03ff77d057ee7bfd2015670b46c73043fc8f /src/nix-build
parent5fcf7f04a91c5cd0d49f833fe21991da89776a22 (diff)
Make `nix-shell` work when nixpkgs is content-addressed
Fix #5259
Diffstat (limited to 'src/nix-build')
-rwxr-xr-xsrc/nix-build/nix-build.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 75576ef8a..e2325c91f 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -359,6 +359,7 @@ static void main_nix_build(int argc, char * * argv)
is not set, then build bashInteractive from
<nixpkgs>. */
auto shell = getEnv("NIX_BUILD_SHELL");
+ std::optional<StorePath> shellDrv;
if (!shell) {
@@ -375,8 +376,7 @@ static void main_nix_build(int argc, char * * argv)
auto bashDrv = store->parseStorePath(drv->queryDrvPath());
pathsToBuild.push_back({bashDrv});
pathsToCopy.insert(bashDrv);
-
- shell = drv->queryOutPath() + "/bin/bash";
+ shellDrv = bashDrv;
} catch (Error & e) {
logError(e.info());
@@ -402,6 +402,11 @@ static void main_nix_build(int argc, char * * argv)
if (dryRun) return;
+ if (shellDrv) {
+ auto shellDrvOutputs = store->queryPartialDerivationOutputMap(shellDrv.value());
+ shell = store->printStorePath(shellDrvOutputs.at("out").value()) + "/bin/bash";
+ }
+
if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations)) {
auto resolvedDrv = drv.tryResolve(*store);
assert(resolvedDrv && "Successfully resolved the derivation");