Skip to content

Commit

Permalink
fix(build): fluidattacks#546 infinite recursion on inputs.self
Browse files Browse the repository at this point in the history
- Assignments involving `self` are only allowed on the right hand side
  of an output. `evaluatedOutputs` violated this axiom.
- Ther reason lies within the recursiveness of these two lines in the
  builtin flake eval:

https://github.com/NixOS/nix/blob/7c90552879da4d1df99b50c85e94201981e60123/src/libexpr/flake/call-flake.nix#L44-L46

fixes: fluidattacks#573
  • Loading branch information
blaggacao committed Sep 17, 2021
1 parent eb50bdf commit be5ab07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
};
evaluatedOutputs = nixpkgs.lib.mapAttrs'
(output: value: {
name = "makes:config:outputs:${output}";
name = "config:outputs:${output}";
inherit value;
})
evaluated.config.outputs;
in
evaluatedOutputs // {
"makes:config:attrs" = evaluated.config.attrs;
"makes:config:cacheAsJson" = evaluated.config.cacheAsJson;
{
__makes__ = evaluatedOutputs // {
"config:attrs" = evaluated.config.attrs;
"config:cacheAsJson" = evaluated.config.cacheAsJson;
};
};
};
}
6 changes: 3 additions & 3 deletions src/cli/main/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def _get_attrs(src: str, head: str) -> List[str]:
args=_nix_build(
attr="config.attrs"
if NIX_STABLE
else f'{head}#"makes:config:attrs"',
else f'{head}#__makes__."config:attrs"',
cache=None,
head=head,
out=out,
Expand All @@ -235,7 +235,7 @@ def _get_cache(src: str, head: str) -> List[Dict[str, str]]:
args=_nix_build(
attr="config.cacheAsJson"
if NIX_STABLE
else f'{head}#"makes:config:cacheAsJson"',
else f'{head}#__makes__."config:cacheAsJson"',
cache=None,
head=head,
out=out,
Expand Down Expand Up @@ -346,7 +346,7 @@ def cli(args: List[str]) -> None:
args=_nix_build(
attr=f'config.outputs."{attr}"'
if NIX_STABLE
else f'{head}#makes:config:outputs:"{attr}"',
else f'{head}#__makes__."config:outputs:{attr}"',
cache=cache,
head=head,
out=out,
Expand Down

0 comments on commit be5ab07

Please sign in to comment.