nixos-generators/checks/test-customize-format.nix
DavHau f4a79d08d7 feat(all-formats.nix): add formatConfigs
While the `all-formats.nix` module allows to import all formats at once, it lacks an interface to customize formats or add formats.

This is fixed by adding the top-level option `formatConfigs` (attrsOf deferredModule).

All format modules created under `config.formatConfigs` are mapped so their outputs are available under `config.formats` which has also been moved to the top-level (previously `config.system.formats`).

Done:
- add option `formatConfigs`
- move option `system.formats` -> `formats`
- add test for customizing a format
2023-07-03 11:54:20 +03:00

28 lines
610 B
Nix

{
nixpkgs ? <nixpkgs>,
system ? builtins.currentSystem,
lib ? import (nixpkgs + /lib),
}: let
nixosSystem = import (nixpkgs + /nixos/lib/eval-config.nix);
userModule1 = {...}: {
formatConfigs.amazon.amazonImage.name = "xyz";
};
userModule2 = {...}: {
formatConfigs.amazon.amazonImage.name = lib.mkForce "custom-name";
};
conf = nixosSystem {
inherit system;
modules = [
../configuration.nix
../all-formats.nix
userModule1
userModule2
];
};
in
assert lib.hasInfix "custom-name" "${conf.config.formats.amazon}";
conf.config.formats.amazon