mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
Rename makeFSSourceAccessor -> getFSSourceAccessor()
This makes it clearer that it returns a shared accessor object.
This commit is contained in:
parent
eab2919119
commit
ef28c7329c
7 changed files with 17 additions and 14 deletions
|
@ -146,7 +146,7 @@ MixFlakeOptions::MixFlakeOptions()
|
||||||
.category = category,
|
.category = category,
|
||||||
.labels = {"flake-lock-path"},
|
.labels = {"flake-lock-path"},
|
||||||
.handler = {[&](std::string lockFilePath) {
|
.handler = {[&](std::string lockFilePath) {
|
||||||
lockFlags.referenceLockFilePath = {makeFSSourceAccessor(), CanonPath(absPath(lockFilePath))};
|
lockFlags.referenceLockFilePath = {getFSSourceAccessor(), CanonPath(absPath(lockFilePath))};
|
||||||
}},
|
}},
|
||||||
.completer = completePath
|
.completer = completePath
|
||||||
});
|
});
|
||||||
|
|
|
@ -399,14 +399,14 @@ EvalState::EvalState(
|
||||||
, emptyBindings(0)
|
, emptyBindings(0)
|
||||||
, rootFS(
|
, rootFS(
|
||||||
evalSettings.restrictEval || evalSettings.pureEval
|
evalSettings.restrictEval || evalSettings.pureEval
|
||||||
? ref<SourceAccessor>(AllowListSourceAccessor::create(makeFSSourceAccessor(), {},
|
? ref<SourceAccessor>(AllowListSourceAccessor::create(getFSSourceAccessor(), {},
|
||||||
[](const CanonPath & path) -> RestrictedPathError {
|
[](const CanonPath & path) -> RestrictedPathError {
|
||||||
auto modeInformation = evalSettings.pureEval
|
auto modeInformation = evalSettings.pureEval
|
||||||
? "in pure evaluation mode (use '--impure' to override)"
|
? "in pure evaluation mode (use '--impure' to override)"
|
||||||
: "in restricted mode";
|
: "in restricted mode";
|
||||||
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
||||||
}))
|
}))
|
||||||
: makeFSSourceAccessor())
|
: getFSSourceAccessor())
|
||||||
, corepkgsFS(make_ref<MemorySourceAccessor>())
|
, corepkgsFS(make_ref<MemorySourceAccessor>())
|
||||||
, internalFS(make_ref<MemorySourceAccessor>())
|
, internalFS(make_ref<MemorySourceAccessor>())
|
||||||
, derivationInternal{corepkgsFS->addFile(
|
, derivationInternal{corepkgsFS->addFile(
|
||||||
|
|
|
@ -212,7 +212,7 @@ struct MercurialInputScheme : InputScheme
|
||||||
|
|
||||||
auto storePath = store->addToStore(
|
auto storePath = store->addToStore(
|
||||||
input.getName(),
|
input.getName(),
|
||||||
{makeFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
FileIngestionMethod::Recursive, HashAlgorithm::SHA256, {},
|
FileIngestionMethod::Recursive, HashAlgorithm::SHA256, {},
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ struct MercurialInputScheme : InputScheme
|
||||||
|
|
||||||
deletePath(tmpDir + "/.hg_archival.txt");
|
deletePath(tmpDir + "/.hg_archival.txt");
|
||||||
|
|
||||||
auto storePath = store->addToStore(name, {makeFSSourceAccessor(), CanonPath(tmpDir)});
|
auto storePath = store->addToStore(name, {getFSSourceAccessor(), CanonPath(tmpDir)});
|
||||||
|
|
||||||
Attrs infoAttrs({
|
Attrs infoAttrs({
|
||||||
{"rev", input.getRev()->gitRev()},
|
{"rev", input.getRev()->gitRev()},
|
||||||
|
|
|
@ -2492,7 +2492,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
HashModuloSink caSink { outputHash.hashAlgo, oldHashPart };
|
HashModuloSink caSink { outputHash.hashAlgo, oldHashPart };
|
||||||
auto fim = outputHash.method.getFileIngestionMethod();
|
auto fim = outputHash.method.getFileIngestionMethod();
|
||||||
dumpPath(
|
dumpPath(
|
||||||
{makeFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
caSink,
|
caSink,
|
||||||
(FileSerialisationMethod) fim);
|
(FileSerialisationMethod) fim);
|
||||||
return caSink.finish().first;
|
return caSink.finish().first;
|
||||||
|
@ -2500,7 +2500,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
case FileIngestionMethod::Git: {
|
case FileIngestionMethod::Git: {
|
||||||
return git::dumpHash(
|
return git::dumpHash(
|
||||||
outputHash.hashAlgo,
|
outputHash.hashAlgo,
|
||||||
{makeFSSourceAccessor(), CanonPath(tmpDir + "/tmp")}).hash;
|
{getFSSourceAccessor(), CanonPath(tmpDir + "/tmp")}).hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -2528,7 +2528,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
|
|
||||||
{
|
{
|
||||||
HashResult narHashAndSize = hashPath(
|
HashResult narHashAndSize = hashPath(
|
||||||
{makeFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
||||||
newInfo0.narHash = narHashAndSize.first;
|
newInfo0.narHash = narHashAndSize.first;
|
||||||
newInfo0.narSize = narHashAndSize.second;
|
newInfo0.narSize = narHashAndSize.second;
|
||||||
|
@ -2551,7 +2551,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
|
||||||
std::string { requiredFinalPath.hashPart() });
|
std::string { requiredFinalPath.hashPart() });
|
||||||
rewriteOutput(outputRewrites);
|
rewriteOutput(outputRewrites);
|
||||||
HashResult narHashAndSize = hashPath(
|
HashResult narHashAndSize = hashPath(
|
||||||
{makeFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
FileSerialisationMethod::Recursive, HashAlgorithm::SHA256);
|
||||||
ValidPathInfo newInfo0 { requiredFinalPath, narHashAndSize.first };
|
ValidPathInfo newInfo0 { requiredFinalPath, narHashAndSize.first };
|
||||||
newInfo0.narSize = narHashAndSize.second;
|
newInfo0.narSize = narHashAndSize.second;
|
||||||
|
|
|
@ -1252,7 +1252,7 @@ StorePath LocalStore::addToStoreFromDump(
|
||||||
methodsMatch
|
methodsMatch
|
||||||
? dumpHash
|
? dumpHash
|
||||||
: hashPath(
|
: hashPath(
|
||||||
{makeFSSourceAccessor(), CanonPath(tempPath)},
|
{getFSSourceAccessor(), CanonPath(tempPath)},
|
||||||
hashMethod.getFileIngestionMethod(), hashAlgo),
|
hashMethod.getFileIngestionMethod(), hashAlgo),
|
||||||
{
|
{
|
||||||
.others = references,
|
.others = references,
|
||||||
|
@ -1392,7 +1392,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
Path linkPath = linksDir + "/" + link.name;
|
Path linkPath = linksDir + "/" + link.name;
|
||||||
PosixSourceAccessor accessor;
|
PosixSourceAccessor accessor;
|
||||||
std::string hash = hashPath(
|
std::string hash = hashPath(
|
||||||
{makeFSSourceAccessor(), CanonPath(linkPath)},
|
{getFSSourceAccessor(), CanonPath(linkPath)},
|
||||||
FileIngestionMethod::Recursive, HashAlgorithm::SHA256).to_string(HashFormat::Nix32, false);
|
FileIngestionMethod::Recursive, HashAlgorithm::SHA256).to_string(HashFormat::Nix32, false);
|
||||||
if (hash != link.name) {
|
if (hash != link.name) {
|
||||||
printError("link '%s' was modified! expected hash '%s', got '%s'",
|
printError("link '%s' was modified! expected hash '%s', got '%s'",
|
||||||
|
|
|
@ -167,7 +167,7 @@ void PosixSourceAccessor::assertNoSymlinks(CanonPath path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<SourceAccessor> makeFSSourceAccessor()
|
ref<SourceAccessor> getFSSourceAccessor()
|
||||||
{
|
{
|
||||||
static auto rootFS = make_ref<PosixSourceAccessor>();
|
static auto rootFS = make_ref<PosixSourceAccessor>();
|
||||||
return rootFS;
|
return rootFS;
|
||||||
|
|
|
@ -197,10 +197,13 @@ MakeError(RestrictedPathError, Error);
|
||||||
/**
|
/**
|
||||||
* Return an accessor for the root filesystem.
|
* Return an accessor for the root filesystem.
|
||||||
*/
|
*/
|
||||||
ref<SourceAccessor> makeFSSourceAccessor();
|
ref<SourceAccessor> getFSSourceAccessor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an accessor for the filesystem rooted at `root`.
|
* Construct an accessor for the filesystem rooted at `root`. Note
|
||||||
|
* that it is not possible to escape `root` by appending `..` path
|
||||||
|
* elements, and that absolute symlinks are resolved relative to
|
||||||
|
* `root`.
|
||||||
*/
|
*/
|
||||||
ref<SourceAccessor> makeFSSourceAccessor(std::filesystem::path root);
|
ref<SourceAccessor> makeFSSourceAccessor(std::filesystem::path root);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue