aboutsummaryrefslogtreecommitdiff
path: root/src/nix/build.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-23 19:02:57 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-23 19:02:57 +0000
commite1de1fe0d82d8ba702947dcad3b678cbb9ce9333 (patch)
tree45d4dd012208464ca7e311e276b50b5ccb39e33a /src/nix/build.cc
parenta7b8f799380da911908cf20d95c9cd644e25ab10 (diff)
Make `Buildable` a `std::variant`
I think this better captures the intent of what's going on: we either have an opaque store path, or a drv path with some outputs. Having this structure will also help us support CA derivations: we'll have to allow the outpath paths to be optional, so the structure we gain now makes up for the structure we loose then.
Diffstat (limited to 'src/nix/build.cc')
-rw-r--r--src/nix/build.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc
index 0f7e0e123..927301314 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -57,17 +57,24 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
if (dryRun) return;
- if (outLink != "") {
- for (size_t i = 0; i < buildables.size(); ++i) {
- for (auto & output : buildables[i].outputs)
- if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
- std::string symlink = outLink;
- if (i) symlink += fmt("-%d", i);
- if (output.first != "out") symlink += fmt("-%s", output.first);
- store2->addPermRoot(output.second, absPath(symlink), true);
- }
- }
- }
+ if (outLink != "")
+ if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
+ for (size_t i = 0; i < buildables.size(); ++i)
+ std::visit(overloaded {
+ [&](BuildableOpaque bo) {
+ std::string symlink = outLink;
+ if (i) symlink += fmt("-%d", i);
+ store2->addPermRoot(bo.path, absPath(symlink), true);
+ },
+ [&](BuildableFromDrv bfd) {
+ for (auto & output : bfd.outputs) {
+ std::string symlink = outLink;
+ if (i) symlink += fmt("-%d", i);
+ if (output.first != "out") symlink += fmt("-%s", output.first);
+ store2->addPermRoot(output.second, absPath(symlink), true);
+ }
+ },
+ }, buildables[i]);
updateProfile(buildables);
}