aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-05 14:44:39 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-05 14:44:39 +0000
commite7b0847f2d9674bc18532c86b2daf421347513e4 (patch)
tree5a72231f31e926c8575f4f592f65859cc79f168c /src/libstore
parent839f0fe0956cf4434b64e81a0966e780051901ad (diff)
Make names more consistent
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc10
-rw-r--r--src/libstore/derivations.cc36
-rw-r--r--src/libstore/derivations.hh14
-rw-r--r--src/libstore/local-store.cc4
-rw-r--r--src/libstore/misc.cc2
5 files changed, 36 insertions, 30 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 0176e7f65..6c9f55a53 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -3722,18 +3722,18 @@ void DerivationGoal::registerOutputs()
std::optional<ContentAddress> ca;
if (! std::holds_alternative<DerivationOutputInputAddressed>(i.second.output)) {
- DerivationOutputFloating outputHash;
+ DerivationOutputCAFloating outputHash;
std::visit(overloaded {
[&](DerivationOutputInputAddressed doi) {
assert(false); // Enclosing `if` handles this case in other branch
},
- [&](DerivationOutputFixed dof) {
- outputHash = DerivationOutputFloating {
+ [&](DerivationOutputCAFixed dof) {
+ outputHash = DerivationOutputCAFloating {
.method = dof.hash.method,
.hashType = dof.hash.hash.type,
};
},
- [&](DerivationOutputFloating dof) {
+ [&](DerivationOutputCAFloating dof) {
outputHash = dof;
},
}, i.second.output);
@@ -3758,7 +3758,7 @@ void DerivationGoal::registerOutputs()
// true if either floating CA, or incorrect fixed hash.
bool needsMove = true;
- if (auto p = std::get_if<DerivationOutputFixed>(& i.second.output)) {
+ if (auto p = std::get_if<DerivationOutputCAFixed>(& i.second.output)) {
Hash & h = p->hash.hash;
if (h != h2) {
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 8f2339885..b17d0cf79 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,7 +27,7 @@ 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;
};
@@ -38,7 +38,7 @@ bool derivationIsCA(DerivationType dt) {
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;
};
@@ -47,7 +47,7 @@ bool derivationIsFixed(DerivationType dt) {
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;
};
@@ -156,7 +156,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, std::istrings
return hash != ""
? DerivationOutput {
- .output = DerivationOutputFixed {
+ .output = DerivationOutputCAFixed {
.hash = FixedOutputHash {
.method = std::move(method),
.hash = Hash::parseNonSRIUnprefixed(hash, hashType),
@@ -164,7 +164,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, std::istrings
}
}
: DerivationOutput {
- .output = DerivationOutputFloating {
+ .output = DerivationOutputCAFloating {
.method = std::move(method),
.hashType = std::move(hashType),
},
@@ -321,11 +321,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 +390,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 +408,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 +474,7 @@ DrvHashModulo hashDerivationModulo(Store & store, const Derivation & drv, bool m
case DerivationType::CAFixed: {
std::map<std::string, Hash> outputHashes;
for (const auto & i : drv.outputs) {
- auto & dof = std::get<DerivationOutputFixed>(i.second.output);
+ auto & dof = std::get<DerivationOutputCAFixed>(i.second.output);
auto hash = hashString(htSHA256, "fixed:out:"
+ dof.hash.printMethodAlgo() + ":"
+ dof.hash.hash.to_string(Base16, false) + ":"
@@ -483,7 +483,7 @@ DrvHashModulo hashDerivationModulo(Store & store, const Derivation & drv, bool m
}
return outputHashes;
}
- case DerivationType::Regular:
+ case DerivationType::InputAddressed:
break;
}
@@ -552,7 +552,7 @@ 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::parseNonSRIUnprefixed(hash, hashType),
@@ -560,7 +560,7 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
}
}
: DerivationOutput {
- .output = DerivationOutputFloating {
+ .output = DerivationOutputCAFloating {
.method = std::move(method),
.hashType = std::move(hashType),
},
@@ -628,11 +628,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))
<< "";
},
diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh
index b1cda85cb..5a410a164 100644
--- a/src/libstore/derivations.hh
+++ b/src/libstore/derivations.hh
@@ -14,6 +14,7 @@ namespace nix {
/* Abstract syntax of derivations. */
+/* The traditional non-fixed-output derivation type. */
struct DerivationOutputInputAddressed
{
/* Will need to become `std::optional<StorePath>` once input-addressed
@@ -21,12 +22,17 @@ struct DerivationOutputInputAddressed
StorePath path;
};
-struct DerivationOutputFixed
+/* Fixed-output derivations, whose output paths are content addressed
+ according to that fixed output. */
+struct DerivationOutputCAFixed
{
FixedOutputHash hash; /* hash used for expected hash computation */
};
-struct DerivationOutputFloating
+/* Floating-output derivations, whose output paths are content addressed, but
+ not fixed, and so are dynamically calculated from whatever the output ends
+ up being. */
+struct DerivationOutputCAFloating
{
/* information used for expected hash computation */
FileIngestionMethod method;
@@ -37,8 +43,8 @@ struct DerivationOutput
{
std::variant<
DerivationOutputInputAddressed,
- DerivationOutputFixed,
- DerivationOutputFloating
+ DerivationOutputCAFixed,
+ DerivationOutputCAFloating
> output;
std::optional<HashType> hashAlgoOpt(const Store & store) const;
std::optional<StorePath> pathOpt(const Store & store, std::string_view drvName) const;
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 7de065ba8..de7ddb84b 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -573,11 +573,11 @@ void LocalStore::checkDerivationOutputs(const StorePath & drvPath, const Derivat
printStorePath(drvPath), printStorePath(doia.path), printStorePath(recomputed));
envHasRightPath(doia.path, i.first);
},
- [&](DerivationOutputFixed dof) {
+ [&](DerivationOutputCAFixed dof) {
StorePath path = makeFixedOutputPath(dof.hash.method, dof.hash.hash, drvName);
envHasRightPath(path, i.first);
},
- [&](DerivationOutputFloating _) {
+ [&](DerivationOutputCAFloating _) {
throw UnimplementedError("Floating CA output derivations are not yet implemented");
},
}, i.second.output);
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index ddba5d052..0ae1ceaad 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -113,7 +113,7 @@ std::optional<ContentAddress> getDerivationCA(const BasicDerivation & drv)
{
auto out = drv.outputs.find("out");
if (out != drv.outputs.end()) {
- if (auto v = std::get_if<DerivationOutputFixed>(&out->second.output))
+ if (auto v = std::get_if<DerivationOutputCAFixed>(&out->second.output))
return v->hash;
}
return std::nullopt;