mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 06:22:42 +01:00
Merge pull request #14530 from NixOS/nix-develop-cleanups-0
Two cleanups `nix develop`
This commit is contained in:
commit
d00c419ed6
1 changed files with 14 additions and 11 deletions
|
|
@ -227,11 +227,13 @@ const static std::string getEnvSh =
|
|||
#include "get-env.sh.gen.hh"
|
||||
;
|
||||
|
||||
/* Given an existing derivation, return the shell environment as
|
||||
initialised by stdenv's setup script. We do this by building a
|
||||
modified derivation with the same dependencies and nearly the same
|
||||
initial environment variables, that just writes the resulting
|
||||
environment to a file and exits. */
|
||||
/**
|
||||
* Given an existing derivation, return the shell environment as
|
||||
* initialised by stdenv's setup script. We do this by building a
|
||||
* modified derivation with the same dependencies and nearly the same
|
||||
* initial environment variables, that just writes the resulting
|
||||
* environment to a file and exits.
|
||||
*/
|
||||
static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore, const StorePath & drvPath)
|
||||
{
|
||||
auto drv = evalStore->derivationFromPath(drvPath);
|
||||
|
|
@ -302,6 +304,8 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
|
|||
bmNormal,
|
||||
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)) {
|
||||
assert(optPath);
|
||||
auto accessor = evalStore->requireStoreObjectAccessor(*optPath);
|
||||
|
|
@ -495,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 strPath = store->printStorePath(shellOutPath);
|
||||
|
||||
updateProfile(shellOutPath);
|
||||
|
||||
debug("reading environment file '%s'", strPath);
|
||||
debug("reading environment file '%s'", store->printStorePath(shellOutPath));
|
||||
|
||||
return {
|
||||
BuildEnvironment::parseJSON(store->requireStoreObjectAccessor(shellOutPath)->readFile(CanonPath::root)),
|
||||
strPath};
|
||||
shellOutPath,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -634,7 +637,7 @@ struct CmdDevelop : Common, MixEnvironment
|
|||
|
||||
setEnviron();
|
||||
// prevent garbage collection until shell exits
|
||||
setEnv("NIX_GCROOT", gcroot.c_str());
|
||||
setEnv("NIX_GCROOT", store->printStorePath(gcroot).c_str());
|
||||
|
||||
Path shell = "bash";
|
||||
bool foundInteractive = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue