mirror of
https://github.com/NixOS/nix.git
synced 2025-12-12 03:51:04 +01:00
Use BuildableReq for buildPaths and ensurePath
This avoids an ambiguity where the `StorePathWithOutputs { drvPath, {}
}` could mean "build `brvPath`" or "substitute `drvPath`" depending on
context.
It also brings the internals closer in line to the new CLI, by
generalizing the `Buildable` type is used there and makes that
distinction already.
In doing so, relegate `StorePathWithOutputs` to being a type just for
backwards compatibility (CLI and RPC).
This commit is contained in:
parent
32f4454b9f
commit
255d145ba7
31 changed files with 364 additions and 126 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "util.hh"
|
||||
#include "path.hh"
|
||||
#include "path.hh"
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
|
@ -13,19 +14,37 @@ class Store;
|
|||
|
||||
struct BuildableOpaque {
|
||||
StorePath path;
|
||||
|
||||
nlohmann::json toJSON(ref<Store> store) const;
|
||||
std::string to_string(const Store & store) const;
|
||||
static BuildableOpaque parse(const Store & store, std::string_view);
|
||||
};
|
||||
|
||||
struct BuildableFromDrv {
|
||||
template<typename Outputs>
|
||||
struct BuildableForFromDrv {
|
||||
StorePath drvPath;
|
||||
std::map<std::string, std::optional<StorePath>> outputs;
|
||||
Outputs outputs;
|
||||
|
||||
nlohmann::json toJSON(ref<Store> store) const;
|
||||
std::string to_string(const Store & store) const;
|
||||
static BuildableForFromDrv<Outputs> parse(const Store & store, std::string_view);
|
||||
};
|
||||
|
||||
typedef std::variant<
|
||||
template <typename Outputs>
|
||||
using BuildableFor = std::variant<
|
||||
BuildableOpaque,
|
||||
BuildableFromDrv
|
||||
> Buildable;
|
||||
BuildableForFromDrv<Outputs>
|
||||
>;
|
||||
|
||||
typedef BuildableForFromDrv<std::set<std::string>> BuildableReqFromDrv;
|
||||
typedef BuildableFor<std::set<std::string>> BuildableReq;
|
||||
|
||||
std::string to_string(const Store & store, const BuildableReq &);
|
||||
|
||||
BuildableReq parseBuildableReq(const Store & store, std::string_view);
|
||||
|
||||
typedef BuildableForFromDrv<std::map<std::string, std::optional<StorePath>>> BuildableFromDrv;
|
||||
typedef BuildableFor<std::map<std::string, std::optional<StorePath>>> Buildable;
|
||||
|
||||
typedef std::vector<Buildable> Buildables;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue