Skip to content

Commit

Permalink
Slight cleanup of builtins.derivation outputHashAlgo logic
Browse files Browse the repository at this point in the history
This was part of approved PR NixOS#10021. Unfortunately that one is stalled
on a peculiar Linux test timeout, so trying to get bits of it merged
first to bisect failure.
  • Loading branch information
Ericson2314 committed Apr 5, 2024
1 parent 74130fd commit 3afa86a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ drvName, Bindings * attrs, Value & v)
bool contentAddressed = false;
bool isImpure = false;
std::optional<std::string> outputHash;
std::string outputHashAlgo;
std::optional<HashAlgorithm> outputHashAlgo;
std::optional<ContentAddressMethod> ingestionMethod;

StringSet outputs;
Expand Down Expand Up @@ -1226,7 +1226,7 @@ drvName, Bindings * attrs, Value & v)
else if (i->name == state.sOutputHash)
outputHash = state.forceStringNoCtx(*i->value, pos, context_below);
else if (i->name == state.sOutputHashAlgo)
outputHashAlgo = state.forceStringNoCtx(*i->value, pos, context_below);
outputHashAlgo = parseHashAlgoOpt(state.forceStringNoCtx(*i->value, pos, context_below));
else if (i->name == state.sOutputHashMode)
handleHashMode(state.forceStringNoCtx(*i->value, pos, context_below));
else if (i->name == state.sOutputs) {
Expand All @@ -1244,7 +1244,7 @@ drvName, Bindings * attrs, Value & v)
if (i->name == state.sBuilder) drv.builder = std::move(s);
else if (i->name == state.sSystem) drv.platform = std::move(s);
else if (i->name == state.sOutputHash) outputHash = std::move(s);
else if (i->name == state.sOutputHashAlgo) outputHashAlgo = std::move(s);
else if (i->name == state.sOutputHashAlgo) outputHashAlgo = parseHashAlgoOpt(s);
else if (i->name == state.sOutputHashMode) handleHashMode(s);
else if (i->name == state.sOutputs)
handleOutputs(tokenizeString<Strings>(s));
Expand Down Expand Up @@ -1327,7 +1327,7 @@ drvName, Bindings * attrs, Value & v)
"multiple outputs are not supported in fixed-output derivations"
).atPos(v).debugThrow();

auto h = newHashAllowEmpty(*outputHash, parseHashAlgoOpt(outputHashAlgo));
auto h = newHashAllowEmpty(*outputHash, outputHashAlgo);

auto method = ingestionMethod.value_or(FileIngestionMethod::Flat);

Expand All @@ -1347,7 +1347,7 @@ drvName, Bindings * attrs, Value & v)
state.error<EvalError>("derivation cannot be both content-addressed and impure")
.atPos(v).debugThrow();

auto ha = parseHashAlgoOpt(outputHashAlgo).value_or(HashAlgorithm::SHA256);
auto ha = outputHashAlgo.value_or(HashAlgorithm::SHA256);
auto method = ingestionMethod.value_or(FileIngestionMethod::Recursive);

for (auto & i : outputs) {
Expand Down

0 comments on commit 3afa86a

Please sign in to comment.