mirror of
https://gitlab.com/rensa-nix/core.git
synced 2026-02-01 23:05:08 +01:00
fix(loader): infinite recursion error when accessing sibling blocks
eg. accessing/returning `cell.b` (cell/b.nix) from cell/a.nix would cause infinite recursion. That's now fixed
This commit is contained in:
parent
558066d8df
commit
0d6970d95a
3 changed files with 24 additions and 1 deletions
|
|
@ -128,9 +128,27 @@
|
|||
inherit (utils) unique accumulate;
|
||||
|
||||
loadCell = cellName: let
|
||||
cell = res.output;
|
||||
cellP = paths.cellPath cellsFrom cellName;
|
||||
cellBlocks' = (unique cellBlocks).result;
|
||||
# fixes `ìnfinite recursion` errors when accessing cell attributes from sibling blocks
|
||||
# example: cells/test/a.nix returns `cell.b`, so the same thing as cells/test/b.nix.
|
||||
# this would previously fail with infinite recursion, this makes it work:
|
||||
cell = l.listToAttrs (l.concatMap (
|
||||
block: let
|
||||
blockP = paths.cellBlockPath cellP block;
|
||||
exists = l.pathExists blockP.file || l.pathExists blockP.dir;
|
||||
in
|
||||
if exists
|
||||
then [
|
||||
{
|
||||
name = block.name;
|
||||
# accessing this value will force the loading of this block
|
||||
value = (l.head (loadCellBlock cellName cellP block)).${block.name};
|
||||
}
|
||||
]
|
||||
else []
|
||||
)
|
||||
cellBlocks');
|
||||
loadCellBlock = createCellBlockLoader {inherit inputs system cells cell transformInputs;};
|
||||
res = accumulate (l.map (loadCellBlock cellName cellP) cellBlocks');
|
||||
in [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue