mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 14:02:42 +01:00
Use the hash modulo in the derivation outputs
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.
This commit is contained in:
parent
8914e01e37
commit
bab1cda0e6
7 changed files with 93 additions and 89 deletions
|
|
@ -7,18 +7,18 @@ namespace nix {
|
|||
MakeError(InvalidDerivationOutputId, Error);
|
||||
|
||||
DrvOutput DrvOutput::parse(const std::string &strRep) {
|
||||
const auto &[rawPath, outputs] = parsePathWithOutputs(strRep);
|
||||
if (outputs.size() != 1)
|
||||
size_t n = strRep.find("!");
|
||||
if (n == strRep.npos)
|
||||
throw InvalidDerivationOutputId("Invalid derivation output id %s", strRep);
|
||||
|
||||
return DrvOutput{
|
||||
.drvPath = StorePath(rawPath),
|
||||
.outputName = *outputs.begin(),
|
||||
.drvHash = Hash::parseAnyPrefixed(strRep.substr(0, n)),
|
||||
.outputName = strRep.substr(n+1),
|
||||
};
|
||||
}
|
||||
|
||||
std::string DrvOutput::to_string() const {
|
||||
return std::string(drvPath.to_string()) + "!" + outputName;
|
||||
return strHash() + "!" + outputName;
|
||||
}
|
||||
|
||||
nlohmann::json Realisation::toJSON() const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue