mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 22:46:16 +02:00
nix dev-shell: Add --profile flag
This is useful to prevent the shell environment from being garbage-collected.
This commit is contained in:
parent
990b5b2dcf
commit
7ba928116e
1 changed files with 15 additions and 5 deletions
|
@ -66,7 +66,7 @@ BuildEnvironment readEnvironment(const Path & path)
|
||||||
modified derivation with the same dependencies and nearly the same
|
modified derivation with the same dependencies and nearly the same
|
||||||
initial environment variables, that just writes the resulting
|
initial environment variables, that just writes the resulting
|
||||||
environment to a file and exits. */
|
environment to a file and exits. */
|
||||||
BuildEnvironment getDerivationEnvironment(ref<Store> store, Derivation drv)
|
Path getDerivationEnvironment(ref<Store> store, Derivation drv)
|
||||||
{
|
{
|
||||||
auto builder = baseNameOf(drv.builder);
|
auto builder = baseNameOf(drv.builder);
|
||||||
if (builder != "bash")
|
if (builder != "bash")
|
||||||
|
@ -101,7 +101,7 @@ BuildEnvironment getDerivationEnvironment(ref<Store> store, Derivation drv)
|
||||||
|
|
||||||
assert(store->isValidPath(shellOutPath));
|
assert(store->isValidPath(shellOutPath));
|
||||||
|
|
||||||
return readEnvironment(shellOutPath);
|
return shellOutPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Common : InstallableCommand
|
struct Common : InstallableCommand
|
||||||
|
@ -175,7 +175,7 @@ struct Common : InstallableCommand
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmdDevShell : Common
|
struct CmdDevShell : Common, MixProfile
|
||||||
{
|
{
|
||||||
std::string description() override
|
std::string description() override
|
||||||
{
|
{
|
||||||
|
@ -193,6 +193,10 @@ struct CmdDevShell : Common
|
||||||
"To get the build environment of the default package of flake in the current directory:",
|
"To get the build environment of the default package of flake in the current directory:",
|
||||||
"nix dev-shell"
|
"nix dev-shell"
|
||||||
},
|
},
|
||||||
|
Example{
|
||||||
|
"To store the build environment in a profile:",
|
||||||
|
"nix dev-shell --profile /tmp/my-shell"
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +210,11 @@ struct CmdDevShell : Common
|
||||||
|
|
||||||
auto & drvPath = *drvs.begin();
|
auto & drvPath = *drvs.begin();
|
||||||
|
|
||||||
auto buildEnvironment = getDerivationEnvironment(store, store->derivationFromPath(drvPath));
|
auto shellOutPath = getDerivationEnvironment(store, store->derivationFromPath(drvPath));
|
||||||
|
|
||||||
|
updateProfile(shellOutPath);
|
||||||
|
|
||||||
|
auto buildEnvironment = readEnvironment(shellOutPath);
|
||||||
|
|
||||||
auto [rcFileFd, rcFilePath] = createTempFile("nix-shell");
|
auto [rcFileFd, rcFilePath] = createTempFile("nix-shell");
|
||||||
|
|
||||||
|
@ -259,7 +267,9 @@ struct CmdPrintDevEnv : Common
|
||||||
|
|
||||||
auto & drvPath = *drvs.begin();
|
auto & drvPath = *drvs.begin();
|
||||||
|
|
||||||
auto buildEnvironment = getDerivationEnvironment(store, store->derivationFromPath(drvPath));
|
auto buildEnvironment = readEnvironment(
|
||||||
|
getDerivationEnvironment(store,
|
||||||
|
store->derivationFromPath(drvPath)));
|
||||||
|
|
||||||
stopProgressBar();
|
stopProgressBar();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue