|
| 1 | +{ lib, targetLib, ... }: |
| 2 | +{ |
| 3 | + # This test verifies that we can define aspects inside |
| 4 | + # an scope and then merge them in another scope. |
| 5 | + # |
| 6 | + # This is important for Den social aspects, since people will |
| 7 | + # try to merge aspects from different sources, local, and remote flakes. |
| 8 | + flake.tests."test-assign-aspects-on-scopes" = |
| 9 | + let |
| 10 | + flake-aspects-lib = import targetLib lib; |
| 11 | + |
| 12 | + first = lib.evalModules { |
| 13 | + modules = [ |
| 14 | + # each scope creates a new <name>.aspects tree. |
| 15 | + (flake-aspects-lib.new-scope "foo") |
| 16 | + (flake-aspects-lib.new-scope "bar") |
| 17 | + (flake-aspects-lib.new-scope "baz") |
| 18 | + # create a._.b._.c aspect on each namespace |
| 19 | + # we will be trying to merge them for this test. |
| 20 | + { |
| 21 | + foo.aspects.a._.b._.c.nixos.x = [ "foo" ]; |
| 22 | + } |
| 23 | + { |
| 24 | + bar.aspects.a._.b._.c.nixos.x = [ "bar" ]; |
| 25 | + } |
| 26 | + { |
| 27 | + baz.aspects.a._.b._.c.nixos.x = [ "baz" ]; |
| 28 | + } |
| 29 | + ( |
| 30 | + { config, ... }: |
| 31 | + { |
| 32 | + bar = config.foo; # bar merges all of foo |
| 33 | + } |
| 34 | + ) |
| 35 | + ( |
| 36 | + { config, ... }: |
| 37 | + { |
| 38 | + baz = config.bar; # baz merges all of baz |
| 39 | + } |
| 40 | + ) |
| 41 | + ]; |
| 42 | + }; |
| 43 | + |
| 44 | + second = lib.evalModules { |
| 45 | + modules = [ |
| 46 | + # We evaluate the abc nixos module from baz |
| 47 | + first.config.baz.aspects.a._.b._.c.modules.nixos |
| 48 | + # create the options to merge all different values |
| 49 | + { options.x = lib.mkOption { type = lib.types.listOf lib.types.str; }; } |
| 50 | + ]; |
| 51 | + }; |
| 52 | + |
| 53 | + expr = second.config.x; |
| 54 | + expected = [ |
| 55 | + "foo" |
| 56 | + "bar" |
| 57 | + "baz" |
| 58 | + ]; |
| 59 | + in |
| 60 | + { |
| 61 | + inherit expected expr; |
| 62 | + }; |
| 63 | + |
| 64 | +} |
0 commit comments