mirror of
https://github.com/NixOS/nix
synced 2025-07-06 13:21:47 +02:00
Checkpoint
This commit is contained in:
parent
e827e6288f
commit
3ec83565b1
11 changed files with 116 additions and 39 deletions
|
@ -2070,14 +2070,14 @@ std::string EvalState::copyPathToStore(PathSet & context, const Path & path)
|
|||
auto path2 = unpackPath(path);
|
||||
#if 0
|
||||
auto p = settings.readOnlyMode
|
||||
? store->computeStorePathForPath(std::string(baseNameOf(path)), canonPath(path)).first
|
||||
: store->addToStore(std::string(baseNameOf(path)), canonPath(path), FileIngestionMethod::Recursive, htSHA256, defaultPathFilter, repair);
|
||||
? store->computeStorePathForPath(path2.baseName(), canonPath(path)).first
|
||||
: store->addToStore(path2.baseName(), canonPath(path), FileIngestionMethod::Recursive, htSHA256, defaultPathFilter, repair);
|
||||
#endif
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
path2.accessor->dumpPath(path2.path, sink);
|
||||
});
|
||||
// FIXME: readOnlyMode
|
||||
auto p = store->addToStoreFromDump(*source, std::string(baseNameOf(path)), FileIngestionMethod::Recursive, htSHA256, repair);
|
||||
auto p = store->addToStoreFromDump(*source, path2.baseName(), FileIngestionMethod::Recursive, htSHA256, repair);
|
||||
dstPath = store->printStorePath(p);
|
||||
allowPath(p);
|
||||
srcToStore.insert_or_assign(path, std::move(p));
|
||||
|
|
|
@ -209,7 +209,7 @@ static Flake getFlake(
|
|||
.originalRef = originalRef,
|
||||
.resolvedRef = resolvedRef,
|
||||
.lockedRef = lockedRef,
|
||||
.sourceInfo = std::make_shared<fetchers::Tree>(std::move(sourceInfo))
|
||||
//.sourceInfo = std::make_shared<fetchers::Tree>(std::move(sourceInfo))
|
||||
};
|
||||
|
||||
if (!pathExists(flakeFile))
|
||||
|
@ -326,6 +326,7 @@ LockedFlake lockFlake(
|
|||
state.store->setOptions();
|
||||
}
|
||||
|
||||
#if 0
|
||||
try {
|
||||
|
||||
// FIXME: symlink attack
|
||||
|
@ -669,6 +670,9 @@ LockedFlake lockFlake(
|
|||
e.addTrace({}, "while updating the lock file of flake '%s'", flake.lockedRef.to_string());
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
|
||||
throw UnimplementedError("lockFlake");
|
||||
}
|
||||
|
||||
void callFlake(EvalState & state,
|
||||
|
@ -683,13 +687,17 @@ void callFlake(EvalState & state,
|
|||
|
||||
vLocks->mkString(lockedFlake.lockFile.to_string());
|
||||
|
||||
#if 0
|
||||
emitTreeAttrs(
|
||||
state,
|
||||
*lockedFlake.flake.sourceInfo,
|
||||
//*lockedFlake.flake.sourceInfo,
|
||||
lockedFlake.flake.lockedRef.input,
|
||||
*vRootSrc,
|
||||
false,
|
||||
lockedFlake.flake.forceDirty);
|
||||
#endif
|
||||
|
||||
throw UnimplementedError("callFlake");
|
||||
|
||||
vRootSubdir->mkString(lockedFlake.flake.lockedRef.subdir);
|
||||
|
||||
|
@ -756,7 +764,8 @@ Fingerprint LockedFlake::getFingerprint() const
|
|||
// flake.sourceInfo.storePath for the fingerprint.
|
||||
return hashString(htSHA256,
|
||||
fmt("%s;%s;%d;%d;%s",
|
||||
flake.sourceInfo->storePath.to_string(),
|
||||
"FIXME",
|
||||
//flake.sourceInfo->storePath.to_string(),
|
||||
flake.lockedRef.subdir,
|
||||
flake.lockedRef.input.getRevCount().value_or(0),
|
||||
flake.lockedRef.input.getLastModified().value_or(0),
|
||||
|
|
|
@ -63,7 +63,6 @@ struct Flake
|
|||
FlakeRef lockedRef; // the specific local store result of invoking the fetcher
|
||||
bool forceDirty = false; // pretend that 'lockedRef' is dirty
|
||||
std::optional<std::string> description;
|
||||
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
||||
FlakeInputs inputs;
|
||||
ConfigFile config; // 'nixConfig' attribute
|
||||
~Flake();
|
||||
|
@ -139,7 +138,7 @@ void callFlake(
|
|||
|
||||
void emitTreeAttrs(
|
||||
EvalState & state,
|
||||
const fetchers::Tree & tree,
|
||||
const SourcePath & path,
|
||||
const fetchers::Input & input,
|
||||
Value & v,
|
||||
bool emptyRevFallback = false,
|
||||
|
|
|
@ -16,15 +16,14 @@ Path EvalState::packPath(const SourcePath & path)
|
|||
|
||||
SourcePath EvalState::unpackPath(const Path & path)
|
||||
{
|
||||
printError("UNPACK %s", path);
|
||||
if (hasPrefix(path, marker)) {
|
||||
auto s = path.substr(marker.size());
|
||||
auto slash = s.find('/');
|
||||
assert(slash != s.npos);
|
||||
auto n = std::stoi(s.substr(0, slash));
|
||||
printError("GOT %d", n);
|
||||
auto i = inputAccessors.find(n);
|
||||
assert(i != inputAccessors.end());
|
||||
return {i->second, s.substr(slash)};
|
||||
return {i->second, slash != std::string::npos ? s.substr(slash) : "/"};
|
||||
} else {
|
||||
printError("FIXME: %s", path);
|
||||
return rootPath(path);
|
||||
|
|
|
@ -13,25 +13,32 @@ namespace nix {
|
|||
|
||||
void emitTreeAttrs(
|
||||
EvalState & state,
|
||||
const fetchers::Tree & tree,
|
||||
const SourcePath & path,
|
||||
const fetchers::Input & input,
|
||||
Value & v,
|
||||
bool emptyRevFallback,
|
||||
bool forceDirty)
|
||||
{
|
||||
assert(input.isLocked());
|
||||
// FIXME?
|
||||
//assert(input.isLocked());
|
||||
|
||||
auto attrs = state.buildBindings(8);
|
||||
|
||||
#if 0
|
||||
auto storePath = state.store->printStorePath(tree.storePath);
|
||||
|
||||
attrs.alloc(state.sOutPath).mkString(storePath, {storePath});
|
||||
#endif
|
||||
|
||||
attrs.alloc(state.sOutPath).mkPath(state.packPath(path));
|
||||
|
||||
// FIXME: support arbitrary input attributes.
|
||||
|
||||
#if 0
|
||||
auto narHash = input.getNarHash();
|
||||
assert(narHash);
|
||||
attrs.alloc("narHash").mkString(narHash->to_string(SRI, true));
|
||||
#endif
|
||||
|
||||
if (input.getType() == "git")
|
||||
attrs.alloc("submodules").mkBool(
|
||||
|
@ -169,11 +176,17 @@ static void fetchTree(
|
|||
if (evalSettings.pureEval && !input.isLocked())
|
||||
throw Error("in pure evaluation mode, 'fetchTree' requires a locked input, at %s", pos);
|
||||
|
||||
auto [tree, input2] = input.fetch(state.store);
|
||||
auto [accessor, input2] = input.lazyFetch(state.store);
|
||||
|
||||
state.allowPath(tree.storePath);
|
||||
//state.allowPath(tree.storePath);
|
||||
|
||||
emitTreeAttrs(state, tree, input2, v, params.emptyRevFallback, false);
|
||||
emitTreeAttrs(
|
||||
state,
|
||||
{accessor, "/"},
|
||||
input2,
|
||||
v,
|
||||
params.emptyRevFallback,
|
||||
false);
|
||||
}
|
||||
|
||||
static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue