2021-03-01 05:48:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util.hh"
|
|
|
|
#include "path.hh"
|
2021-03-02 03:50:41 +00:00
|
|
|
#include "path.hh"
|
2021-03-01 05:48:01 +00:00
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class Store;
|
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
struct DerivedPathOpaque {
|
2021-03-01 05:48:01 +00:00
|
|
|
StorePath path;
|
2021-03-02 03:50:41 +00:00
|
|
|
|
2021-03-01 05:48:01 +00:00
|
|
|
nlohmann::json toJSON(ref<Store> store) const;
|
2021-03-02 03:50:41 +00:00
|
|
|
std::string to_string(const Store & store) const;
|
2021-04-05 13:48:18 +00:00
|
|
|
static DerivedPathOpaque parse(const Store & store, std::string_view);
|
2021-03-01 05:48:01 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
struct DerivedPathBuilt {
|
2021-03-01 05:48:01 +00:00
|
|
|
StorePath drvPath;
|
2021-04-05 13:15:25 +00:00
|
|
|
std::set<std::string> outputs;
|
2021-03-02 03:50:41 +00:00
|
|
|
|
|
|
|
std::string to_string(const Store & store) const;
|
2021-04-05 13:48:18 +00:00
|
|
|
static DerivedPathBuilt parse(const Store & store, std::string_view);
|
2021-03-01 05:48:01 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
using _DerivedPathRaw = std::variant<
|
|
|
|
DerivedPathOpaque,
|
|
|
|
DerivedPathBuilt
|
2021-03-02 03:50:41 +00:00
|
|
|
>;
|
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
struct DerivedPath : _DerivedPathRaw {
|
|
|
|
using Raw = _DerivedPathRaw;
|
2021-04-05 13:24:42 +00:00
|
|
|
using Raw::Raw;
|
2021-03-02 03:50:41 +00:00
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
using Opaque = DerivedPathOpaque;
|
|
|
|
using Built = DerivedPathBuilt;
|
|
|
|
|
2021-04-05 13:24:42 +00:00
|
|
|
inline const Raw & raw() const {
|
|
|
|
return static_cast<const Raw &>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string to_string(const Store & store) const;
|
2021-04-05 13:48:18 +00:00
|
|
|
static DerivedPath parse(const Store & store, std::string_view);
|
2021-04-05 13:24:42 +00:00
|
|
|
};
|
2021-03-02 03:50:41 +00:00
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
struct DerivedPathWithHintsBuilt {
|
2021-04-05 13:15:25 +00:00
|
|
|
StorePath drvPath;
|
|
|
|
std::map<std::string, std::optional<StorePath>> outputs;
|
|
|
|
|
|
|
|
nlohmann::json toJSON(ref<Store> store) const;
|
2021-04-05 13:48:18 +00:00
|
|
|
static DerivedPathWithHintsBuilt parse(const Store & store, std::string_view);
|
2021-04-05 13:15:25 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 14:05:21 +00:00
|
|
|
using _DerivedPathWithHintsRaw = std::variant<
|
2021-04-05 13:48:18 +00:00
|
|
|
DerivedPath::Opaque,
|
|
|
|
DerivedPathWithHintsBuilt
|
2021-04-05 13:15:25 +00:00
|
|
|
>;
|
2021-03-01 05:48:01 +00:00
|
|
|
|
2021-04-05 14:05:21 +00:00
|
|
|
struct DerivedPathWithHints : _DerivedPathWithHintsRaw {
|
|
|
|
using Raw = _DerivedPathWithHintsRaw;
|
|
|
|
using Raw::Raw;
|
|
|
|
|
|
|
|
using Opaque = DerivedPathOpaque;
|
|
|
|
using Built = DerivedPathWithHintsBuilt;
|
|
|
|
|
|
|
|
inline const Raw & raw() const {
|
|
|
|
return static_cast<const Raw &>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
typedef std::vector<DerivedPathWithHints> DerivedPathsWithHints;
|
2021-03-01 05:48:01 +00:00
|
|
|
|
2021-04-05 13:48:18 +00:00
|
|
|
nlohmann::json derivedPathsWithHintsToJSON(const DerivedPathsWithHints & buildables, ref<Store> store);
|
2021-03-01 05:48:01 +00:00
|
|
|
|
|
|
|
}
|