aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/realisation.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-12-09 16:56:56 +0100
committerregnat <rg@regnat.ovh>2020-12-11 21:17:23 +0100
commitbab1cda0e6c30e25460b5a9c809589d3948f35df (patch)
tree4418501c6be637b4049d34c0a132db2a9a8ddeaf /src/libstore/realisation.cc
parent8914e01e37ad072d940e2000fede7c2e0f4b194c (diff)
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.
Diffstat (limited to 'src/libstore/realisation.cc')
-rw-r--r--src/libstore/realisation.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstore/realisation.cc b/src/libstore/realisation.cc
index 47db1ec9f..47ad90eee 100644
--- a/src/libstore/realisation.cc
+++ b/src/libstore/realisation.cc
@@ -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 {