mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-20 16:39:31 +03:00
46 lines
892 B
Nix
46 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; };
|
||
|
}
|
||
|
)
|
||
|
];
|
||
|
}
|