Skip to content

Commit d1f750a

Browse files
edolstraEricson2314
authored andcommitted
nix develop: getBuildEnvironment return StorePath
1 parent af1db77 commit d1f750a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/nix/develop.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
304304
bmNormal,
305305
evalStore);
306306

307+
// `get-env.sh` will write its JSON output to an arbitrary output
308+
// path, so return the first non-empty output path.
307309
for (auto & [_0, optPath] : evalStore->queryPartialDerivationOutputMap(shellDrvPath)) {
308310
assert(optPath);
309311
auto accessor = evalStore->requireStoreObjectAccessor(*optPath);
@@ -497,19 +499,18 @@ struct Common : InstallableCommand, MixProfile
497499
}
498500
}
499501

500-
std::pair<BuildEnvironment, std::string> getBuildEnvironment(ref<Store> store, ref<Installable> installable)
502+
std::pair<BuildEnvironment, StorePath> getBuildEnvironment(ref<Store> store, ref<Installable> installable)
501503
{
502504
auto shellOutPath = getShellOutPath(store, installable);
503505

504-
auto strPath = store->printStorePath(shellOutPath);
505-
506506
updateProfile(shellOutPath);
507507

508-
debug("reading environment file '%s'", strPath);
508+
debug("reading environment file '%s'", store->printStorePath(shellOutPath));
509509

510510
return {
511511
BuildEnvironment::parseJSON(store->requireStoreObjectAccessor(shellOutPath)->readFile(CanonPath::root)),
512-
strPath};
512+
shellOutPath,
513+
};
513514
}
514515
};
515516

@@ -636,7 +637,7 @@ struct CmdDevelop : Common, MixEnvironment
636637

637638
setEnviron();
638639
// prevent garbage collection until shell exits
639-
setEnv("NIX_GCROOT", gcroot.c_str());
640+
setEnv("NIX_GCROOT", store->printStorePath(gcroot).c_str());
640641

641642
Path shell = "bash";
642643
bool foundInteractive = false;

0 commit comments

Comments
 (0)