Nix 2.36.0
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 "nix/store/path.hh"
7#include "nix/util/ref.hh"
9
10#include <variant>
11
12#include <nlohmann/json_fwd.hpp>
13
14namespace nix {
15
16struct StoreDirConfig;
17
26{
27 StorePath path;
28
29 std::string to_string(const StoreDirConfig & store) const;
30 static DerivedPathOpaque parse(const StoreDirConfig & store, std::string_view);
31
32 bool operator==(const DerivedPathOpaque &) const = default;
33 auto operator<=>(const DerivedPathOpaque &) const = default;
34};
35
37
46{
48 OutputName output;
49
60 const StorePath & getBaseStorePath() const;
61
66 bool isDynamicDrvOutput() const;
67
71 std::string to_string(const StoreDirConfig & store) const;
75 std::string to_string_legacy(const StoreDirConfig & store) const;
82 const StoreDirConfig & store,
84 OutputNameView outputs,
85 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
86
87 bool operator==(const SingleDerivedPathBuilt &) const noexcept;
88 std::strong_ordering operator<=>(const SingleDerivedPathBuilt &) const noexcept;
89};
90
91using _SingleDerivedPathRaw = std::variant<DerivedPathOpaque, SingleDerivedPathBuilt>;
92
104struct SingleDerivedPath : _SingleDerivedPathRaw
105{
106 using Raw = _SingleDerivedPathRaw;
107 using Raw::Raw;
108
109 using Opaque = DerivedPathOpaque;
110 using Built = SingleDerivedPathBuilt;
111
112 inline const Raw & raw() const
113 {
114 return static_cast<const Raw &>(*this);
115 }
116
117 bool operator==(const SingleDerivedPath &) const = default;
118 auto operator<=>(const SingleDerivedPath &) const = default;
119
130 const StorePath & getBaseStorePath() const;
131
137 bool isDynamicDrvOutput() const;
138
142 std::string to_string(const StoreDirConfig & store) const;
146 std::string to_string_legacy(const StoreDirConfig & store) const;
153 const StoreDirConfig & store,
154 std::string_view,
155 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
162 const StoreDirConfig & store,
163 std::string_view,
164 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
165};
166
167static inline ref<SingleDerivedPath> makeConstantStorePathRef(StorePath drvPath)
168{
169 return make_ref<SingleDerivedPath>(SingleDerivedPath::Opaque{drvPath});
170}
171
185{
187 OutputsSpec outputs;
188
199 const StorePath & getBaseStorePath() const;
200
204 std::string to_string(const StoreDirConfig & store) const;
208 std::string to_string_legacy(const StoreDirConfig & store) const;
214 static DerivedPathBuilt parse(
215 const StoreDirConfig & store,
217 std::string_view,
218 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
219
220 bool operator==(const DerivedPathBuilt &) const noexcept;
221 // TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
222 bool operator<(const DerivedPathBuilt &) const noexcept;
223};
224
225using _DerivedPathRaw = std::variant<DerivedPathOpaque, DerivedPathBuilt>;
226
237struct DerivedPath : _DerivedPathRaw
238{
239 using Raw = _DerivedPathRaw;
240 using Raw::Raw;
241
242 using Opaque = DerivedPathOpaque;
243 using Built = DerivedPathBuilt;
244
245 inline const Raw & raw() const
246 {
247 return static_cast<const Raw &>(*this);
248 }
249
260 const StorePath & getBaseStorePath() const;
261
265 std::string to_string(const StoreDirConfig & store) const;
269 std::string to_string_legacy(const StoreDirConfig & store) const;
275 static DerivedPath parse(
276 const StoreDirConfig & store,
277 std::string_view,
278 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
285 const StoreDirConfig & store,
286 std::string_view,
287 const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
288
293};
294
295typedef std::vector<DerivedPath> DerivedPaths;
296
306void drvRequireExperiment(
307 const SingleDerivedPath & drv, const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
308} // namespace nix
309
310JSON_IMPL(nix::SingleDerivedPath::Opaque)
311JSON_IMPL_WITH_XP_FEATURES(nix::SingleDerivedPath::Built)
312JSON_IMPL_WITH_XP_FEATURES(nix::SingleDerivedPath)
313JSON_IMPL_WITH_XP_FEATURES(nix::DerivedPath::Built)
314JSON_IMPL_WITH_XP_FEATURES(nix::DerivedPath)
Definition path.hh:33
Definition ref.hh:58
std::string_view OutputNameView
Definition outputs-spec.hh:24
std::string OutputName
Definition outputs-spec.hh:18
Definition derived-path.hh:185
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:39
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:34
static DerivedPathBuilt parse(const StoreDirConfig &store, ref< const SingleDerivedPath >, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:108
const StorePath & getBaseStorePath() const
Definition derived-path.cc:197
Definition derived-path.hh:26
Definition derived-path.hh:238
static DerivedPath parse(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:166
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:64
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:49
const StorePath & getBaseStorePath() const
Definition derived-path.cc:218
static DerivedPath fromSingle(const SingleDerivedPath &)
Definition derived-path.cc:177
static DerivedPath parseLegacy(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:171
Definition configuration.hh:558
Definition outputs-spec.hh:27
Definition derived-path.hh:46
const StorePath & getBaseStorePath() const
Definition derived-path.cc:192
bool isDynamicDrvOutput() const
Definition derived-path.cc:223
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:24
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:29
static SingleDerivedPathBuilt parse(const StoreDirConfig &store, ref< const SingleDerivedPath > drvPath, OutputNameView outputs, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:95
Definition derived-path.hh:105
static SingleDerivedPath parse(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:137
static SingleDerivedPath parseLegacy(const StoreDirConfig &store, std::string_view, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
Definition derived-path.cc:143
std::string to_string_legacy(const StoreDirConfig &store) const
Definition derived-path.cc:54
std::string to_string(const StoreDirConfig &store) const
Definition derived-path.cc:44
bool isDynamicDrvOutput() const
Definition derived-path.cc:228
const StorePath & getBaseStorePath() const
Definition derived-path.cc:213
Definition store-dir-config.hh:29