aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derived-path-map.cc
blob: 5c8c7a4f212c17786311b5d36e44957c60179f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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>>;

}