core/lib/tests/modules/define-variant.nix

28 lines
792 B
Nix
Raw Normal View History

2024-05-01 22:14:04 +00:00
{ config, lib, ... }:
2024-06-30 08:16:52 +00:00
let
inherit (lib) types mkOption attrNames;
2024-05-01 22:14:04 +00:00
in
{
options = {
attrs = mkOption { type = types.attrsOf lib.types.int; };
result = mkOption { };
resultFoo = mkOption { };
resultFooBar = mkOption { };
resultFooFoo = mkOption { };
};
config = {
attrs.a = 1;
variants.foo.attrs.b = 1;
variants.bar.attrs.y = 1;
variants.foo.variants.bar.attrs.z = 1;
variants.foo.variants.foo.attrs.c = 3;
resultFoo = lib.concatMapStringsSep " " toString (attrNames config.variants.foo.attrs);
2024-06-30 08:16:52 +00:00
resultFooBar = lib.concatMapStringsSep " " toString (
attrNames config.variants.foo.variants.bar.attrs
);
resultFooFoo = lib.concatMapStringsSep " " toString (
attrNames config.variants.foo.variants.foo.attrs
);
2024-05-01 22:14:04 +00:00
};
}