nixpkgs/lib/tests/modules/types-anything/functions.nix
Rebecca Turner fa9727cf1e
lib: modules.sh should check JSON output for predictability
Currently, the `lib/tests/modules.sh` test checks the output of
`nix-instantiate --eval` without `--json`, which outputs an unspecified
human-readable format.

This patch modifies `modules.sh` to use the `--json` output instead, to
be robust against future changes to `nix-instantiate` output.
2023-12-19 09:23:09 -08:00

28 lines
592 B
Nix

{ lib, config, ... }: {
options.valueIsFunction = lib.mkOption {
default = lib.mapAttrs (name: lib.isFunction) config.value;
};
options.value = lib.mkOption {
type = lib.types.anything;
};
options.applied = lib.mkOption {
default = lib.mapAttrs (name: fun: fun null) config.value;
};
config = lib.mkMerge [
{
value.single-lambda = x: x;
value.multiple-lambdas = x: { inherit x; };
value.merging-lambdas = x: { inherit x; };
}
{
value.multiple-lambdas = x: [ x ];
value.merging-lambdas = y: { inherit y; };
}
];
}