aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/buildable.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/buildable.hh')
-rw-r--r--src/libstore/buildable.hh65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/libstore/buildable.hh b/src/libstore/buildable.hh
new file mode 100644
index 000000000..a1784a4c6
--- /dev/null
+++ b/src/libstore/buildable.hh
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "util.hh"
+#include "path.hh"
+
+#include <optional>
+#include <variant>
+
+#include <nlohmann/json_fwd.hpp>
+
+namespace nix {
+
+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 BuildableReqFromDrv {
+ StorePath drvPath;
+ std::set<std::string> outputs;
+
+ std::string to_string(const Store & store) const;
+ static BuildableReqFromDrv parse(const Store & store, std::string_view);
+};
+
+using _BuildableReqRaw = std::variant<
+ BuildableOpaque,
+ BuildableReqFromDrv
+>;
+
+struct BuildableReq : _BuildableReqRaw {
+ using Raw = _BuildableReqRaw;
+ using Raw::Raw;
+
+ inline const Raw & raw() const {
+ return static_cast<const Raw &>(*this);
+ }
+
+ std::string to_string(const Store & store) const;
+ static BuildableReq parse(const Store & store, std::string_view);
+};
+
+struct BuildableFromDrv {
+ StorePath drvPath;
+ std::map<std::string, std::optional<StorePath>> outputs;
+
+ nlohmann::json toJSON(ref<Store> store) const;
+ static BuildableFromDrv parse(const Store & store, std::string_view);
+};
+
+using Buildable = std::variant<
+ BuildableOpaque,
+ BuildableFromDrv
+>;
+
+typedef std::vector<Buildable> Buildables;
+
+nlohmann::json buildablesToJSON(const Buildables & buildables, ref<Store> store);
+
+}