mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
Rename Recursive
-> NixArchive
For enums: - `FileIngestionMethod` - `FileSerialisationMethod`
This commit is contained in:
parent
903acc7c0f
commit
64e599ebe1
37 changed files with 93 additions and 93 deletions
|
@ -2303,7 +2303,7 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
|
||||||
path.resolveSymlinks(),
|
path.resolveSymlinks(),
|
||||||
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
|
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
|
||||||
path.baseName(),
|
path.baseName(),
|
||||||
FileIngestionMethod::Recursive,
|
FileIngestionMethod::NixArchive,
|
||||||
nullptr,
|
nullptr,
|
||||||
repair);
|
repair);
|
||||||
allowPath(dstPath);
|
allowPath(dstPath);
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ static void derivationStrictInternal(
|
||||||
auto handleHashMode = [&](const std::string_view s) {
|
auto handleHashMode = [&](const std::string_view s) {
|
||||||
if (s == "recursive") {
|
if (s == "recursive") {
|
||||||
// back compat, new name is "nar"
|
// back compat, new name is "nar"
|
||||||
ingestionMethod = FileIngestionMethod::Recursive;
|
ingestionMethod = FileIngestionMethod::NixArchive;
|
||||||
} else try {
|
} else try {
|
||||||
ingestionMethod = ContentAddressMethod::parse(s);
|
ingestionMethod = ContentAddressMethod::parse(s);
|
||||||
} catch (UsageError &) {
|
} catch (UsageError &) {
|
||||||
|
@ -1432,7 +1432,7 @@ static void derivationStrictInternal(
|
||||||
.atPos(v).debugThrow();
|
.atPos(v).debugThrow();
|
||||||
|
|
||||||
auto ha = outputHashAlgo.value_or(HashAlgorithm::SHA256);
|
auto ha = outputHashAlgo.value_or(HashAlgorithm::SHA256);
|
||||||
auto method = ingestionMethod.value_or(FileIngestionMethod::Recursive);
|
auto method = ingestionMethod.value_or(FileIngestionMethod::NixArchive);
|
||||||
|
|
||||||
for (auto & i : outputs) {
|
for (auto & i : outputs) {
|
||||||
drv.env[i] = hashPlaceholder(i);
|
drv.env[i] = hashPlaceholder(i);
|
||||||
|
@ -2391,7 +2391,7 @@ static void prim_filterSource(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
"while evaluating the second argument (the path to filter) passed to 'builtins.filterSource'");
|
"while evaluating the second argument (the path to filter) passed to 'builtins.filterSource'");
|
||||||
state.forceFunction(*args[0], pos, "while evaluating the first argument passed to builtins.filterSource");
|
state.forceFunction(*args[0], pos, "while evaluating the first argument passed to builtins.filterSource");
|
||||||
|
|
||||||
addPath(state, pos, path.baseName(), path, args[0], FileIngestionMethod::Recursive, std::nullopt, v, context);
|
addPath(state, pos, path.baseName(), path, args[0], FileIngestionMethod::NixArchive, std::nullopt, v, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_filterSource({
|
static RegisterPrimOp primop_filterSource({
|
||||||
|
@ -2454,7 +2454,7 @@ static void prim_path(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
std::optional<SourcePath> path;
|
std::optional<SourcePath> path;
|
||||||
std::string name;
|
std::string name;
|
||||||
Value * filterFun = nullptr;
|
Value * filterFun = nullptr;
|
||||||
ContentAddressMethod method = FileIngestionMethod::Recursive;
|
ContentAddressMethod method = FileIngestionMethod::NixArchive;
|
||||||
std::optional<Hash> expectedHash;
|
std::optional<Hash> expectedHash;
|
||||||
NixStringContext context;
|
NixStringContext context;
|
||||||
|
|
||||||
|
@ -2470,7 +2470,7 @@ static void prim_path(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
state.forceFunction(*(filterFun = attr.value), attr.pos, "while evaluating the `filter` parameter passed to builtins.path");
|
state.forceFunction(*(filterFun = attr.value), attr.pos, "while evaluating the `filter` parameter passed to builtins.path");
|
||||||
else if (n == "recursive")
|
else if (n == "recursive")
|
||||||
method = state.forceBool(*attr.value, attr.pos, "while evaluating the `recursive` attribute passed to builtins.path")
|
method = state.forceBool(*attr.value, attr.pos, "while evaluating the `recursive` attribute passed to builtins.path")
|
||||||
? FileIngestionMethod::Recursive
|
? FileIngestionMethod::NixArchive
|
||||||
: FileIngestionMethod::Flat;
|
: FileIngestionMethod::Flat;
|
||||||
else if (n == "sha256")
|
else if (n == "sha256")
|
||||||
expectedHash = newHashAllowEmpty(state.forceStringNoCtx(*attr.value, attr.pos, "while evaluating the `sha256` attribute passed to builtins.path"), HashAlgorithm::SHA256);
|
expectedHash = newHashAllowEmpty(state.forceStringNoCtx(*attr.value, attr.pos, "while evaluating the `sha256` attribute passed to builtins.path"), HashAlgorithm::SHA256);
|
||||||
|
|
|
@ -468,7 +468,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 {
|
||||||
.method = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat,
|
.method = unpack ? FileIngestionMethod::NixArchive : FileIngestionMethod::Flat,
|
||||||
.hash = *expectedHash,
|
.hash = *expectedHash,
|
||||||
.references = {}
|
.references = {}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ StorePath fetchToStore(
|
||||||
const SourcePath & path,
|
const SourcePath & path,
|
||||||
FetchMode mode,
|
FetchMode mode,
|
||||||
std::string_view name = "source",
|
std::string_view name = "source",
|
||||||
ContentAddressMethod method = FileIngestionMethod::Recursive,
|
ContentAddressMethod method = FileIngestionMethod::NixArchive,
|
||||||
PathFilter * filter = nullptr,
|
PathFilter * filter = nullptr,
|
||||||
RepairFlag repair = NoRepair);
|
RepairFlag repair = NoRepair);
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,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 {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = *narHash,
|
.hash = *narHash,
|
||||||
.references = {},
|
.references = {},
|
||||||
});
|
});
|
||||||
|
|
|
@ -213,7 +213,7 @@ struct MercurialInputScheme : InputScheme
|
||||||
auto storePath = store->addToStore(
|
auto storePath = store->addToStore(
|
||||||
input.getName(),
|
input.getName(),
|
||||||
{getFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
FileIngestionMethod::Recursive, HashAlgorithm::SHA256, {},
|
FileIngestionMethod::NixArchive, HashAlgorithm::SHA256, {},
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
return storePath;
|
return storePath;
|
||||||
|
|
|
@ -322,7 +322,7 @@ StorePath BinaryCacheStore::addToStoreFromDump(
|
||||||
if (static_cast<FileIngestionMethod>(dumpMethod) == hashMethod.getFileIngestionMethod())
|
if (static_cast<FileIngestionMethod>(dumpMethod) == hashMethod.getFileIngestionMethod())
|
||||||
caHash = hashString(HashAlgorithm::SHA256, dump2.s);
|
caHash = hashString(HashAlgorithm::SHA256, dump2.s);
|
||||||
switch (dumpMethod) {
|
switch (dumpMethod) {
|
||||||
case FileSerialisationMethod::Recursive:
|
case FileSerialisationMethod::NixArchive:
|
||||||
// The dump is already NAR in this case, just use it.
|
// The dump is already NAR in this case, just use it.
|
||||||
nar = dump2.s;
|
nar = dump2.s;
|
||||||
break;
|
break;
|
||||||
|
@ -339,7 +339,7 @@ StorePath BinaryCacheStore::addToStoreFromDump(
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, we have to do th same hashing as NAR so our single
|
// Otherwise, we have to do th same hashing as NAR so our single
|
||||||
// hash will suffice for both purposes.
|
// hash will suffice for both purposes.
|
||||||
if (dumpMethod != FileSerialisationMethod::Recursive || hashAlgo != HashAlgorithm::SHA256)
|
if (dumpMethod != FileSerialisationMethod::NixArchive || hashAlgo != HashAlgorithm::SHA256)
|
||||||
unsupported("addToStoreFromDump");
|
unsupported("addToStoreFromDump");
|
||||||
}
|
}
|
||||||
StringSource narDump { nar };
|
StringSource narDump { nar };
|
||||||
|
|
|
@ -530,7 +530,7 @@ bool Worker::pathContentsGood(const StorePath & path)
|
||||||
else {
|
else {
|
||||||
auto current = hashPath(
|
auto current = hashPath(
|
||||||
{store.getFSAccessor(), CanonPath(store.printStorePath(path))},
|
{store.getFSAccessor(), CanonPath(store.printStorePath(path))},
|
||||||
FileIngestionMethod::Recursive, info->narHash.algo).first;
|
FileIngestionMethod::NixArchive, info->narHash.algo).first;
|
||||||
Hash nullHash(HashAlgorithm::SHA256);
|
Hash nullHash(HashAlgorithm::SHA256);
|
||||||
res = info->narHash == nullHash || info->narHash == current;
|
res = info->narHash == nullHash || info->narHash == current;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ std::string_view makeFileIngestionPrefix(FileIngestionMethod m)
|
||||||
switch (m) {
|
switch (m) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
return "";
|
return "";
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
return "r:";
|
return "r:";
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
experimentalFeatureSettings.require(Xp::GitHashing);
|
experimentalFeatureSettings.require(Xp::GitHashing);
|
||||||
|
@ -52,7 +52,7 @@ std::string_view ContentAddressMethod::renderPrefix() const
|
||||||
ContentAddressMethod ContentAddressMethod::parsePrefix(std::string_view & m)
|
ContentAddressMethod ContentAddressMethod::parsePrefix(std::string_view & m)
|
||||||
{
|
{
|
||||||
if (splitPrefix(m, "r:")) {
|
if (splitPrefix(m, "r:")) {
|
||||||
return FileIngestionMethod::Recursive;
|
return FileIngestionMethod::NixArchive;
|
||||||
}
|
}
|
||||||
else if (splitPrefix(m, "git:")) {
|
else if (splitPrefix(m, "git:")) {
|
||||||
experimentalFeatureSettings.require(Xp::GitHashing);
|
experimentalFeatureSettings.require(Xp::GitHashing);
|
||||||
|
@ -137,7 +137,7 @@ static std::pair<ContentAddressMethod, HashAlgorithm> parseContentAddressMethodP
|
||||||
// Parse method
|
// Parse method
|
||||||
auto method = FileIngestionMethod::Flat;
|
auto method = FileIngestionMethod::Flat;
|
||||||
if (splitPrefix(rest, "r:"))
|
if (splitPrefix(rest, "r:"))
|
||||||
method = FileIngestionMethod::Recursive;
|
method = FileIngestionMethod::NixArchive;
|
||||||
else if (splitPrefix(rest, "git:")) {
|
else if (splitPrefix(rest, "git:")) {
|
||||||
experimentalFeatureSettings.require(Xp::GitHashing);
|
experimentalFeatureSettings.require(Xp::GitHashing);
|
||||||
method = FileIngestionMethod::Git;
|
method = FileIngestionMethod::Git;
|
||||||
|
|
|
@ -415,12 +415,12 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
dumpMethod = FileSerialisationMethod::Flat;
|
dumpMethod = FileSerialisationMethod::Flat;
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
dumpMethod = FileSerialisationMethod::Recursive;
|
dumpMethod = FileSerialisationMethod::NixArchive;
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
// Use NAR; Git is not a serialization method
|
// Use NAR; Git is not a serialization method
|
||||||
dumpMethod = FileSerialisationMethod::Recursive;
|
dumpMethod = FileSerialisationMethod::NixArchive;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -441,13 +441,13 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
uint8_t recursive;
|
uint8_t recursive;
|
||||||
std::string hashAlgoRaw;
|
std::string hashAlgoRaw;
|
||||||
from >> baseName >> fixed /* obsolete */ >> recursive >> hashAlgoRaw;
|
from >> baseName >> fixed /* obsolete */ >> recursive >> hashAlgoRaw;
|
||||||
if (recursive > (uint8_t) FileIngestionMethod::Recursive)
|
if (recursive > (uint8_t) FileIngestionMethod::NixArchive)
|
||||||
throw Error("unsupported FileIngestionMethod with value of %i; you may need to upgrade nix-daemon", recursive);
|
throw Error("unsupported FileIngestionMethod with value of %i; you may need to upgrade nix-daemon", recursive);
|
||||||
method = FileIngestionMethod { recursive };
|
method = FileIngestionMethod { recursive };
|
||||||
/* Compatibility hack. */
|
/* Compatibility hack. */
|
||||||
if (!fixed) {
|
if (!fixed) {
|
||||||
hashAlgoRaw = "sha256";
|
hashAlgoRaw = "sha256";
|
||||||
method = FileIngestionMethod::Recursive;
|
method = FileIngestionMethod::NixArchive;
|
||||||
}
|
}
|
||||||
hashAlgo = parseHashAlgo(hashAlgoRaw);
|
hashAlgo = parseHashAlgo(hashAlgoRaw);
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
});
|
});
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto path = store->addToStoreFromDump(
|
auto path = store->addToStoreFromDump(
|
||||||
*dumpSource, baseName, FileSerialisationMethod::Recursive, method, hashAlgo);
|
*dumpSource, baseName, FileSerialisationMethod::NixArchive, method, hashAlgo);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
|
|
||||||
to << store->printStorePath(path);
|
to << store->printStorePath(path);
|
||||||
|
|
|
@ -64,8 +64,8 @@ struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
||||||
virtual StorePath addToStoreFromDump(
|
virtual StorePath addToStoreFromDump(
|
||||||
Source & dump,
|
Source & dump,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
FileSerialisationMethod dumpMethod = FileSerialisationMethod::Recursive,
|
FileSerialisationMethod dumpMethod = FileSerialisationMethod::NixArchive,
|
||||||
ContentAddressMethod hashMethod = FileIngestionMethod::Recursive,
|
ContentAddressMethod hashMethod = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = StorePathSet(),
|
const StorePathSet & references = StorePathSet(),
|
||||||
RepairFlag repair = NoRepair) override
|
RepairFlag repair = NoRepair) override
|
||||||
|
|
|
@ -76,8 +76,8 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
|
||||||
virtual StorePath addToStoreFromDump(
|
virtual StorePath addToStoreFromDump(
|
||||||
Source & dump,
|
Source & dump,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
FileSerialisationMethod dumpMethod = FileSerialisationMethod::Recursive,
|
FileSerialisationMethod dumpMethod = FileSerialisationMethod::NixArchive,
|
||||||
ContentAddressMethod hashMethod = FileIngestionMethod::Recursive,
|
ContentAddressMethod hashMethod = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = StorePathSet(),
|
const StorePathSet & references = StorePathSet(),
|
||||||
RepairFlag repair = NoRepair) override
|
RepairFlag repair = NoRepair) override
|
||||||
|
|
|
@ -1155,7 +1155,7 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
|
||||||
auto fim = specified.method.getFileIngestionMethod();
|
auto fim = specified.method.getFileIngestionMethod();
|
||||||
switch (fim) {
|
switch (fim) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
{
|
{
|
||||||
HashModuloSink caSink {
|
HashModuloSink caSink {
|
||||||
specified.hash.algo,
|
specified.hash.algo,
|
||||||
|
@ -1314,7 +1314,7 @@ StorePath LocalStore::addToStoreFromDump(
|
||||||
auto fim = hashMethod.getFileIngestionMethod();
|
auto fim = hashMethod.getFileIngestionMethod();
|
||||||
switch (fim) {
|
switch (fim) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
restorePath(realPath, dumpSource, (FileSerialisationMethod) fim);
|
restorePath(realPath, dumpSource, (FileSerialisationMethod) fim);
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
|
@ -1330,7 +1330,7 @@ StorePath LocalStore::addToStoreFromDump(
|
||||||
/* For computing the nar hash. In recursive SHA-256 mode, this
|
/* For computing the nar hash. In recursive SHA-256 mode, this
|
||||||
is the same as the store hash, so no need to do it again. */
|
is the same as the store hash, so no need to do it again. */
|
||||||
auto narHash = std::pair { dumpHash, size };
|
auto narHash = std::pair { dumpHash, size };
|
||||||
if (dumpMethod != FileSerialisationMethod::Recursive || hashAlgo != HashAlgorithm::SHA256) {
|
if (dumpMethod != FileSerialisationMethod::NixArchive || hashAlgo != HashAlgorithm::SHA256) {
|
||||||
HashSink narSink { HashAlgorithm::SHA256 };
|
HashSink narSink { HashAlgorithm::SHA256 };
|
||||||
dumpPath(realPath, narSink);
|
dumpPath(realPath, narSink);
|
||||||
narHash = narSink.finish();
|
narHash = narSink.finish();
|
||||||
|
@ -1423,7 +1423,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
PosixSourceAccessor accessor;
|
PosixSourceAccessor accessor;
|
||||||
std::string hash = hashPath(
|
std::string hash = hashPath(
|
||||||
PosixSourceAccessor::createAtRoot(link.path()),
|
PosixSourceAccessor::createAtRoot(link.path()),
|
||||||
FileIngestionMethod::Recursive, HashAlgorithm::SHA256).first.to_string(HashFormat::Nix32, false);
|
FileIngestionMethod::NixArchive, HashAlgorithm::SHA256).first.to_string(HashFormat::Nix32, false);
|
||||||
if (hash != name.string()) {
|
if (hash != name.string()) {
|
||||||
printError("link '%s' was modified! expected hash '%s', got '%s'",
|
printError("link '%s' was modified! expected hash '%s', got '%s'",
|
||||||
link.path(), name, hash);
|
link.path(), name, hash);
|
||||||
|
|
|
@ -52,7 +52,7 @@ std::map<StorePath, StorePath> makeContentAddressed(
|
||||||
dstStore,
|
dstStore,
|
||||||
path.name(),
|
path.name(),
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = narModuloHash,
|
.hash = narModuloHash,
|
||||||
.references = std::move(refs),
|
.references = std::move(refs),
|
||||||
},
|
},
|
||||||
|
|
|
@ -151,7 +151,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
|
||||||
Hash hash = ({
|
Hash hash = ({
|
||||||
hashPath(
|
hashPath(
|
||||||
{make_ref<PosixSourceAccessor>(), CanonPath(path)},
|
{make_ref<PosixSourceAccessor>(), CanonPath(path)},
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256).first;
|
FileSerialisationMethod::NixArchive, HashAlgorithm::SHA256).first;
|
||||||
});
|
});
|
||||||
debug("'%1%' has hash '%2%'", path, hash.to_string(HashFormat::Nix32, true));
|
debug("'%1%' has hash '%2%'", path, hash.to_string(HashFormat::Nix32, true));
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
|
||||||
|| (repair && hash != ({
|
|| (repair && hash != ({
|
||||||
hashPath(
|
hashPath(
|
||||||
PosixSourceAccessor::createAtRoot(linkPath),
|
PosixSourceAccessor::createAtRoot(linkPath),
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256).first;
|
FileSerialisationMethod::NixArchive, HashAlgorithm::SHA256).first;
|
||||||
})))
|
})))
|
||||||
{
|
{
|
||||||
// XXX: Consider overwriting linkPath with our valid version.
|
// XXX: Consider overwriting linkPath with our valid version.
|
||||||
|
|
|
@ -406,8 +406,8 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
||||||
conn->to
|
conn->to
|
||||||
<< WorkerProto::Op::AddToStore
|
<< WorkerProto::Op::AddToStore
|
||||||
<< name
|
<< name
|
||||||
<< ((hashAlgo == HashAlgorithm::SHA256 && fim == FileIngestionMethod::Recursive) ? 0 : 1) /* backwards compatibility hack */
|
<< ((hashAlgo == HashAlgorithm::SHA256 && fim == FileIngestionMethod::NixArchive) ? 0 : 1) /* backwards compatibility hack */
|
||||||
<< (fim == FileIngestionMethod::Recursive ? 1 : 0)
|
<< (fim == FileIngestionMethod::NixArchive ? 1 : 0)
|
||||||
<< printHashAlgo(hashAlgo);
|
<< printHashAlgo(hashAlgo);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -415,7 +415,7 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
||||||
connections->incCapacity();
|
connections->incCapacity();
|
||||||
{
|
{
|
||||||
Finally cleanup([&]() { connections->decCapacity(); });
|
Finally cleanup([&]() { connections->decCapacity(); });
|
||||||
if (fim == FileIngestionMethod::Recursive) {
|
if (fim == FileIngestionMethod::NixArchive) {
|
||||||
dump.drainInto(conn->to);
|
dump.drainInto(conn->to);
|
||||||
} else {
|
} else {
|
||||||
std::string contents = dump.drain();
|
std::string contents = dump.drain();
|
||||||
|
@ -457,12 +457,12 @@ StorePath RemoteStore::addToStoreFromDump(
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
fsm = FileSerialisationMethod::Flat;
|
fsm = FileSerialisationMethod::Flat;
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
fsm = FileSerialisationMethod::Recursive;
|
fsm = FileSerialisationMethod::NixArchive;
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
// Use NAR; Git is not a serialization method
|
// Use NAR; Git is not a serialization method
|
||||||
fsm = FileSerialisationMethod::Recursive;
|
fsm = FileSerialisationMethod::NixArchive;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
@ -87,8 +87,8 @@ public:
|
||||||
StorePath addToStoreFromDump(
|
StorePath addToStoreFromDump(
|
||||||
Source & dump,
|
Source & dump,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
FileSerialisationMethod dumpMethod = FileSerialisationMethod::Recursive,
|
FileSerialisationMethod dumpMethod = FileSerialisationMethod::NixArchive,
|
||||||
ContentAddressMethod hashMethod = FileIngestionMethod::Recursive,
|
ContentAddressMethod hashMethod = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = StorePathSet(),
|
const StorePathSet & references = StorePathSet(),
|
||||||
RepairFlag repair = NoRepair) override;
|
RepairFlag repair = NoRepair) override;
|
||||||
|
|
|
@ -122,7 +122,7 @@ StorePath StoreDirConfig::makeFixedOutputPath(std::string_view name, const Fixed
|
||||||
if (info.method == FileIngestionMethod::Git && info.hash.algo != HashAlgorithm::SHA1)
|
if (info.method == FileIngestionMethod::Git && info.hash.algo != HashAlgorithm::SHA1)
|
||||||
throw Error("Git file ingestion must use SHA-1 hash");
|
throw Error("Git file ingestion must use SHA-1 hash");
|
||||||
|
|
||||||
if (info.hash.algo == HashAlgorithm::SHA256 && info.method == FileIngestionMethod::Recursive) {
|
if (info.hash.algo == HashAlgorithm::SHA256 && info.method == FileIngestionMethod::NixArchive) {
|
||||||
return makeStorePath(makeType(*this, "source", info.references), info.hash, name);
|
return makeStorePath(makeType(*this, "source", info.references), info.hash, name);
|
||||||
} else {
|
} else {
|
||||||
if (!info.references.empty()) {
|
if (!info.references.empty()) {
|
||||||
|
@ -200,12 +200,12 @@ StorePath Store::addToStore(
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
fsm = FileSerialisationMethod::Flat;
|
fsm = FileSerialisationMethod::Flat;
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
fsm = FileSerialisationMethod::Recursive;
|
fsm = FileSerialisationMethod::NixArchive;
|
||||||
break;
|
break;
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
// Use NAR; Git is not a serialization method
|
// Use NAR; Git is not a serialization method
|
||||||
fsm = FileSerialisationMethod::Recursive;
|
fsm = FileSerialisationMethod::NixArchive;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto source = sinkToSource([&](Sink & sink) {
|
auto source = sinkToSource([&](Sink & sink) {
|
||||||
|
@ -356,7 +356,7 @@ ValidPathInfo Store::addToStoreSlow(
|
||||||
RegularFileSink fileSink { caHashSink };
|
RegularFileSink fileSink { caHashSink };
|
||||||
TeeSink unusualHashTee { narHashSink, caHashSink };
|
TeeSink unusualHashTee { narHashSink, caHashSink };
|
||||||
|
|
||||||
auto & narSink = method == FileIngestionMethod::Recursive && hashAlgo != HashAlgorithm::SHA256
|
auto & narSink = method == FileIngestionMethod::NixArchive && hashAlgo != HashAlgorithm::SHA256
|
||||||
? static_cast<Sink &>(unusualHashTee)
|
? static_cast<Sink &>(unusualHashTee)
|
||||||
: narHashSink;
|
: narHashSink;
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ ValidPathInfo Store::addToStoreSlow(
|
||||||
finish. */
|
finish. */
|
||||||
auto [narHash, narSize] = narHashSink.finish();
|
auto [narHash, narSize] = narHashSink.finish();
|
||||||
|
|
||||||
auto hash = method == FileIngestionMethod::Recursive && hashAlgo == HashAlgorithm::SHA256
|
auto hash = method == FileIngestionMethod::NixArchive && hashAlgo == HashAlgorithm::SHA256
|
||||||
? narHash
|
? narHash
|
||||||
: method == FileIngestionMethod::Git
|
: method == FileIngestionMethod::Git
|
||||||
? git::dumpHash(hashAlgo, srcPath).hash
|
? git::dumpHash(hashAlgo, srcPath).hash
|
||||||
|
|
|
@ -441,7 +441,7 @@ public:
|
||||||
virtual StorePath addToStore(
|
virtual StorePath addToStore(
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
const SourcePath & path,
|
const SourcePath & path,
|
||||||
ContentAddressMethod method = FileIngestionMethod::Recursive,
|
ContentAddressMethod method = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = StorePathSet(),
|
const StorePathSet & references = StorePathSet(),
|
||||||
PathFilter & filter = defaultPathFilter,
|
PathFilter & filter = defaultPathFilter,
|
||||||
|
@ -455,7 +455,7 @@ public:
|
||||||
ValidPathInfo addToStoreSlow(
|
ValidPathInfo addToStoreSlow(
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
const SourcePath & path,
|
const SourcePath & path,
|
||||||
ContentAddressMethod method = FileIngestionMethod::Recursive,
|
ContentAddressMethod method = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = StorePathSet(),
|
const StorePathSet & references = StorePathSet(),
|
||||||
std::optional<Hash> expectedCAHash = {});
|
std::optional<Hash> expectedCAHash = {});
|
||||||
|
@ -470,7 +470,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param dumpMethod What serialisation format is `dump`, i.e. how
|
* @param dumpMethod What serialisation format is `dump`, i.e. how
|
||||||
* to deserialize it. Must either match hashMethod or be
|
* to deserialize it. Must either match hashMethod or be
|
||||||
* `FileSerialisationMethod::Recursive`.
|
* `FileSerialisationMethod::NixArchive`.
|
||||||
*
|
*
|
||||||
* @param hashMethod How content addressing? Need not match be the
|
* @param hashMethod How content addressing? Need not match be the
|
||||||
* same as `dumpMethod`.
|
* same as `dumpMethod`.
|
||||||
|
@ -480,8 +480,8 @@ public:
|
||||||
virtual StorePath addToStoreFromDump(
|
virtual StorePath addToStoreFromDump(
|
||||||
Source & dump,
|
Source & dump,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
FileSerialisationMethod dumpMethod = FileSerialisationMethod::Recursive,
|
FileSerialisationMethod dumpMethod = FileSerialisationMethod::NixArchive,
|
||||||
ContentAddressMethod hashMethod = FileIngestionMethod::Recursive,
|
ContentAddressMethod hashMethod = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = StorePathSet(),
|
const StorePathSet & references = StorePathSet(),
|
||||||
RepairFlag repair = NoRepair) = 0;
|
RepairFlag repair = NoRepair) = 0;
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct StoreDirConfig : public Config
|
||||||
std::pair<StorePath, Hash> computeStorePath(
|
std::pair<StorePath, Hash> computeStorePath(
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
const SourcePath & path,
|
const SourcePath & path,
|
||||||
ContentAddressMethod method = FileIngestionMethod::Recursive,
|
ContentAddressMethod method = FileIngestionMethod::NixArchive,
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256,
|
||||||
const StorePathSet & references = {},
|
const StorePathSet & references = {},
|
||||||
PathFilter & filter = defaultPathFilter) const;
|
PathFilter & filter = defaultPathFilter) const;
|
||||||
|
|
|
@ -2489,7 +2489,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
auto fim = outputHash.method.getFileIngestionMethod();
|
auto fim = outputHash.method.getFileIngestionMethod();
|
||||||
switch (fim) {
|
switch (fim) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
{
|
{
|
||||||
HashModuloSink caSink { outputHash.hashAlgo, oldHashPart };
|
HashModuloSink caSink { outputHash.hashAlgo, oldHashPart };
|
||||||
auto fim = outputHash.method.getFileIngestionMethod();
|
auto fim = outputHash.method.getFileIngestionMethod();
|
||||||
|
@ -2531,7 +2531,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
{
|
{
|
||||||
HashResult narHashAndSize = hashPath(
|
HashResult narHashAndSize = hashPath(
|
||||||
{getFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
FileSerialisationMethod::NixArchive, HashAlgorithm::SHA256);
|
||||||
newInfo0.narHash = narHashAndSize.first;
|
newInfo0.narHash = narHashAndSize.first;
|
||||||
newInfo0.narSize = narHashAndSize.second;
|
newInfo0.narSize = narHashAndSize.second;
|
||||||
}
|
}
|
||||||
|
@ -2554,7 +2554,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
rewriteOutput(outputRewrites);
|
rewriteOutput(outputRewrites);
|
||||||
HashResult narHashAndSize = hashPath(
|
HashResult narHashAndSize = hashPath(
|
||||||
{getFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
FileSerialisationMethod::NixArchive, HashAlgorithm::SHA256);
|
||||||
ValidPathInfo newInfo0 { requiredFinalPath, narHashAndSize.first };
|
ValidPathInfo newInfo0 { requiredFinalPath, narHashAndSize.first };
|
||||||
newInfo0.narSize = narHashAndSize.second;
|
newInfo0.narSize = narHashAndSize.second;
|
||||||
auto refs = rewriteRefs();
|
auto refs = rewriteRefs();
|
||||||
|
|
|
@ -10,7 +10,7 @@ static std::optional<FileSerialisationMethod> parseFileSerialisationMethodOpt(st
|
||||||
if (input == "flat") {
|
if (input == "flat") {
|
||||||
return FileSerialisationMethod::Flat;
|
return FileSerialisationMethod::Flat;
|
||||||
} else if (input == "nar") {
|
} else if (input == "nar") {
|
||||||
return FileSerialisationMethod::Recursive;
|
return FileSerialisationMethod::NixArchive;
|
||||||
} else {
|
} else {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ std::string_view renderFileSerialisationMethod(FileSerialisationMethod method)
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case FileSerialisationMethod::Flat:
|
case FileSerialisationMethod::Flat:
|
||||||
return "flat";
|
return "flat";
|
||||||
case FileSerialisationMethod::Recursive:
|
case FileSerialisationMethod::NixArchive:
|
||||||
return "nar";
|
return "nar";
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -57,7 +57,7 @@ std::string_view renderFileIngestionMethod(FileIngestionMethod method)
|
||||||
{
|
{
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
return renderFileSerialisationMethod(
|
return renderFileSerialisationMethod(
|
||||||
static_cast<FileSerialisationMethod>(method));
|
static_cast<FileSerialisationMethod>(method));
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
|
@ -78,7 +78,7 @@ void dumpPath(
|
||||||
case FileSerialisationMethod::Flat:
|
case FileSerialisationMethod::Flat:
|
||||||
path.readFile(sink);
|
path.readFile(sink);
|
||||||
break;
|
break;
|
||||||
case FileSerialisationMethod::Recursive:
|
case FileSerialisationMethod::NixArchive:
|
||||||
path.dumpPath(sink, filter);
|
path.dumpPath(sink, filter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ void restorePath(
|
||||||
case FileSerialisationMethod::Flat:
|
case FileSerialisationMethod::Flat:
|
||||||
writeFile(path, source);
|
writeFile(path, source);
|
||||||
break;
|
break;
|
||||||
case FileSerialisationMethod::Recursive:
|
case FileSerialisationMethod::NixArchive:
|
||||||
restorePath(path, source);
|
restorePath(path, source);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ std::pair<Hash, std::optional<uint64_t>> hashPath(
|
||||||
{
|
{
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
case FileIngestionMethod::Recursive: {
|
case FileIngestionMethod::NixArchive: {
|
||||||
auto res = hashPath(path, (FileSerialisationMethod) method, ht, filter);
|
auto res = hashPath(path, (FileSerialisationMethod) method, ht, filter);
|
||||||
return {res.first, {res.second}};
|
return {res.first, {res.second}};
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ enum struct FileSerialisationMethod : uint8_t {
|
||||||
* See `file-system-object/content-address.md#serial-nix-archive` in
|
* See `file-system-object/content-address.md#serial-nix-archive` in
|
||||||
* the manual.
|
* the manual.
|
||||||
*/
|
*/
|
||||||
Recursive,
|
NixArchive,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a `FileSerialisationMethod` by name. Choice of:
|
* Parse a `FileSerialisationMethod` by name. Choice of:
|
||||||
*
|
*
|
||||||
* - `flat`: `FileSerialisationMethod::Flat`
|
* - `flat`: `FileSerialisationMethod::Flat`
|
||||||
* - `nar`: `FileSerialisationMethod::Recursive`
|
* - `nar`: `FileSerialisationMethod::NixArchive`
|
||||||
*
|
*
|
||||||
* Opposite of `renderFileSerialisationMethod`.
|
* Opposite of `renderFileSerialisationMethod`.
|
||||||
*/
|
*/
|
||||||
|
@ -107,12 +107,12 @@ enum struct FileIngestionMethod : uint8_t {
|
||||||
Flat,
|
Flat,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash `FileSerialisationMethod::Recursive` serialisation.
|
* Hash `FileSerialisationMethod::NixArchive` serialisation.
|
||||||
*
|
*
|
||||||
* See `file-system-object/content-address.md#serial-flat` in the
|
* See `file-system-object/content-address.md#serial-flat` in the
|
||||||
* manual.
|
* manual.
|
||||||
*/
|
*/
|
||||||
Recursive,
|
NixArchive,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git hashing.
|
* Git hashing.
|
||||||
|
@ -127,7 +127,7 @@ enum struct FileIngestionMethod : uint8_t {
|
||||||
* Parse a `FileIngestionMethod` by name. Choice of:
|
* Parse a `FileIngestionMethod` by name. Choice of:
|
||||||
*
|
*
|
||||||
* - `flat`: `FileIngestionMethod::Flat`
|
* - `flat`: `FileIngestionMethod::Flat`
|
||||||
* - `nar`: `FileIngestionMethod::Recursive`
|
* - `nar`: `FileIngestionMethod::NixArchive`
|
||||||
* - `git`: `FileIngestionMethod::Git`
|
* - `git`: `FileIngestionMethod::Git`
|
||||||
*
|
*
|
||||||
* Opposite of `renderFileIngestionMethod`.
|
* Opposite of `renderFileIngestionMethod`.
|
||||||
|
|
|
@ -197,7 +197,7 @@ static void opAddFixed(Strings opFlags, Strings opArgs)
|
||||||
auto method = FileIngestionMethod::Flat;
|
auto method = FileIngestionMethod::Flat;
|
||||||
|
|
||||||
for (auto & i : opFlags)
|
for (auto & i : opFlags)
|
||||||
if (i == "--recursive") method = FileIngestionMethod::Recursive;
|
if (i == "--recursive") method = FileIngestionMethod::NixArchive;
|
||||||
else throw UsageError("unknown flag '%1%'", i);
|
else throw UsageError("unknown flag '%1%'", i);
|
||||||
|
|
||||||
if (opArgs.empty())
|
if (opArgs.empty())
|
||||||
|
@ -223,7 +223,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
||||||
auto method = FileIngestionMethod::Flat;
|
auto method = FileIngestionMethod::Flat;
|
||||||
|
|
||||||
for (auto i : opFlags)
|
for (auto i : opFlags)
|
||||||
if (i == "--recursive") method = FileIngestionMethod::Recursive;
|
if (i == "--recursive") method = FileIngestionMethod::NixArchive;
|
||||||
else throw UsageError("unknown flag '%1%'", i);
|
else throw UsageError("unknown flag '%1%'", i);
|
||||||
|
|
||||||
if (opArgs.size() != 3)
|
if (opArgs.size() != 3)
|
||||||
|
@ -563,7 +563,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
||||||
if (!hashGiven) {
|
if (!hashGiven) {
|
||||||
HashResult hash = hashPath(
|
HashResult hash = hashPath(
|
||||||
{store->getFSAccessor(false), CanonPath { store->printStorePath(info->path) }},
|
{store->getFSAccessor(false), CanonPath { store->printStorePath(info->path) }},
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
FileSerialisationMethod::NixArchive, HashAlgorithm::SHA256);
|
||||||
info->narHash = hash.first;
|
info->narHash = hash.first;
|
||||||
info->narSize = hash.second;
|
info->narSize = hash.second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
|
||||||
{
|
{
|
||||||
Path path;
|
Path path;
|
||||||
std::optional<std::string> namePart;
|
std::optional<std::string> namePart;
|
||||||
ContentAddressMethod caMethod = FileIngestionMethod::Recursive;
|
ContentAddressMethod caMethod = FileIngestionMethod::NixArchive;
|
||||||
HashAlgorithm hashAlgo = HashAlgorithm::SHA256;
|
HashAlgorithm hashAlgo = HashAlgorithm::SHA256;
|
||||||
|
|
||||||
CmdAddToStore()
|
CmdAddToStore()
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct CmdHashBase : Command
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
return "print cryptographic hash of a regular file";
|
return "print cryptographic hash of a regular file";
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
return "print cryptographic hash of the NAR serialisation of a path";
|
return "print cryptographic hash of the NAR serialisation of a path";
|
||||||
case FileIngestionMethod::Git:
|
case FileIngestionMethod::Git:
|
||||||
return "print cryptographic hash of the Git serialisation of a path";
|
return "print cryptographic hash of the Git serialisation of a path";
|
||||||
|
@ -91,7 +91,7 @@ struct CmdHashBase : Command
|
||||||
Hash h { HashAlgorithm::SHA256 }; // throwaway def to appease C++
|
Hash h { HashAlgorithm::SHA256 }; // throwaway def to appease C++
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
case FileIngestionMethod::Recursive:
|
case FileIngestionMethod::NixArchive:
|
||||||
{
|
{
|
||||||
auto hashSink = makeSink();
|
auto hashSink = makeSink();
|
||||||
dumpPath(path2, *hashSink, (FileSerialisationMethod) mode);
|
dumpPath(path2, *hashSink, (FileSerialisationMethod) mode);
|
||||||
|
@ -126,7 +126,7 @@ struct CmdHashBase : Command
|
||||||
struct CmdHashPath : CmdHashBase
|
struct CmdHashPath : CmdHashBase
|
||||||
{
|
{
|
||||||
CmdHashPath()
|
CmdHashPath()
|
||||||
: CmdHashBase(FileIngestionMethod::Recursive)
|
: CmdHashBase(FileIngestionMethod::NixArchive)
|
||||||
{
|
{
|
||||||
addFlag(flag::hashAlgo("algo", &hashAlgo));
|
addFlag(flag::hashAlgo("algo", &hashAlgo));
|
||||||
addFlag(flag::fileIngestionMethod(&mode));
|
addFlag(flag::fileIngestionMethod(&mode));
|
||||||
|
@ -311,7 +311,7 @@ static int compatNixHash(int argc, char * * argv)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (op == opHash) {
|
if (op == opHash) {
|
||||||
CmdHashBase cmd(flat ? FileIngestionMethod::Flat : FileIngestionMethod::Recursive);
|
CmdHashBase cmd(flat ? FileIngestionMethod::Flat : FileIngestionMethod::NixArchive);
|
||||||
if (!hashAlgo.has_value()) hashAlgo = HashAlgorithm::MD5;
|
if (!hashAlgo.has_value()) hashAlgo = HashAlgorithm::MD5;
|
||||||
cmd.hashAlgo = hashAlgo.value();
|
cmd.hashAlgo = hashAlgo.value();
|
||||||
cmd.hashFormat = hashFormat;
|
cmd.hashFormat = hashFormat;
|
||||||
|
|
|
@ -57,7 +57,7 @@ std::tuple<StorePath, Hash> prefetchFile(
|
||||||
bool unpack,
|
bool unpack,
|
||||||
bool executable)
|
bool executable)
|
||||||
{
|
{
|
||||||
auto ingestionMethod = unpack || executable ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
auto ingestionMethod = unpack || executable ? FileIngestionMethod::NixArchive : FileIngestionMethod::Flat;
|
||||||
|
|
||||||
/* Figure out a name in the Nix store. */
|
/* Figure out a name in the Nix store. */
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
|
|
@ -258,7 +258,7 @@ struct ProfileManifest
|
||||||
*store,
|
*store,
|
||||||
"profile",
|
"profile",
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = narHash,
|
.hash = narHash,
|
||||||
.references = {
|
.references = {
|
||||||
.others = std::move(references),
|
.others = std::move(references),
|
||||||
|
|
|
@ -259,7 +259,7 @@ hashPath(char * algo, int base32, char * path)
|
||||||
try {
|
try {
|
||||||
Hash h = hashPath(
|
Hash h = hashPath(
|
||||||
PosixSourceAccessor::createAtRoot(path),
|
PosixSourceAccessor::createAtRoot(path),
|
||||||
FileIngestionMethod::Recursive, parseHashAlgo(algo)).first;
|
FileIngestionMethod::NixArchive, parseHashAlgo(algo)).first;
|
||||||
auto s = h.to_string(base32 ? HashFormat::Nix32 : HashFormat::Base16, false);
|
auto s = h.to_string(base32 ? HashFormat::Nix32 : HashFormat::Base16, false);
|
||||||
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
|
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
|
@ -335,7 +335,7 @@ SV *
|
||||||
StoreWrapper::addToStore(char * srcPath, int recursive, char * algo)
|
StoreWrapper::addToStore(char * srcPath, int recursive, char * algo)
|
||||||
PPCODE:
|
PPCODE:
|
||||||
try {
|
try {
|
||||||
auto method = recursive ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
auto method = recursive ? FileIngestionMethod::NixArchive : FileIngestionMethod::Flat;
|
||||||
auto path = THIS->store->addToStore(
|
auto path = THIS->store->addToStore(
|
||||||
std::string(baseNameOf(srcPath)),
|
std::string(baseNameOf(srcPath)),
|
||||||
PosixSourceAccessor::createAtRoot(srcPath),
|
PosixSourceAccessor::createAtRoot(srcPath),
|
||||||
|
@ -351,7 +351,7 @@ StoreWrapper::makeFixedOutputPath(int recursive, char * algo, char * hash, char
|
||||||
PPCODE:
|
PPCODE:
|
||||||
try {
|
try {
|
||||||
auto h = Hash::parseAny(hash, parseHashAlgo(algo));
|
auto h = Hash::parseAny(hash, parseHashAlgo(algo));
|
||||||
auto method = recursive ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
auto method = recursive ? FileIngestionMethod::NixArchive : FileIngestionMethod::Flat;
|
||||||
auto path = THIS->store->makeFixedOutputPath(name, FixedOutputInfo {
|
auto path = THIS->store->makeFixedOutputPath(name, FixedOutputInfo {
|
||||||
.method = method,
|
.method = method,
|
||||||
.hash = h,
|
.hash = h,
|
||||||
|
|
|
@ -91,7 +91,7 @@ CHARACTERIZATION_TEST(
|
||||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||||
},
|
},
|
||||||
ContentAddress {
|
ContentAddress {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -12,7 +12,7 @@ TEST(ContentAddressMethod, testRoundTripPrintParse_1) {
|
||||||
for (const ContentAddressMethod & cam : {
|
for (const ContentAddressMethod & cam : {
|
||||||
ContentAddressMethod { TextIngestionMethod {} },
|
ContentAddressMethod { TextIngestionMethod {} },
|
||||||
ContentAddressMethod { FileIngestionMethod::Flat },
|
ContentAddressMethod { FileIngestionMethod::Flat },
|
||||||
ContentAddressMethod { FileIngestionMethod::Recursive },
|
ContentAddressMethod { FileIngestionMethod::NixArchive },
|
||||||
ContentAddressMethod { FileIngestionMethod::Git },
|
ContentAddressMethod { FileIngestionMethod::Git },
|
||||||
}) {
|
}) {
|
||||||
EXPECT_EQ(ContentAddressMethod::parse(cam.render()), cam);
|
EXPECT_EQ(ContentAddressMethod::parse(cam.render()), cam);
|
||||||
|
|
|
@ -117,7 +117,7 @@ TEST_JSON(DerivationTest, caFixedFlat,
|
||||||
TEST_JSON(DerivationTest, caFixedNAR,
|
TEST_JSON(DerivationTest, caFixedNAR,
|
||||||
(DerivationOutput::CAFixed {
|
(DerivationOutput::CAFixed {
|
||||||
.ca = {
|
.ca = {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@ -133,7 +133,7 @@ TEST_JSON(DynDerivationTest, caFixedText,
|
||||||
|
|
||||||
TEST_JSON(CaDerivationTest, caFloating,
|
TEST_JSON(CaDerivationTest, caFloating,
|
||||||
(DerivationOutput::CAFloating {
|
(DerivationOutput::CAFloating {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hashAlgo = HashAlgorithm::SHA256,
|
.hashAlgo = HashAlgorithm::SHA256,
|
||||||
}),
|
}),
|
||||||
"drv-name", "output-name")
|
"drv-name", "output-name")
|
||||||
|
@ -144,7 +144,7 @@ TEST_JSON(DerivationTest, deferred,
|
||||||
|
|
||||||
TEST_JSON(ImpureDerivationTest, impure,
|
TEST_JSON(ImpureDerivationTest, impure,
|
||||||
(DerivationOutput::Impure {
|
(DerivationOutput::Impure {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hashAlgo = HashAlgorithm::SHA256,
|
.hashAlgo = HashAlgorithm::SHA256,
|
||||||
}),
|
}),
|
||||||
"drv-name", "output-name")
|
"drv-name", "output-name")
|
||||||
|
|
|
@ -25,7 +25,7 @@ static NarInfo makeNarInfo(const Store & store, bool includeImpureInfo) {
|
||||||
store,
|
store,
|
||||||
"foo",
|
"foo",
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
|
|
||||||
.references = {
|
.references = {
|
||||||
|
|
|
@ -32,7 +32,7 @@ static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo
|
||||||
store,
|
store,
|
||||||
"foo",
|
"foo",
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
|
|
||||||
.references = {
|
.references = {
|
||||||
|
|
|
@ -63,7 +63,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||||
},
|
},
|
||||||
ContentAddress {
|
ContentAddress {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
@ -280,7 +280,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
*LibStoreTest::store,
|
*LibStoreTest::store,
|
||||||
"foo",
|
"foo",
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
.references = {
|
.references = {
|
||||||
.others = {
|
.others = {
|
||||||
|
|
|
@ -64,7 +64,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||||
},
|
},
|
||||||
ContentAddress {
|
ContentAddress {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
@ -512,7 +512,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
*LibStoreTest::store,
|
*LibStoreTest::store,
|
||||||
"foo",
|
"foo",
|
||||||
FixedOutputInfo {
|
FixedOutputInfo {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::NixArchive,
|
||||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||||
.references = {
|
.references = {
|
||||||
.others = {
|
.others = {
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace nix {
|
||||||
TEST(FileSerialisationMethod, testRoundTripPrintParse_1) {
|
TEST(FileSerialisationMethod, testRoundTripPrintParse_1) {
|
||||||
for (const FileSerialisationMethod fim : {
|
for (const FileSerialisationMethod fim : {
|
||||||
FileSerialisationMethod::Flat,
|
FileSerialisationMethod::Flat,
|
||||||
FileSerialisationMethod::Recursive,
|
FileSerialisationMethod::NixArchive,
|
||||||
}) {
|
}) {
|
||||||
EXPECT_EQ(parseFileSerialisationMethod(renderFileSerialisationMethod(fim)), fim);
|
EXPECT_EQ(parseFileSerialisationMethod(renderFileSerialisationMethod(fim)), fim);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException) {
|
||||||
TEST(FileIngestionMethod, testRoundTripPrintParse_1) {
|
TEST(FileIngestionMethod, testRoundTripPrintParse_1) {
|
||||||
for (const FileIngestionMethod fim : {
|
for (const FileIngestionMethod fim : {
|
||||||
FileIngestionMethod::Flat,
|
FileIngestionMethod::Flat,
|
||||||
FileIngestionMethod::Recursive,
|
FileIngestionMethod::NixArchive,
|
||||||
FileIngestionMethod::Git,
|
FileIngestionMethod::Git,
|
||||||
}) {
|
}) {
|
||||||
EXPECT_EQ(parseFileIngestionMethod(renderFileIngestionMethod(fim)), fim);
|
EXPECT_EQ(parseFileIngestionMethod(renderFileIngestionMethod(fim)), fim);
|
||||||
|
|
Loading…
Reference in a new issue