nixpkgs/lib/tests/modules/lazy-attrsWith.nix
2024-12-03 10:02:40 +01:00

45 lines
892 B
Nix

# Check that AttrsWith { lazy = true; } is lazy
{ lib, ... }:
let
inherit (lib) types mkOption;
in
{
imports = [
# Module A
(
{ ... }:
{
options.mergedLazy = mkOption {
# Same as lazyAttrsOf
type = types.attrsWith {
lazy = true;
elemType = types.int;
};
};
}
)
# Module B
(
{ ... }:
{
options.mergedLazy = lib.mkOption {
# Same as lazyAttrsOf
type = types.attrsWith {
lazy = true;
elemType = types.int;
};
};
}
)
# Result
(
{ config, ... }:
{
# Can only evaluate if lazy
config.mergedLazy.bar = config.mergedLazy.baz + 1;
config.mergedLazy.baz = 10;
options.result = mkOption { default = config.mergedLazy.bar; };
}
)
];
}