mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
Merge remote-tracking branch 'obsidian/no-hash-type-unknown' into validPathInfo-ca-proper-datatype
This commit is contained in:
commit
3c78ac348c
16 changed files with 89 additions and 64 deletions
|
@ -718,14 +718,14 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
|||
if (outputs.size() != 1 || *(outputs.begin()) != "out")
|
||||
throw Error(format("multiple outputs are not supported in fixed-output derivations, at %1%") % posDrvName);
|
||||
|
||||
HashType ht = outputHashAlgo.empty() ? HashType::Unknown : parseHashType(outputHashAlgo);
|
||||
std::optional<HashType> ht = parseHashTypeOpt(outputHashAlgo);
|
||||
Hash h(*outputHash, ht);
|
||||
|
||||
auto outPath = state.store->makeFixedOutputPath(ingestionMethod, h, drvName);
|
||||
if (!jsonObject) drv.env["out"] = state.store->printStorePath(outPath);
|
||||
drv.outputs.insert_or_assign("out", DerivationOutput(
|
||||
std::move(outPath),
|
||||
FileSystemHash(ingestionMethod, std::move(h))));
|
||||
std::move(outPath),
|
||||
FileSystemHash(ingestionMethod, std::move(h))));
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -931,14 +931,14 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
|
|||
static void prim_hashFile(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||
{
|
||||
string type = state.forceStringNoCtx(*args[0], pos);
|
||||
HashType ht = parseHashType(type);
|
||||
if (ht == HashType::Unknown)
|
||||
std::optional<HashType> ht = parseHashType(type);
|
||||
if (!ht)
|
||||
throw Error(format("unknown hash type '%1%', at %2%") % type % pos);
|
||||
|
||||
PathSet context; // discarded
|
||||
Path p = state.coerceToPath(pos, *args[1], context);
|
||||
|
||||
mkString(v, hashFile(ht, state.checkSourcePath(p)).to_string(Base::Base16, false), context);
|
||||
mkString(v, hashFile(*ht, state.checkSourcePath(p)).to_string(Base::Base16, false), context);
|
||||
}
|
||||
|
||||
/* Read a directory (without . or ..) */
|
||||
|
@ -1809,14 +1809,14 @@ static void prim_stringLength(EvalState & state, const Pos & pos, Value * * args
|
|||
static void prim_hashString(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||
{
|
||||
string type = state.forceStringNoCtx(*args[0], pos);
|
||||
HashType ht = parseHashType(type);
|
||||
if (ht == HashType::Unknown)
|
||||
std::optional<HashType> ht = parseHashType(type);
|
||||
if (!ht)
|
||||
throw Error(format("unknown hash type '%1%', at %2%") % type % pos);
|
||||
|
||||
PathSet context; // discarded
|
||||
string s = state.forceString(*args[1], context, pos);
|
||||
|
||||
mkString(v, hashString(ht, s).to_string(Base::Base16, false), context);
|
||||
mkString(v, hashString(*ht, s).to_string(Base::Base16, false), context);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue