FileSystemHash -> DerivationOutputHash

This commit is contained in:
John Ericson 2020-06-19 14:47:10 +00:00
parent 517f5980e2
commit 237d88c97e
4 changed files with 15 additions and 15 deletions

View file

@ -776,7 +776,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (!jsonObject) drv.env["out"] = state.store->printStorePath(outPath); if (!jsonObject) drv.env["out"] = state.store->printStorePath(outPath);
drv.outputs.insert_or_assign("out", DerivationOutput { drv.outputs.insert_or_assign("out", DerivationOutput {
.path = std::move(outPath), .path = std::move(outPath),
.hash = FileSystemHash { ingestionMethod, std::move(h) }, .hash = DerivationOutputHash { ingestionMethod, std::move(h) },
}); });
} }
@ -792,7 +792,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
drv.outputs.insert_or_assign(i, drv.outputs.insert_or_assign(i,
DerivationOutput { DerivationOutput {
.path = StorePath::dummy, .path = StorePath::dummy,
.hash = std::optional<FileSystemHash> {}, .hash = std::optional<DerivationOutputHash> {},
}); });
} }
@ -804,7 +804,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
drv.outputs.insert_or_assign(i, drv.outputs.insert_or_assign(i,
DerivationOutput { DerivationOutput {
.path = std::move(outPath), .path = std::move(outPath),
.hash = std::optional<FileSystemHash>(), .hash = std::optional<DerivationOutputHash>(),
}); });
} }
} }

View file

@ -8,7 +8,7 @@
namespace nix { namespace nix {
std::string FileSystemHash::printMethodAlgo() const { std::string DerivationOutputHash::printMethodAlgo() const {
return makeFileIngestionPrefix(method) + printHashType(hash.type); return makeFileIngestionPrefix(method) + printHashType(hash.type);
} }
@ -113,7 +113,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, istringstream
expect(str, ","); const auto hash = parseString(str); expect(str, ","); const auto hash = parseString(str);
expect(str, ")"); expect(str, ")");
std::optional<FileSystemHash> fsh; std::optional<DerivationOutputHash> fsh;
if (hashAlgo != "") { if (hashAlgo != "") {
auto method = FileIngestionMethod::Flat; auto method = FileIngestionMethod::Flat;
if (string(hashAlgo, 0, 2) == "r:") { if (string(hashAlgo, 0, 2) == "r:") {
@ -123,7 +123,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, istringstream
const HashType hashType = parseHashType(hashAlgo); const HashType hashType = parseHashType(hashAlgo);
if (hashType == htUnknown) if (hashType == htUnknown)
throw Error("unknown hash hashAlgorithm '%s'", hashAlgo); throw Error("unknown hash hashAlgorithm '%s'", hashAlgo);
fsh = FileSystemHash { fsh = DerivationOutputHash {
std::move(method), std::move(method),
Hash(hash, hashType), Hash(hash, hashType),
}; };
@ -413,7 +413,7 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
auto hashAlgo = readString(in); auto hashAlgo = readString(in);
const auto hash = readString(in); const auto hash = readString(in);
std::optional<FileSystemHash> fsh; std::optional<DerivationOutputHash> fsh;
if (hashAlgo != "") { if (hashAlgo != "") {
auto method = FileIngestionMethod::Flat; auto method = FileIngestionMethod::Flat;
if (string(hashAlgo, 0, 2) == "r:") { if (string(hashAlgo, 0, 2) == "r:") {
@ -423,7 +423,7 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
const HashType hashType = parseHashType(hashAlgo); const HashType hashType = parseHashType(hashAlgo);
if (hashType == htUnknown) if (hashType == htUnknown)
throw Error("unknown hash hashAlgorithm '%s'", hashAlgo); throw Error("unknown hash hashAlgorithm '%s'", hashAlgo);
fsh = FileSystemHash { fsh = DerivationOutputHash {
std::move(method), std::move(method),
Hash(hash, hashType), Hash(hash, hashType),
}; };

View file

@ -13,23 +13,23 @@ namespace nix {
/* Abstract syntax of derivations. */ /* Abstract syntax of derivations. */
/// Pair of a hash, and how the file system was ingested /// Pair of a hash, and how the file system was ingested
struct FileSystemHash { struct DerivationOutputHash {
FileIngestionMethod method; FileIngestionMethod method;
Hash hash; Hash hash;
FileSystemHash(FileIngestionMethod method, Hash hash) DerivationOutputHash(FileIngestionMethod method, Hash hash)
: method(std::move(method)) : method(std::move(method))
, hash(std::move(hash)) , hash(std::move(hash))
{ } { }
FileSystemHash(const FileSystemHash &) = default; DerivationOutputHash(const DerivationOutputHash &) = default;
FileSystemHash(FileSystemHash &&) = default; DerivationOutputHash(DerivationOutputHash &&) = default;
FileSystemHash & operator = (const FileSystemHash &) = default; DerivationOutputHash & operator = (const DerivationOutputHash &) = default;
std::string printMethodAlgo() const; std::string printMethodAlgo() const;
}; };
struct DerivationOutput struct DerivationOutput
{ {
StorePath path; StorePath path;
std::optional<FileSystemHash> hash; /* hash used for expected hash computation */ std::optional<DerivationOutputHash> hash; /* hash used for expected hash computation */
void parseHashInfo(FileIngestionMethod & recursive, Hash & hash) const; void parseHashInfo(FileIngestionMethod & recursive, Hash & hash) const;
}; };

View file

@ -137,7 +137,7 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
auto shellOutPath = store->makeOutputPath("out", h, drvName); auto shellOutPath = store->makeOutputPath("out", h, drvName);
drv.outputs.insert_or_assign("out", DerivationOutput { drv.outputs.insert_or_assign("out", DerivationOutput {
.path = shellOutPath, .path = shellOutPath,
.hash = FileSystemHash { .hash = DerivationOutputHash {
FileIngestionMethod::Flat, Hash { } FileIngestionMethod::Flat, Hash { }
}, },
}); });