mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
No inheritance for TextInfo
and FixedOutputInfo
This commit is contained in:
parent
85bb865d20
commit
d381248ec0
17 changed files with 33 additions and 31 deletions
|
@ -296,7 +296,7 @@ SV * makeFixedOutputPath(int recursive, char * algo, char * hash, char * name)
|
||||||
auto h = Hash::parseAny(hash, parseHashType(algo));
|
auto h = Hash::parseAny(hash, parseHashType(algo));
|
||||||
auto method = recursive ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
auto method = recursive ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
||||||
auto path = store()->makeFixedOutputPath(name, FixedOutputInfo {
|
auto path = store()->makeFixedOutputPath(name, FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = h,
|
.hash = h,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1283,7 +1283,7 @@ drvName, Bindings * attrs, Value & v)
|
||||||
|
|
||||||
auto method = ingestionMethod.value_or(FileIngestionMethod::Flat);
|
auto method = ingestionMethod.value_or(FileIngestionMethod::Flat);
|
||||||
auto outPath = state.store->makeFixedOutputPath(drvName, FixedOutputInfo {
|
auto outPath = state.store->makeFixedOutputPath(drvName, FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = h,
|
.hash = h,
|
||||||
},
|
},
|
||||||
|
@ -2099,7 +2099,7 @@ static void addPath(
|
||||||
std::optional<StorePath> expectedStorePath;
|
std::optional<StorePath> expectedStorePath;
|
||||||
if (expectedHash)
|
if (expectedHash)
|
||||||
expectedStorePath = state.store->makeFixedOutputPath(name, FixedOutputInfo {
|
expectedStorePath = state.store->makeFixedOutputPath(name, FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = *expectedHash,
|
.hash = *expectedHash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -246,7 +246,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
||||||
auto expectedPath = state.store->makeFixedOutputPath(
|
auto expectedPath = state.store->makeFixedOutputPath(
|
||||||
name,
|
name,
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat,
|
.method = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat,
|
||||||
.hash = *expectedHash,
|
.hash = *expectedHash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -211,7 +211,7 @@ StorePath Input::computeStorePath(Store & store) const
|
||||||
if (!narHash)
|
if (!narHash)
|
||||||
throw Error("cannot compute store path for unlocked input '%s'", to_string());
|
throw Error("cannot compute store path for unlocked input '%s'", to_string());
|
||||||
return store.makeFixedOutputPath(getName(), FixedOutputInfo {
|
return store.makeFixedOutputPath(getName(), FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::Recursive,
|
||||||
.hash = *narHash,
|
.hash = *narHash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -74,7 +74,7 @@ DownloadFileResult downloadFile(
|
||||||
*store,
|
*store,
|
||||||
name,
|
name,
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = FileIngestionMethod::Flat,
|
.method = FileIngestionMethod::Flat,
|
||||||
.hash = hash,
|
.hash = hash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -309,7 +309,7 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
|
||||||
*this,
|
*this,
|
||||||
name,
|
name,
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = nar.first,
|
.hash = nar.first,
|
||||||
},
|
},
|
||||||
|
@ -427,7 +427,7 @@ StorePath BinaryCacheStore::addToStore(
|
||||||
*this,
|
*this,
|
||||||
name,
|
name,
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = h,
|
.hash = h,
|
||||||
},
|
},
|
||||||
|
|
|
@ -2442,7 +2442,7 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
worker.store,
|
worker.store,
|
||||||
outputPathName(drv->name, outputName),
|
outputPathName(drv->name, outputName),
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = outputHash.method,
|
.method = outputHash.method,
|
||||||
.hash = got,
|
.hash = got,
|
||||||
},
|
},
|
||||||
|
|
|
@ -166,13 +166,13 @@ ContentAddressWithReferences caWithoutRefs(const ContentAddress & ca) {
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
[&](const TextHash & h) -> ContentAddressWithReferences {
|
[&](const TextHash & h) -> ContentAddressWithReferences {
|
||||||
return TextInfo {
|
return TextInfo {
|
||||||
h,
|
.hash = h,
|
||||||
.references = {},
|
.references = {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[&](const FixedOutputHash & h) -> ContentAddressWithReferences {
|
[&](const FixedOutputHash & h) -> ContentAddressWithReferences {
|
||||||
return FixedOutputInfo {
|
return FixedOutputInfo {
|
||||||
h,
|
.hash = h,
|
||||||
.references = {},
|
.references = {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -111,18 +111,20 @@ struct StoreReferences {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// This matches the additional info that we need for makeTextPath
|
// This matches the additional info that we need for makeTextPath
|
||||||
struct TextInfo : TextHash {
|
struct TextInfo {
|
||||||
|
TextHash hash;
|
||||||
// References for the paths, self references disallowed
|
// References for the paths, self references disallowed
|
||||||
StorePathSet references;
|
StorePathSet references;
|
||||||
|
|
||||||
GENERATE_CMP(TextInfo, *(const TextHash *)me, me->references);
|
GENERATE_CMP(TextInfo, me->hash, me->references);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FixedOutputInfo : FixedOutputHash {
|
struct FixedOutputInfo {
|
||||||
|
FixedOutputHash hash;
|
||||||
// References for the paths
|
// References for the paths
|
||||||
StoreReferences references;
|
StoreReferences references;
|
||||||
|
|
||||||
GENERATE_CMP(FixedOutputInfo, *(const FixedOutputHash *)me, me->references);
|
GENERATE_CMP(FixedOutputInfo, me->hash, me->references);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::variant<
|
typedef std::variant<
|
||||||
|
|
|
@ -1415,7 +1415,7 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
|
||||||
auto [hash, size] = hashSink->finish();
|
auto [hash, size] = hashSink->finish();
|
||||||
|
|
||||||
ContentAddressWithReferences desc = FixedOutputInfo {
|
ContentAddressWithReferences desc = FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = hash,
|
.hash = hash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -52,7 +52,7 @@ std::map<StorePath, StorePath> makeContentAddressed(
|
||||||
dstStore,
|
dstStore,
|
||||||
path.name(),
|
path.name(),
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::Recursive,
|
||||||
.hash = narModuloHash,
|
.hash = narModuloHash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,7 +30,7 @@ std::optional<ContentAddressWithReferences> ValidPathInfo::contentAddressWithRef
|
||||||
[&](const TextHash & th) -> ContentAddressWithReferences {
|
[&](const TextHash & th) -> ContentAddressWithReferences {
|
||||||
assert(references.count(path) == 0);
|
assert(references.count(path) == 0);
|
||||||
return TextInfo {
|
return TextInfo {
|
||||||
th,
|
.hash = th,
|
||||||
.references = references,
|
.references = references,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -42,7 +42,7 @@ std::optional<ContentAddressWithReferences> ValidPathInfo::contentAddressWithRef
|
||||||
refs.erase(path);
|
refs.erase(path);
|
||||||
}
|
}
|
||||||
return FixedOutputInfo {
|
return FixedOutputInfo {
|
||||||
foh,
|
.hash = foh,
|
||||||
.references = {
|
.references = {
|
||||||
.others = std::move(refs),
|
.others = std::move(refs),
|
||||||
.self = hasSelfReference,
|
.self = hasSelfReference,
|
||||||
|
|
|
@ -184,15 +184,15 @@ static std::string makeType(
|
||||||
|
|
||||||
StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const
|
StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const
|
||||||
{
|
{
|
||||||
if (info.hash.type == htSHA256 && info.method == FileIngestionMethod::Recursive) {
|
if (info.hash.hash.type == htSHA256 && info.hash.method == FileIngestionMethod::Recursive) {
|
||||||
return makeStorePath(makeType(*this, "source", info.references), info.hash, name);
|
return makeStorePath(makeType(*this, "source", info.references), info.hash.hash, name);
|
||||||
} else {
|
} else {
|
||||||
assert(info.references.size() == 0);
|
assert(info.references.size() == 0);
|
||||||
return makeStorePath("output:out",
|
return makeStorePath("output:out",
|
||||||
hashString(htSHA256,
|
hashString(htSHA256,
|
||||||
"fixed:out:"
|
"fixed:out:"
|
||||||
+ makeFileIngestionPrefix(info.method)
|
+ makeFileIngestionPrefix(info.hash.method)
|
||||||
+ info.hash.to_string(Base16, true) + ":"),
|
+ info.hash.hash.to_string(Base16, true) + ":"),
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,13 +200,13 @@ StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInf
|
||||||
|
|
||||||
StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) const
|
StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) const
|
||||||
{
|
{
|
||||||
assert(info.hash.type == htSHA256);
|
assert(info.hash.hash.type == htSHA256);
|
||||||
return makeStorePath(
|
return makeStorePath(
|
||||||
makeType(*this, "text", StoreReferences {
|
makeType(*this, "text", StoreReferences {
|
||||||
.others = info.references,
|
.others = info.references,
|
||||||
.self = false,
|
.self = false,
|
||||||
}),
|
}),
|
||||||
info.hash,
|
info.hash.hash,
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ std::pair<StorePath, Hash> Store::computeStorePathForPath(std::string_view name,
|
||||||
? hashPath(hashAlgo, srcPath, filter).first
|
? hashPath(hashAlgo, srcPath, filter).first
|
||||||
: hashFile(hashAlgo, srcPath);
|
: hashFile(hashAlgo, srcPath);
|
||||||
FixedOutputInfo caInfo {
|
FixedOutputInfo caInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = h,
|
.hash = h,
|
||||||
},
|
},
|
||||||
|
@ -441,7 +441,7 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
|
||||||
*this,
|
*this,
|
||||||
name,
|
name,
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = hash,
|
.hash = hash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -216,7 +216,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
||||||
std::string name = *i++;
|
std::string name = *i++;
|
||||||
|
|
||||||
cout << fmt("%s\n", store->printStorePath(store->makeFixedOutputPath(name, FixedOutputInfo {
|
cout << fmt("%s\n", store->printStorePath(store->makeFixedOutputPath(name, FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = Hash::parseAny(hash, hashAlgo),
|
.hash = Hash::parseAny(hash, hashAlgo),
|
||||||
},
|
},
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
|
||||||
*store,
|
*store,
|
||||||
std::move(*namePart),
|
std::move(*namePart),
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = std::move(ingestionMethod),
|
.method = std::move(ingestionMethod),
|
||||||
.hash = std::move(hash),
|
.hash = std::move(hash),
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,7 +68,7 @@ std::tuple<StorePath, Hash> prefetchFile(
|
||||||
if (expectedHash) {
|
if (expectedHash) {
|
||||||
hashType = expectedHash->type;
|
hashType = expectedHash->type;
|
||||||
storePath = store->makeFixedOutputPath(*name, FixedOutputInfo {
|
storePath = store->makeFixedOutputPath(*name, FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = ingestionMethod,
|
.method = ingestionMethod,
|
||||||
.hash = *expectedHash,
|
.hash = *expectedHash,
|
||||||
},
|
},
|
||||||
|
|
|
@ -203,7 +203,7 @@ struct ProfileManifest
|
||||||
*store,
|
*store,
|
||||||
"profile",
|
"profile",
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
{
|
.hash = {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::Recursive,
|
||||||
.hash = narHash,
|
.hash = narHash,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue