aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derived-path-map.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/derived-path-map.cc')
-rw-r--r--src/libstore/derived-path-map.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libstore/derived-path-map.cc b/src/libstore/derived-path-map.cc
new file mode 100644
index 000000000..5c8c7a4f2
--- /dev/null
+++ b/src/libstore/derived-path-map.cc
@@ -0,0 +1,33 @@
+#include "derived-path-map.hh"
+
+namespace nix {
+
+template<typename V>
+typename DerivedPathMap<V>::ChildNode & DerivedPathMap<V>::ensureSlot(const SingleDerivedPath & k)
+{
+ std::function<ChildNode &(const SingleDerivedPath & )> initIter;
+ initIter = [&](const auto & k) -> auto & {
+ return std::visit(overloaded {
+ [&](const SingleDerivedPath::Opaque & bo) -> auto & {
+ // will not overwrite if already there
+ return map[bo.path];
+ },
+ [&](const SingleDerivedPath::Built & bfd) -> auto & {
+ auto & n = initIter(*bfd.drvPath);
+ return n.childMap[bfd.output];
+ },
+ }, k.raw());
+ };
+ return initIter(k);
+}
+
+}
+
+// instantiations
+
+#include "create-derivation-and-realise-goal.hh"
+namespace nix {
+
+template struct DerivedPathMap<std::weak_ptr<CreateDerivationAndRealiseGoal>>;
+
+}