mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge pull request #6664 from Ma27/innixshell-backwards-compat
nix-shell: restore backwards-compat with old nixpkgs
This commit is contained in:
commit
d63cd77549
3 changed files with 43 additions and 5 deletions
|
@ -257,11 +257,12 @@ static void main_nix_build(int argc, char * * argv)
|
|||
|
||||
auto autoArgs = myArgs.getAutoArgs(*state);
|
||||
|
||||
auto autoArgsWithInNixShell = autoArgs;
|
||||
if (runEnv) {
|
||||
auto newArgs = state->buildBindings(autoArgs->size() + 1);
|
||||
auto newArgs = state->buildBindings(autoArgsWithInNixShell->size() + 1);
|
||||
newArgs.alloc("inNixShell").mkBool(true);
|
||||
for (auto & i : *autoArgs) newArgs.insert(i);
|
||||
autoArgs = newArgs.finish();
|
||||
autoArgsWithInNixShell = newArgs.finish();
|
||||
}
|
||||
|
||||
if (packages) {
|
||||
|
@ -316,10 +317,39 @@ static void main_nix_build(int argc, char * * argv)
|
|||
Value vRoot;
|
||||
state->eval(e, vRoot);
|
||||
|
||||
std::function<bool(const Value & v)> takesNixShellAttr;
|
||||
takesNixShellAttr = [&](const Value & v) {
|
||||
if (!runEnv) {
|
||||
return false;
|
||||
}
|
||||
bool add = false;
|
||||
if (v.type() == nFunction && v.lambda.fun->hasFormals()) {
|
||||
for (auto & i : v.lambda.fun->formals->formals) {
|
||||
if (state->symbols[i.name] == "inNixShell") {
|
||||
add = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return add;
|
||||
};
|
||||
|
||||
for (auto & i : attrPaths) {
|
||||
Value & v(*findAlongAttrPath(*state, i, *autoArgs, vRoot).first);
|
||||
Value & v(*findAlongAttrPath(
|
||||
*state,
|
||||
i,
|
||||
takesNixShellAttr(vRoot) ? *autoArgsWithInNixShell : *autoArgs,
|
||||
vRoot
|
||||
).first);
|
||||
state->forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
getDerivations(*state, v, "", *autoArgs, drvs, false);
|
||||
getDerivations(
|
||||
*state,
|
||||
v,
|
||||
"",
|
||||
takesNixShellAttr(v) ? *autoArgsWithInNixShell : *autoArgs,
|
||||
drvs,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue