mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
45 lines
892 B
Nix
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; };
|
|
}
|
|
)
|
|
];
|
|
}
|