diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-04-05 10:33:28 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-04-05 10:33:28 -0400 |
commit | d8fa7517fad4272e20ff9b9b740c91158bc685e2 (patch) | |
tree | 762177a895898255d12e74ce479e171ba902a98b /src/libstore/derived-path.hh | |
parent | 179582872de60863fcabcf471f98930a25fd6df3 (diff) |
buildable.{cc,hh} -> derived-path.{cc,hh}
Diffstat (limited to 'src/libstore/derived-path.hh')
-rw-r--r-- | src/libstore/derived-path.hh | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/libstore/derived-path.hh b/src/libstore/derived-path.hh new file mode 100644 index 000000000..ce5ae5fc0 --- /dev/null +++ b/src/libstore/derived-path.hh @@ -0,0 +1,81 @@ +#pragma once + +#include "util.hh" +#include "path.hh" +#include "path.hh" + +#include <optional> + +#include <nlohmann/json_fwd.hpp> + +namespace nix { + +class Store; + +struct DerivedPathOpaque { + StorePath path; + + nlohmann::json toJSON(ref<Store> store) const; + std::string to_string(const Store & store) const; + static DerivedPathOpaque parse(const Store & store, std::string_view); +}; + +struct DerivedPathBuilt { + StorePath drvPath; + std::set<std::string> outputs; + + std::string to_string(const Store & store) const; + static DerivedPathBuilt parse(const Store & store, std::string_view); +}; + +using _DerivedPathRaw = std::variant< + DerivedPathOpaque, + DerivedPathBuilt +>; + +struct DerivedPath : _DerivedPathRaw { + using Raw = _DerivedPathRaw; + using Raw::Raw; + + using Opaque = DerivedPathOpaque; + using Built = DerivedPathBuilt; + + inline const Raw & raw() const { + return static_cast<const Raw &>(*this); + } + + std::string to_string(const Store & store) const; + static DerivedPath parse(const Store & store, std::string_view); +}; + +struct DerivedPathWithHintsBuilt { + StorePath drvPath; + std::map<std::string, std::optional<StorePath>> outputs; + + nlohmann::json toJSON(ref<Store> store) const; + static DerivedPathWithHintsBuilt parse(const Store & store, std::string_view); +}; + +using _DerivedPathWithHintsRaw = std::variant< + DerivedPath::Opaque, + DerivedPathWithHintsBuilt +>; + +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); + } + +}; + +typedef std::vector<DerivedPathWithHints> DerivedPathsWithHints; + +nlohmann::json derivedPathsWithHintsToJSON(const DerivedPathsWithHints & buildables, ref<Store> store); + +} |