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);
drv.outputs.insert_or_assign("out", DerivationOutput {
.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,
DerivationOutput {
.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,
DerivationOutput {
.path = std::move(outPath),
.hash = std::optional<FileSystemHash>(),
.hash = std::optional<DerivationOutputHash>(),
});
}
}

View file

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

View file

@ -13,23 +13,23 @@ namespace nix {
/* Abstract syntax of derivations. */
/// Pair of a hash, and how the file system was ingested
struct FileSystemHash {
struct DerivationOutputHash {
FileIngestionMethod method;
Hash hash;
FileSystemHash(FileIngestionMethod method, Hash hash)
DerivationOutputHash(FileIngestionMethod method, Hash hash)
: method(std::move(method))
, hash(std::move(hash))
{ }
FileSystemHash(const FileSystemHash &) = default;
FileSystemHash(FileSystemHash &&) = default;
FileSystemHash & operator = (const FileSystemHash &) = default;
DerivationOutputHash(const DerivationOutputHash &) = default;
DerivationOutputHash(DerivationOutputHash &&) = default;
DerivationOutputHash & operator = (const DerivationOutputHash &) = default;
std::string printMethodAlgo() const;
};
struct DerivationOutput
{
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;
};

View file

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