2020-10-08 15:36:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "path.hh"
|
2020-12-08 20:07:52 +00:00
|
|
|
#include <nlohmann/json_fwd.hpp>
|
2020-10-08 15:36:51 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
struct DrvOutput {
|
2020-12-09 15:56:56 +00:00
|
|
|
// The hash modulo of the derivation
|
|
|
|
Hash drvHash;
|
2020-10-08 15:36:51 +00:00
|
|
|
std::string outputName;
|
|
|
|
|
|
|
|
std::string to_string() const;
|
|
|
|
|
2020-12-09 15:56:56 +00:00
|
|
|
std::string strHash() const
|
|
|
|
{ return drvHash.to_string(Base16, true); }
|
|
|
|
|
2020-10-08 15:36:51 +00:00
|
|
|
static DrvOutput parse(const std::string &);
|
|
|
|
|
|
|
|
bool operator<(const DrvOutput& other) const { return to_pair() < other.to_pair(); }
|
|
|
|
bool operator==(const DrvOutput& other) const { return to_pair() == other.to_pair(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Just to make comparison operators easier to write
|
2020-12-09 15:56:56 +00:00
|
|
|
std::pair<Hash, std::string> to_pair() const
|
|
|
|
{ return std::make_pair(drvHash, outputName); }
|
2020-10-08 15:36:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Realisation {
|
|
|
|
DrvOutput id;
|
|
|
|
StorePath outPath;
|
|
|
|
|
2020-12-08 20:07:52 +00:00
|
|
|
nlohmann::json toJSON() const;
|
|
|
|
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);
|
2020-10-08 15:36:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<DrvOutput, Realisation> DrvOutputs;
|
|
|
|
|
|
|
|
}
|