feat(readTree): Add special here argument.
It's convenient for depending on sub-tree members of the current file as well as gives access to siblings. Change-Id: I74234cec6566177d88d3bc8507fa3f6ec789adb8 Reviewed-on: https://cl.snix.dev/c/snix/+/30098 Reviewed-by: adis bladis <adisbladis@gmail.com> Tested-by: besadii
This commit is contained in:
parent
39b3e2c410
commit
a04c73ca83
7 changed files with 39 additions and 15 deletions
|
|
@ -134,6 +134,13 @@ let
|
|||
(assertEq "default.nix drv is not changed by readTree"
|
||||
tree-tl.default-nix.can-be-drv
|
||||
(import ./test-tree-traversal/default-nix/can-be-drv/default.nix { }))
|
||||
(assertEq "`here` argument represents the attrset a given file is part of"
|
||||
(builtins.removeAttrs tree-tl.here-arg [ "__readTree" "__readTreeChildren" "subdir" ])
|
||||
{
|
||||
attr1 = "foo";
|
||||
attr2 = "foo";
|
||||
attr3 = "sibl1";
|
||||
})
|
||||
];
|
||||
|
||||
# these each call readTree themselves because the throws have to happen inside assertThrows
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
{ here, ... }: {
|
||||
attr1 = "foo";
|
||||
attr2 = here.attr1;
|
||||
|
||||
attr3 = here.subdir.sibl2;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ ... }: "sibl1"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
{ here, ... }:
|
||||
here.sibl1
|
||||
Loading…
Add table
Add a link
Reference in a new issue