mirror of
https://github.com/NixOS/nix
synced 2025-06-29 10:31:15 +02:00
Fixing #7479
Types converted: - `NixStringContextElem` - `OutputsSpec` - `ExtendedOutputsSpec` - `DerivationOutput` - `DerivationType` Existing ones mostly conforming the pattern cleaned up: - `ContentAddressMethod` - `ContentAddressWithReferences` The `DerivationGoal::derivationType` field had a bogus initialization, now caught, so I made it `std::optional`. I think #8829 can make it non-optional again because it will ensure we always have the derivation when we construct a `DerivationGoal`. See that issue (#7479) for details on the general goal. `git grep 'Raw::Raw'` indicates the two types I didn't yet convert `DerivedPath` and `BuiltPath` (and their `Single` variants) . This is because @roberth and I (can't find issue right now...) plan on reworking them somewhat, so I didn't want to churn them more just yet. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
284c180732
commit
9121fed4b4
29 changed files with 355 additions and 334 deletions
|
@ -99,7 +99,7 @@ std::string NixStringContextElem::to_string() const
|
|||
res += '=';
|
||||
res += d.drvPath.to_string();
|
||||
},
|
||||
}, raw());
|
||||
}, raw);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
#include "util.hh"
|
||||
#include "comparator.hh"
|
||||
#include "derived-path.hh"
|
||||
|
||||
#include <variant>
|
||||
#include "variant-wrapper.hh"
|
||||
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
|
@ -26,58 +25,47 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Plain opaque path to some store object.
|
||||
*
|
||||
* Encoded as just the path: ‘<path>’.
|
||||
*/
|
||||
typedef SingleDerivedPath::Opaque NixStringContextElem_Opaque;
|
||||
struct NixStringContextElem {
|
||||
/**
|
||||
* Plain opaque path to some store object.
|
||||
*
|
||||
* Encoded as just the path: ‘<path>’.
|
||||
*/
|
||||
using Opaque = SingleDerivedPath::Opaque;
|
||||
|
||||
/**
|
||||
* Path to a derivation and its entire build closure.
|
||||
*
|
||||
* The path doesn't just refer to derivation itself and its closure, but
|
||||
* also all outputs of all derivations in that closure (including the
|
||||
* root derivation).
|
||||
*
|
||||
* Encoded in the form ‘=<drvPath>’.
|
||||
*/
|
||||
struct NixStringContextElem_DrvDeep {
|
||||
StorePath drvPath;
|
||||
/**
|
||||
* Path to a derivation and its entire build closure.
|
||||
*
|
||||
* The path doesn't just refer to derivation itself and its closure, but
|
||||
* also all outputs of all derivations in that closure (including the
|
||||
* root derivation).
|
||||
*
|
||||
* Encoded in the form ‘=<drvPath>’.
|
||||
*/
|
||||
struct DrvDeep {
|
||||
StorePath drvPath;
|
||||
|
||||
GENERATE_CMP(NixStringContextElem_DrvDeep, me->drvPath);
|
||||
};
|
||||
GENERATE_CMP(DrvDeep, me->drvPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Derivation output.
|
||||
*
|
||||
* Encoded in the form ‘!<output>!<drvPath>’.
|
||||
*/
|
||||
typedef SingleDerivedPath::Built NixStringContextElem_Built;
|
||||
/**
|
||||
* Derivation output.
|
||||
*
|
||||
* Encoded in the form ‘!<output>!<drvPath>’.
|
||||
*/
|
||||
using Built = SingleDerivedPath::Built;
|
||||
|
||||
using _NixStringContextElem_Raw = std::variant<
|
||||
NixStringContextElem_Opaque,
|
||||
NixStringContextElem_DrvDeep,
|
||||
NixStringContextElem_Built
|
||||
>;
|
||||
using Raw = std::variant<
|
||||
Opaque,
|
||||
DrvDeep,
|
||||
Built
|
||||
>;
|
||||
|
||||
struct NixStringContextElem : _NixStringContextElem_Raw {
|
||||
using Raw = _NixStringContextElem_Raw;
|
||||
using Raw::Raw;
|
||||
Raw raw;
|
||||
|
||||
using Opaque = NixStringContextElem_Opaque;
|
||||
using DrvDeep = NixStringContextElem_DrvDeep;
|
||||
using Built = NixStringContextElem_Built;
|
||||
GENERATE_CMP(NixStringContextElem, me->raw);
|
||||
|
||||
inline const Raw & raw() const & {
|
||||
return static_cast<const Raw &>(*this);
|
||||
}
|
||||
inline Raw & raw() & {
|
||||
return static_cast<Raw &>(*this);
|
||||
}
|
||||
inline Raw && raw() && {
|
||||
return static_cast<Raw &&>(*this);
|
||||
}
|
||||
MAKE_WRAPPER_CONSTRUCTOR(NixStringContextElem);
|
||||
|
||||
/**
|
||||
* Decode a context string, one of:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue