aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-14 20:55:41 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-14 20:55:41 +0200
commit31a1a8ed3c3769eedbbe71fccbb9ae8a7cf448a1 (patch)
tree7e03e6e7581afb990008107ff6ea360f4e9077f2 /src/libexpr
parent5169a6da98d43f9d32bccd95d69e1138902d5595 (diff)
parent03cbb9ad5979a6af808b77e5783d2ee193bebbb4 (diff)
Merge pull request #815 from vcunat/p/outputsToInstall
nix-env: respect meta.outputsToInstall
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/get-drvs.cc24
-rw-r--r--src/libexpr/get-drvs.hh3
2 files changed, 22 insertions, 5 deletions
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 996c2c5f4..4889fe206 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -30,7 +30,7 @@ string DrvInfo::queryOutPath()
}
-DrvInfo::Outputs DrvInfo::queryOutputs()
+DrvInfo::Outputs DrvInfo::queryOutputs(bool onlyOutputsToInstall)
{
if (outputs.empty()) {
/* Get the ‘outputs’ list. */
@@ -55,7 +55,23 @@ DrvInfo::Outputs DrvInfo::queryOutputs()
} else
outputs["out"] = queryOutPath();
}
- return outputs;
+ if (!onlyOutputsToInstall || !attrs)
+ return outputs;
+
+ /* Check for `meta.outputsToInstall` and return `outputs` reduced to that. */
+ const Value * outTI = queryMeta("outputsToInstall");
+ if (!outTI) return outputs;
+ const auto errMsg = Error("this derivation has bad ‘meta.outputsToInstall’");
+ /* ^ this shows during `nix-env -i` right under the bad derivation */
+ if (!outTI->isList()) throw errMsg;
+ Outputs result;
+ for (auto i = outTI->listElems(); i != outTI->listElems() + outTI->listSize(); ++i) {
+ if ((*i)->type != tString) throw errMsg;
+ auto out = outputs.find((*i)->string.s);
+ if (out == outputs.end()) throw errMsg;
+ result.insert(*out);
+ }
+ return result;
}
@@ -192,8 +208,8 @@ typedef set<Bindings *> Done;
/* Evaluate value `v'. If it evaluates to a set of type `derivation',
- then put information about it in `drvs' (unless it's already in
- `doneExprs'). The result boolean indicates whether it makes sense
+ then put information about it in `drvs' (unless it's already in `done').
+ The result boolean indicates whether it makes sense
for the caller to recursively search for derivations in `v'. */
static bool getDerivation(EvalState & state, Value & v,
const string & attrPath, DrvInfos & drvs, Done & done,
diff --git a/src/libexpr/get-drvs.hh b/src/libexpr/get-drvs.hh
index 365c66c8d..37fcbe829 100644
--- a/src/libexpr/get-drvs.hh
+++ b/src/libexpr/get-drvs.hh
@@ -42,7 +42,8 @@ public:
string queryDrvPath();
string queryOutPath();
string queryOutputName();
- Outputs queryOutputs();
+ /** Return the list of outputs. The "outputs to install" are determined by `mesa.outputsToInstall`. */
+ Outputs queryOutputs(bool onlyOutputsToInstall = false);
StringSet queryMetaNames();
Value * queryMeta(const string & name);