forked from lix-project/lix
bab1cda0e6
Rather than storing the derivation outputs as `drvPath!outputName` internally, store them as `drvHashModulo!outputName` (or `outputHash!outputName` for fixed-output derivations). This makes the storage slightly more opaque, but enables an earlier cutoff in cases where a fixed-output dependency changes (but keeps the same output hash) − same as what we already do for input-addressed derivations.
40 lines
956 B
C++
40 lines
956 B
C++
#pragma once
|
|
|
|
#include "path.hh"
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
namespace nix {
|
|
|
|
struct DrvOutput {
|
|
// The hash modulo of the derivation
|
|
Hash drvHash;
|
|
std::string outputName;
|
|
|
|
std::string to_string() const;
|
|
|
|
std::string strHash() const
|
|
{ return drvHash.to_string(Base16, true); }
|
|
|
|
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
|
|
std::pair<Hash, std::string> to_pair() const
|
|
{ return std::make_pair(drvHash, outputName); }
|
|
};
|
|
|
|
struct Realisation {
|
|
DrvOutput id;
|
|
StorePath outPath;
|
|
|
|
nlohmann::json toJSON() const;
|
|
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);
|
|
};
|
|
|
|
typedef std::map<DrvOutput, Realisation> DrvOutputs;
|
|
|
|
}
|