Move follows-check into its own function

This commit is contained in:
Maximilian Bosch 2022-07-12 11:25:33 +02:00
parent 411111a3bc
commit 1f771065f1
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E

View file

@ -353,26 +353,15 @@ LockedFlake lockFlake(
std::vector<FlakeRef> parents; std::vector<FlakeRef> parents;
std::function<void( std::function<void(
const FlakeInputs & flakeInputs,
std::shared_ptr<Node> node,
const InputPath & inputPathPrefix, const InputPath & inputPathPrefix,
std::shared_ptr<const Node> oldNode, const FlakeInputs & flakeInputs
const InputPath & lockRootPath, )>
const Path & parentPath, checkFollowsDeclarations;
bool trustLock)>
computeLocks;
computeLocks = [&]( checkFollowsDeclarations = [&](
const FlakeInputs & flakeInputs,
std::shared_ptr<Node> node,
const InputPath & inputPathPrefix, const InputPath & inputPathPrefix,
std::shared_ptr<const Node> oldNode, const FlakeInputs & flakeInputs
const InputPath & lockRootPath, ) {
const Path & parentPath,
bool trustLock)
{
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
for (auto [inputPath, inputOverride] : overrides) { for (auto [inputPath, inputOverride] : overrides) {
auto inputPath2(inputPath); auto inputPath2(inputPath);
auto follow = inputPath2.back(); auto follow = inputPath2.back();
@ -394,6 +383,30 @@ LockedFlake lockFlake(
); );
} }
} }
};
std::function<void(
const FlakeInputs & flakeInputs,
std::shared_ptr<Node> node,
const InputPath & inputPathPrefix,
std::shared_ptr<const Node> oldNode,
const InputPath & lockRootPath,
const Path & parentPath,
bool trustLock)>
computeLocks;
computeLocks = [&](
const FlakeInputs & flakeInputs,
std::shared_ptr<Node> node,
const InputPath & inputPathPrefix,
std::shared_ptr<const Node> oldNode,
const InputPath & lockRootPath,
const Path & parentPath,
bool trustLock)
{
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
checkFollowsDeclarations(inputPathPrefix, flakeInputs);
/* Get the overrides (i.e. attributes of the form /* Get the overrides (i.e. attributes of the form
'inputs.nixops.inputs.nixpkgs.url = ...'). */ 'inputs.nixops.inputs.nixpkgs.url = ...'). */