diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-11-26 12:47:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-26 12:47:30 +0100 |
commit | b653fb9ccf2805f98b9777baec9cd4908f03bb3d (patch) | |
tree | 40e3b78a6f0d2e7b89dae1896174268c13da6562 /src | |
parent | c18238d92a04741e117c3f54d6ed7cc82a745482 (diff) | |
parent | 05081bedc156c8e6556b66fe2470fec14e074caf (diff) |
Merge pull request #5662 from NixOS/5259-nix-shell-with-ca-bash
Make `nix-shell` work when nixpkgs is content-addressed
Diffstat (limited to 'src')
-rwxr-xr-x | src/nix-build/nix-build.cc | 9 |
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"); |