Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
masked.hh
Go to the documentation of this file.
1#pragma once
3
5#include "nix/util/fun.hh"
6
7#include <boost/unordered/concurrent_flat_map_fwd.hpp>
8
9namespace nix {
10
11class Store;
12
13namespace derivation::masked {
14
25{
26 StorePathSet srcs;
27
33 using DrvMap = std::map<Hash, std::set<OutputName, std::less<>>>;
34
38 struct Drvs
39 {
40 DrvMap map;
41
42 bool operator==(const Drvs &) const = default;
43 } drvs;
44
45 /* Needed so that `Drv`, and thus `Derivation<HashInputs, Out>`, is
46 comparable: the tests compare masked derivations structurally
47 rather than comparing their hashes. */
48 bool operator==(const HashInputs &) const = default;
49};
50
84template<typename Out = Output::InputAddressed>
86
95{
102 using DrvHash = Hash;
103
108 using CaOutputHashes = std::map<std::string, Hash>;
109
116 using DeferredDrv = std::monostate;
117
118 using Raw = std::variant<DrvHash, CaOutputHashes, DeferredDrv>;
119
120 Raw raw;
121
122 bool operator==(const MaskedHash &) const = default;
123 // auto operator <=> (const MaskedHash &) const = default;
124
125 MAKE_WRAPPER_CONSTRUCTOR(MaskedHash);
126};
127
129{
130 using is_avalanching = std::true_type;
131
132 std::size_t operator()(const StorePath & path) const noexcept
133 {
134 return std::hash<std::string_view>{}(path.to_string());
135 }
136};
137
141typedef boost::concurrent_flat_map<StorePath, MaskedHash, HashFct> Hashes;
142
143// FIXME: global, though at least thread-safe.
144extern Hashes hashes;
145
176MaskedHash hashInput(const StoreDirConfig & store, ReadDerivation & readDerivation, const Full & drv);
177
178MaskedHash hashInput(Store & store, const Full & drv);
179
190template<typename Out>
191std::optional<Drv<Output::Deferred>> fullyMaskDerivation(
192 const StoreDirConfig & store,
193 ReadDerivation & readDerivation,
194 const Derivation<std::set<SingleDerivedPath>, Out> & drv);
195
196extern template std::optional<Drv<Output::Deferred>>
197fullyMaskDerivation(const StoreDirConfig & store, ReadDerivation & readDerivation, const Full & drv);
198extern template std::optional<Drv<Output::Deferred>>
199fullyMaskDerivation(const StoreDirConfig & store, ReadDerivation & readDerivation, const FullDeferred & drv);
200extern template std::optional<Drv<Output::Deferred>>
201fullyMaskDerivation(const StoreDirConfig & store, ReadDerivation & readDerivation, const FullInputAddressed & drv);
202
203template<typename Out>
204std::optional<Drv<Output::Deferred>>
205fullyMaskDerivation(Store & store, const Derivation<std::set<SingleDerivedPath>, Out> & drv)
206{
207 return fullyMaskDerivation(store, derivation::readInvalid(store), drv);
208}
209
214Drv<Output::Deferred> fullyMaskDerivation(const StoreDirConfig & store, const Basic & drv);
215
225template<typename Out>
226Hash hashDerivation(const StoreDirConfig & store, const Drv<Out> & drv);
227
228extern template Hash hashDerivation(const StoreDirConfig & store, const Drv<Output::Deferred> & drv);
229extern template Hash hashDerivation(const StoreDirConfig & store, const Drv<Output::InputAddressed> & drv);
230
231} // namespace derivation::masked
232
233} // namespace nix
Definition path.hh:33
Definition store-api.hh:397
boost::concurrent_flat_map< StorePath, MaskedHash, HashFct > Hashes
Definition masked.hh:141
Derivation< HashInputs, Out > Drv
Definition masked.hh:85
Derivation< std::set< SingleDerivedPath > > Full
Derivation that depends on the outputs of other derivations in addition.
Definition derivations.hh:168
Derivation< StorePathSet > Basic
Derivation that depends only on other store objects.
Definition derivations.hh:160
fun< Full(const StorePath &drvPath)> ReadDerivation
Definition derivations.hh:180
ReadDerivation readInvalid(Store &store)
Definition derivations.cc:560
Derivation< std::set< SingleDerivedPath >, Output::InputAddressed > FullInputAddressed
Full, but statically known to be input-addressed.
Definition derivations.hh:204
Derivation< std::set< SingleDerivedPath >, Output::Deferred > FullDeferred
Full, but statically known to have no output paths yet.
Definition derivations.hh:196
Definition hash.hh:58
Definition store-dir-config.hh:29
Definition derivations.hh:208
Definition masked.hh:129
std::map< Hash, std::set< OutputName, std::less<> > > DrvMap
Definition masked.hh:33
std::map< std::string, Hash > CaOutputHashes
Definition masked.hh:108
Hash DrvHash
Definition masked.hh:102
std::monostate DeferredDrv
Definition masked.hh:116