Skip to content

Commit

Permalink
Move follows-check into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma27 committed Jul 12, 2022
1 parent 411111a commit 1f77106
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions src/libexpr/flake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,26 +353,15 @@ LockedFlake lockFlake(
std::vector<FlakeRef> parents;

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;
const FlakeInputs & flakeInputs
)>
checkFollowsDeclarations;

computeLocks = [&](
const FlakeInputs & flakeInputs,
std::shared_ptr<Node> node,
checkFollowsDeclarations = [&](
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));

const FlakeInputs & flakeInputs
) {
for (auto [inputPath, inputOverride] : overrides) {
auto inputPath2(inputPath);
auto follow = inputPath2.back();
Expand All @@ -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
'inputs.nixops.inputs.nixpkgs.url = ...'). */
Expand Down

0 comments on commit 1f77106

Please sign in to comment.