mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-09-11 12:15:29 +03:00
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
28 lines
610 B
Nix
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
|