flake-parts/setups/nixos: add shouldbePartOfNixOSConfigurations

This allows explicitly including a NixOS config even with the unfulfilled
conditions. With deploy-rs nodes, they're pretty specific so we'll opt for
this solution.
This commit is contained in:
Gabriel Arazas 2024-02-28 18:47:43 +08:00
parent cf64ff7490
commit 22e3a09243
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -323,6 +323,16 @@ let
the NixOS configuration.
'';
};
shouldBePartOfNixOSConfigurations = lib.mkOption {
type = lib.types.bool;
default = lib.isAttrs config.deploy || config.formats == null;
example = true;
description = ''
Indicates whether the declarative NixOS setup should be included as
part of the `nixosConfigurations` flake output.
'';
};
};
config.modules = [
@ -571,7 +581,7 @@ in
pureNixosConfigs =
let
validConfigs =
lib.filterAttrs (_: v: v.formats == null || v.deploy != null) cfg.configs;
lib.filterAttrs (_: v: v.shouldBePartOfNixOSConfigurations) cfg.configs;
generatePureConfigs = hostname: metadata:
lib.listToAttrs