aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derivations.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r--src/libstore/derivations.cc56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index b9c913788..aa5980475 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -13,12 +13,12 @@ std::optional<StorePath> DerivationOutput::pathOpt(const Store & store, std::str
[](DerivationOutputInputAddressed doi) -> std::optional<StorePath> {
return { doi.path };
},
- [&](DerivationOutputFixed dof) -> std::optional<StorePath> {
+ [&](DerivationOutputCAFixed dof) -> std::optional<StorePath> {
return {
store.makeFixedOutputPath(dof.hash.method, dof.hash.hash, drvName)
};
},
- [](DerivationOutputFloating dof) -> std::optional<StorePath> {
+ [](DerivationOutputCAFloating dof) -> std::optional<StorePath> {
return std::nullopt;
},
}, output);
@@ -27,31 +27,31 @@ std::optional<StorePath> DerivationOutput::pathOpt(const Store & store, std::str
bool derivationIsCA(DerivationType dt) {
switch (dt) {
- case DerivationType::Regular: return false;
+ case DerivationType::InputAddressed: return false;
case DerivationType::CAFixed: return true;
case DerivationType::CAFloating: return true;
};
// Since enums can have non-variant values, but making a `default:` would
// disable exhaustiveness warnings.
- abort();
+ assert(false);
}
bool derivationIsFixed(DerivationType dt) {
switch (dt) {
- case DerivationType::Regular: return false;
+ case DerivationType::InputAddressed: return false;
case DerivationType::CAFixed: return true;
case DerivationType::CAFloating: return false;
};
- abort();
+ assert(false);
}
bool derivationIsImpure(DerivationType dt) {
switch (dt) {
- case DerivationType::Regular: return false;
+ case DerivationType::InputAddressed: return false;
case DerivationType::CAFixed: return true;
case DerivationType::CAFloating: return false;
};
- abort();
+ assert(false);
}
@@ -156,19 +156,20 @@ static DerivationOutput parseDerivationOutput(const Store & store, std::istrings
return hash != ""
? DerivationOutput {
- .output = DerivationOutputFixed {
+ .output = DerivationOutputCAFixed {
.hash = FixedOutputHash {
.method = std::move(method),
- .hash = Hash(hash, hashType),
+ .hash = Hash::parseNonSRIUnprefixed(hash, hashType),
},
}
}
- : DerivationOutput {
- .output = DerivationOutputFloating {
+ : (settings.requireExperimentalFeature("ca-derivations"),
+ DerivationOutput {
+ .output = DerivationOutputCAFloating {
.method = std::move(method),
.hashType = std::move(hashType),
},
- };
+ });
} else
return DerivationOutput {
.output = DerivationOutputInputAddressed {
@@ -321,11 +322,11 @@ string Derivation::unparse(const Store & store, bool maskOutputs,
s += ','; printUnquotedString(s, "");
s += ','; printUnquotedString(s, "");
},
- [&](DerivationOutputFixed dof) {
+ [&](DerivationOutputCAFixed dof) {
s += ','; printUnquotedString(s, dof.hash.printMethodAlgo());
s += ','; printUnquotedString(s, dof.hash.hash.to_string(Base16, false));
},
- [&](DerivationOutputFloating dof) {
+ [&](DerivationOutputCAFloating dof) {
s += ','; printUnquotedString(s, makeFileIngestionPrefix(dof.method) + printHashType(dof.hashType));
s += ','; printUnquotedString(s, "");
},
@@ -390,10 +391,10 @@ DerivationType BasicDerivation::type() const
[&](DerivationOutputInputAddressed _) {
inputAddressedOutputs.insert(i.first);
},
- [&](DerivationOutputFixed _) {
+ [&](DerivationOutputCAFixed _) {
fixedCAOutputs.insert(i.first);
},
- [&](DerivationOutputFloating dof) {
+ [&](DerivationOutputCAFloating dof) {
floatingCAOutputs.insert(i.first);
if (!floatingHashType) {
floatingHashType = dof.hashType;
@@ -408,7 +409,7 @@ DerivationType BasicDerivation::type() const
if (inputAddressedOutputs.empty() && fixedCAOutputs.empty() && floatingCAOutputs.empty()) {
throw Error("Must have at least one output");
} else if (! inputAddressedOutputs.empty() && fixedCAOutputs.empty() && floatingCAOutputs.empty()) {
- return DerivationType::Regular;
+ return DerivationType::InputAddressed;
} else if (inputAddressedOutputs.empty() && ! fixedCAOutputs.empty() && floatingCAOutputs.empty()) {
if (fixedCAOutputs.size() > 1)
// FIXME: Experimental feature?
@@ -474,7 +475,7 @@ DrvHashModulo hashDerivationModulo(Store & store, const Derivation & drv, bool m
case DerivationType::CAFixed: {
std::map<std::string, Hash> outputHashes;
for (const auto & i : drv.outputsAndPaths(store)) {
- auto & dof = std::get<DerivationOutputFixed>(i.second.first.output);
+ auto & dof = std::get<DerivationOutputCAFixed>(i.second.first.output);
auto hash = hashString(htSHA256, "fixed:out:"
+ dof.hash.printMethodAlgo() + ":"
+ dof.hash.hash.to_string(Base16, false) + ":"
@@ -483,7 +484,7 @@ DrvHashModulo hashDerivationModulo(Store & store, const Derivation & drv, bool m
}
return outputHashes;
}
- case DerivationType::Regular:
+ case DerivationType::InputAddressed:
break;
}
@@ -552,19 +553,20 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
auto hashType = parseHashType(hashAlgo);
return hash != ""
? DerivationOutput {
- .output = DerivationOutputFixed {
+ .output = DerivationOutputCAFixed {
.hash = FixedOutputHash {
.method = std::move(method),
- .hash = Hash(hash, hashType),
+ .hash = Hash::parseNonSRIUnprefixed(hash, hashType),
},
}
}
- : DerivationOutput {
- .output = DerivationOutputFloating {
+ : (settings.requireExperimentalFeature("ca-derivations"),
+ DerivationOutput {
+ .output = DerivationOutputCAFloating {
.method = std::move(method),
.hashType = std::move(hashType),
},
- };
+ });
} else
return DerivationOutput {
.output = DerivationOutputInputAddressed {
@@ -649,11 +651,11 @@ void writeDerivation(Sink & out, const Store & store, const BasicDerivation & dr
[&](DerivationOutputInputAddressed doi) {
out << "" << "";
},
- [&](DerivationOutputFixed dof) {
+ [&](DerivationOutputCAFixed dof) {
out << dof.hash.printMethodAlgo()
<< dof.hash.hash.to_string(Base16, false);
},
- [&](DerivationOutputFloating dof) {
+ [&](DerivationOutputCAFloating dof) {
out << (makeFileIngestionPrefix(dof.method) + printHashType(dof.hashType))
<< "";
},