aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/get-drvs.hh
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-03-12 13:47:01 +0100
committerNaïm Favier <n@monade.li>2022-03-16 21:26:19 +0100
commit57366619229c62ed182514d9ad71ef3aea93d5d6 (patch)
treedb7d5cf2eed02ebb3f97b0c24139670472673b52 /src/libexpr/get-drvs.hh
parentd5322698a2abbc6d141e1d244e17b0d226a2f18b (diff)
nix-env: always print output names in JSON and XML
The current `--out-path` flag has two disadvantages when one is only concerned with querying the names of outputs: - it requires evaluating every output's `outPath`, which takes significantly more resources and runs into more failures - it destroys the information of the order of outputs so we can't tell which one is the main output This patch makes the output names always present (replacing paths with `null` in JSON if `--out-path` isn't given), and adds an `outputName` field.
Diffstat (limited to 'src/libexpr/get-drvs.hh')
-rw-r--r--src/libexpr/get-drvs.hh7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libexpr/get-drvs.hh b/src/libexpr/get-drvs.hh
index 3ca6f1fca..7cc1abef2 100644
--- a/src/libexpr/get-drvs.hh
+++ b/src/libexpr/get-drvs.hh
@@ -13,7 +13,7 @@ namespace nix {
struct DrvInfo
{
public:
- typedef std::map<std::string, StorePath> Outputs;
+ typedef std::map<std::string, std::optional<StorePath>> Outputs;
private:
EvalState * state;
@@ -46,8 +46,9 @@ public:
StorePath requireDrvPath() const;
StorePath queryOutPath() const;
std::string queryOutputName() const;
- /** Return the list of outputs. The "outputs to install" are determined by `meta.outputsToInstall`. */
- Outputs queryOutputs(bool onlyOutputsToInstall = false);
+ /** Return the unordered map of output names to (optional) output paths.
+ * The "outputs to install" are determined by `meta.outputsToInstall`. */
+ Outputs queryOutputs(bool withPaths = true, bool onlyOutputsToInstall = false);
StringSet queryMetaNames();
Value * queryMeta(const std::string & name);