1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 06:22:42 +01:00

nix develop: getBuildEnvironment return StorePath

This commit is contained in:
Eelco Dolstra 2025-09-08 09:39:44 +02:00 committed by John Ericson
parent af1db7774f
commit d1f750a714

View file

@ -304,6 +304,8 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
bmNormal, bmNormal,
evalStore); evalStore);
// `get-env.sh` will write its JSON output to an arbitrary output
// path, so return the first non-empty output path.
for (auto & [_0, optPath] : evalStore->queryPartialDerivationOutputMap(shellDrvPath)) { for (auto & [_0, optPath] : evalStore->queryPartialDerivationOutputMap(shellDrvPath)) {
assert(optPath); assert(optPath);
auto accessor = evalStore->requireStoreObjectAccessor(*optPath); auto accessor = evalStore->requireStoreObjectAccessor(*optPath);
@ -497,19 +499,18 @@ struct Common : InstallableCommand, MixProfile
} }
} }
std::pair<BuildEnvironment, std::string> getBuildEnvironment(ref<Store> store, ref<Installable> installable) std::pair<BuildEnvironment, StorePath> getBuildEnvironment(ref<Store> store, ref<Installable> installable)
{ {
auto shellOutPath = getShellOutPath(store, installable); auto shellOutPath = getShellOutPath(store, installable);
auto strPath = store->printStorePath(shellOutPath);
updateProfile(shellOutPath); updateProfile(shellOutPath);
debug("reading environment file '%s'", strPath); debug("reading environment file '%s'", store->printStorePath(shellOutPath));
return { return {
BuildEnvironment::parseJSON(store->requireStoreObjectAccessor(shellOutPath)->readFile(CanonPath::root)), BuildEnvironment::parseJSON(store->requireStoreObjectAccessor(shellOutPath)->readFile(CanonPath::root)),
strPath}; shellOutPath,
};
} }
}; };
@ -636,7 +637,7 @@ struct CmdDevelop : Common, MixEnvironment
setEnviron(); setEnviron();
// prevent garbage collection until shell exits // prevent garbage collection until shell exits
setEnv("NIX_GCROOT", gcroot.c_str()); setEnv("NIX_GCROOT", store->printStorePath(gcroot).c_str());
Path shell = "bash"; Path shell = "bash";
bool foundInteractive = false; bool foundInteractive = false;