The workaround is no longer needed since Nixpkgs 22.05 (https://github.com/NixOS/nixpkgs/pull/156533). Declaring options directly in a submodule now works, e.g. `options.flake.foo`. The function is kept for backwards compatibility but documented as deprecated. The minimum supported Nixpkgs lib version is already 22.05, so this change does not drop support for any previously supported version.
36 lines
1 KiB
Nix
36 lines
1 KiB
Nix
{ lib, ... }:
|
|
let
|
|
inherit (lib)
|
|
mkOption
|
|
types
|
|
literalExpression
|
|
;
|
|
in
|
|
{
|
|
options = {
|
|
flake.nixosConfigurations = mkOption {
|
|
type = types.lazyAttrsOf types.raw;
|
|
default = { };
|
|
description = ''
|
|
Instantiated NixOS configurations. Used by `nixos-rebuild`.
|
|
|
|
`nixosConfigurations` is for specific machines. If you want to expose
|
|
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
|
|
in the form of modules (no `lib.nixosSystem`), so that you can reference
|
|
them in this or another flake's `nixosConfigurations`.
|
|
'';
|
|
example = literalExpression ''
|
|
{
|
|
my-machine = inputs.nixpkgs.lib.nixosSystem {
|
|
# system is not needed with freshly generated hardware-configuration.nix
|
|
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
|
|
modules = [
|
|
./my-machine/nixos-configuration.nix
|
|
config.nixosModules.my-module
|
|
];
|
|
};
|
|
}
|
|
'';
|
|
};
|
|
};
|
|
}
|