mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
Respect the outputSpecified attribute
E.g. 'nix build nixpkgs#libxml2.dev' will build the 'dev' output.
This commit is contained in:
parent
ec07a70979
commit
8e8e9d8705
5 changed files with 36 additions and 17 deletions
|
@ -22,9 +22,6 @@
|
||||||
`meta.outputsToInstall` attribute if it exists, or all outputs
|
`meta.outputsToInstall` attribute if it exists, or all outputs
|
||||||
otherwise.
|
otherwise.
|
||||||
|
|
||||||
Selecting derivation outputs using the attribute selection syntax
|
|
||||||
(e.g. `nixpkgs#glibc.dev`) no longer works.
|
|
||||||
|
|
||||||
* Running nix with the new `--debugger` flag will cause it to start a repl session if
|
* Running nix with the new `--debugger` flag will cause it to start a repl session if
|
||||||
there is an exception thrown during eval, or if `builtins.break` is called. From
|
there is an exception thrown during eval, or if `builtins.break` is called. From
|
||||||
there one can inspect symbol values and evaluate nix expressions. In debug mode
|
there one can inspect symbol values and evaluate nix expressions. In debug mode
|
||||||
|
|
|
@ -623,7 +623,14 @@ std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableF
|
||||||
std::set<std::string> outputsToInstall;
|
std::set<std::string> outputsToInstall;
|
||||||
std::optional<NixInt> priority;
|
std::optional<NixInt> priority;
|
||||||
|
|
||||||
if (auto aMeta = attr->maybeGetAttr(state->sMeta)) {
|
if (auto aOutputSpecified = attr->maybeGetAttr(state->sOutputSpecified)) {
|
||||||
|
if (aOutputSpecified->getBool()) {
|
||||||
|
if (auto aOutputName = attr->maybeGetAttr("outputName"))
|
||||||
|
outputsToInstall = { aOutputName->getString() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (auto aMeta = attr->maybeGetAttr(state->sMeta)) {
|
||||||
if (auto aOutputsToInstall = aMeta->maybeGetAttr("outputsToInstall"))
|
if (auto aOutputsToInstall = aMeta->maybeGetAttr("outputsToInstall"))
|
||||||
for (auto & s : aOutputsToInstall->getListOfStrings())
|
for (auto & s : aOutputsToInstall->getListOfStrings())
|
||||||
outputsToInstall.insert(s);
|
outputsToInstall.insert(s);
|
||||||
|
|
|
@ -459,6 +459,7 @@ EvalState::EvalState(
|
||||||
, sKey(symbols.create("key"))
|
, sKey(symbols.create("key"))
|
||||||
, sPath(symbols.create("path"))
|
, sPath(symbols.create("path"))
|
||||||
, sPrefix(symbols.create("prefix"))
|
, sPrefix(symbols.create("prefix"))
|
||||||
|
, sOutputSpecified(symbols.create("outputSpecified"))
|
||||||
, repair(NoRepair)
|
, repair(NoRepair)
|
||||||
, emptyBindings(0)
|
, emptyBindings(0)
|
||||||
, store(store)
|
, store(store)
|
||||||
|
|
|
@ -103,7 +103,8 @@ public:
|
||||||
sOutputHash, sOutputHashAlgo, sOutputHashMode,
|
sOutputHash, sOutputHashAlgo, sOutputHashMode,
|
||||||
sRecurseForDerivations,
|
sRecurseForDerivations,
|
||||||
sDescription, sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath,
|
sDescription, sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath,
|
||||||
sPrefix;
|
sPrefix,
|
||||||
|
sOutputSpecified;
|
||||||
Symbol sDerivationNix;
|
Symbol sDerivationNix;
|
||||||
|
|
||||||
/* If set, force copying files to the Nix store even if they
|
/* If set, force copying files to the Nix store even if they
|
||||||
|
|
|
@ -132,9 +132,21 @@ DrvInfo::Outputs DrvInfo::queryOutputs(bool withPaths, bool onlyOutputsToInstall
|
||||||
} else
|
} else
|
||||||
outputs.emplace("out", withPaths ? std::optional{queryOutPath()} : std::nullopt);
|
outputs.emplace("out", withPaths ? std::optional{queryOutPath()} : std::nullopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!onlyOutputsToInstall || !attrs)
|
if (!onlyOutputsToInstall || !attrs)
|
||||||
return outputs;
|
return outputs;
|
||||||
|
|
||||||
|
Bindings::iterator i;
|
||||||
|
if (attrs && (i = attrs->find(state->sOutputSpecified)) != attrs->end() && state->forceBool(*i->value, i->pos)) {
|
||||||
|
Outputs result;
|
||||||
|
auto out = outputs.find(queryOutputName());
|
||||||
|
if (out == outputs.end())
|
||||||
|
throw Error("derivation does not have output '%s'", queryOutputName());
|
||||||
|
result.insert(*out);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
/* Check for `meta.outputsToInstall` and return `outputs` reduced to that. */
|
/* Check for `meta.outputsToInstall` and return `outputs` reduced to that. */
|
||||||
const Value * outTI = queryMeta("outputsToInstall");
|
const Value * outTI = queryMeta("outputsToInstall");
|
||||||
if (!outTI) return outputs;
|
if (!outTI) return outputs;
|
||||||
|
@ -149,6 +161,7 @@ DrvInfo::Outputs DrvInfo::queryOutputs(bool withPaths, bool onlyOutputsToInstall
|
||||||
result.insert(*out);
|
result.insert(*out);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue