Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
derived-path.hh
Go to the documentation of this file.
1#pragma once
3
4#include "path.hh"
5#include "outputs-spec.hh"
6#include "config.hh"
7#include "ref.hh"
8
9#include <variant>
10
11#include <nlohmann/json_fwd.hpp>
12
13namespace nix {
14
15struct StoreDirConfig;
16
17// TODO stop needing this, `toJSON` below should be pure
18class Store;
19
28 StorePath path;
29
30 std::string to_string(const StoreDirConfig & store) const;
31 static DerivedPathOpaque parse(const StoreDirConfig & store, std::string_view);
32 nlohmann::json toJSON(const StoreDirConfig & store) const;
33
34 bool operator == (const DerivedPathOpaque &) const = default;
35 auto operator <=> (const DerivedPathOpaque &) const = default;
36};
37
39
49 OutputName output;
50
61 const StorePath & getBaseStorePath() const;
62
66 std::string to_string(const StoreDirConfig & store) const;
70 std::string to_string_legacy(const StoreDirConfig & store) const;
78 OutputNameView outputs,
79 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
80 nlohmann::json toJSON(Store & store) const;
81
82 bool operator == (const SingleDerivedPathBuilt &) const noexcept;
83 std::strong_ordering operator <=> (const SingleDerivedPathBuilt &) const noexcept;
84};
85
86using _SingleDerivedPathRaw = std::variant<
89>;
90
102struct SingleDerivedPath : _SingleDerivedPathRaw {
103 using Raw = _SingleDerivedPathRaw;
104 using Raw::Raw;
105
106 using Opaque = DerivedPathOpaque;
107 using Built = SingleDerivedPathBuilt;
108
109 inline const Raw & raw() const {
110 return static_cast<const Raw &>(*this);
111 }
112
113 bool operator == (const SingleDerivedPath &) const = default;
114 auto operator <=> (const SingleDerivedPath &) const = default;
115
126 const StorePath & getBaseStorePath() const;
127
131 std::string to_string(const StoreDirConfig & store) const;
135 std::string to_string_legacy(const StoreDirConfig & store) const;
142 const StoreDirConfig & store,
143 std::string_view,
144 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
151 const StoreDirConfig & store,
152 std::string_view,
153 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
154 nlohmann::json toJSON(Store & store) const;
155};
156
157static inline ref<SingleDerivedPath> makeConstantStorePathRef(StorePath drvPath)
158{
159 return make_ref<SingleDerivedPath>(SingleDerivedPath::Opaque { drvPath });
160}
161
176 OutputsSpec outputs;
177
188 const StorePath & getBaseStorePath() const;
189
193 std::string to_string(const StoreDirConfig & store) const;
197 std::string to_string_legacy(const StoreDirConfig & store) const;
203 static DerivedPathBuilt parse(
205 std::string_view,
206 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
207 nlohmann::json toJSON(Store & store) const;
208
209 bool operator == (const DerivedPathBuilt &) const noexcept;
210 // TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
211 bool operator < (const DerivedPathBuilt &) const noexcept;
212};
213
214using _DerivedPathRaw = std::variant<
217>;
218
229struct DerivedPath : _DerivedPathRaw {
230 using Raw = _DerivedPathRaw;
231 using Raw::Raw;
232
233 using Opaque = DerivedPathOpaque;
234 using Built = DerivedPathBuilt;
235
236 inline const Raw & raw() const {
237 return static_cast<const Raw &>(*this);
238 }
239
240 bool operator == (const DerivedPath &) const = default;
241 // TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
242 //auto operator <=> (const DerivedPath &) const = default;
243
254 const StorePath & getBaseStorePath() const;
255
259 std::string to_string(const StoreDirConfig & store) const;
263 std::string to_string_legacy(const StoreDirConfig & store) const;
269 static DerivedPath parse(
270 const StoreDirConfig & store,
271 std::string_view,
272 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
279 const StoreDirConfig & store,
280 std::string_view,
281 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
282
287
288 nlohmann::json toJSON(Store & store) const;
289};
290
291typedef std::vector<DerivedPath> DerivedPaths;
292
302void drvRequireExperiment(
303 const SingleDerivedPath & drv,
304 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
305}
Definition path.hh:27
Definition store-api.hh:169
Definition ref.hh:15
ChunkedVector< std::string, 8192 > store
Definition lexer.l:1011
virtual nlohmann::json toJSON()=0
std::string_view OutputNameView
Definition outputs-spec.hh:24
std::string OutputName
Definition outputs-spec.hh:18
Definition derived-path.hh:174
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:115
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:108
static DerivedPathBuilt parse(const StoreDirConfig &store, ref< SingleDerivedPath >, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:184
const StorePath & getBaseStorePath() const
Definition derived-path.cc:282
Definition derived-path.hh:27
Definition derived-path.hh:229
static DerivedPath parse(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:246
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:144
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:129
const StorePath & getBaseStorePath() const
Definition derived-path.cc:305
static DerivedPath fromSingle(const SingleDerivedPath &)
Definition derived-path.cc:262
static DerivedPath parseLegacy(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:254
Definition config.hh:382
Definition outputs-spec.hh:26
Definition derived-path.hh:47
const StorePath & getBaseStorePath() const
Definition derived-path.cc:277
static SingleDerivedPathBuilt parse(const StoreDirConfig &store, ref< SingleDerivedPath > drvPath, OutputNameView outputs, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:172
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:98
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:103
Definition derived-path.hh:102
static SingleDerivedPath parse(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:213
static SingleDerivedPath parseLegacy(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:221
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:136
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:122
const StorePath & getBaseStorePath() const
Definition derived-path.cc:300
Definition store-dir-config.hh:22