mirror of
https://github.com/NixOS/nix
synced 2025-07-02 05:11:47 +02:00
Add inNixShell = true to nix-shell auto-call
This is an alternative to the IN_NIX_SHELL environment variable, allowing the expression to adapt itself to nix-shell without triggering those adaptations when used as a dependency of another shell. Closes #3147
This commit is contained in:
parent
2f96a89646
commit
9d612c393a
3 changed files with 21 additions and 6 deletions
|
@ -245,7 +245,21 @@ static void _main(int argc, char * * argv)
|
|||
auto state = std::make_unique<EvalState>(myArgs.searchPath, store);
|
||||
state->repair = repair;
|
||||
|
||||
Bindings & autoArgs = *myArgs.getAutoArgs(*state);
|
||||
Bindings & autoArgs = *[&](){
|
||||
Bindings *userAutoArgs = myArgs.getAutoArgs(*state);
|
||||
if (runEnv) {
|
||||
Bindings * res = state->allocBindings(userAutoArgs->size() + 1);
|
||||
Value * tru = state->allocValue();
|
||||
mkBool(*tru, true);
|
||||
res->push_back(Attr(state->symbols.create("inNixShell"), tru));
|
||||
for (auto & i : *userAutoArgs) {
|
||||
res->push_back(i);
|
||||
}
|
||||
res->sort();
|
||||
return res;
|
||||
}
|
||||
else return userAutoArgs;
|
||||
}();
|
||||
|
||||
if (packages) {
|
||||
std::ostringstream joined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue