aboutsummaryrefslogtreecommitdiff
path: root/src/nix/command.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-07 17:46:39 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-07 17:46:39 +0000
commitf7ba16f9cbc27b141f1797a7c4f1fd3243f31683 (patch)
treef4311bcd8bd9fe14abbd29233503d101d067aa23 /src/nix/command.cc
parent47644e49ca252441fcc3ae57f5a01e7fc579ba8c (diff)
parent3c75ddc16b054a7dabf0710ee0a4323b4371effd (diff)
Merge remote-tracking branch 'upstream/master' into drv-outputs-map-allow-missing
Diffstat (limited to 'src/nix/command.cc')
-rw-r--r--src/nix/command.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/nix/command.cc b/src/nix/command.cc
index af36dda89..da32819da 100644
--- a/src/nix/command.cc
+++ b/src/nix/command.cc
@@ -128,20 +128,25 @@ void MixProfile::updateProfile(const Buildables & buildables)
{
if (!profile) return;
- std::optional<StorePath> result;
+ std::vector<StorePath> result;
for (auto & buildable : buildables) {
- for (auto & output : buildable.outputs) {
- if (result)
- throw Error("'--profile' requires that the arguments produce a single store path, but there are multiple");
- result = output.second;
- }
+ std::visit(overloaded {
+ [&](BuildableOpaque bo) {
+ result.push_back(bo.path);
+ },
+ [&](BuildableFromDrv bfd) {
+ for (auto & output : bfd.outputs) {
+ result.push_back(output.second);
+ }
+ },
+ }, buildable);
}
- if (!result)
- throw Error("'--profile' requires that the arguments produce a single store path, but there are none");
+ if (result.size() != 1)
+ throw Error("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
- updateProfile(*result);
+ updateProfile(result[0]);
}
MixDefaultProfile::MixDefaultProfile()