nixos-config/modules/flake-parts/images.nix

47 lines
1.4 KiB
Nix
Raw Normal View History

2024-01-15 23:21:31 +00:00
# A custom flake-parts module to configure my NixOS images generated with
# nixos-generators. For more details, see the "Declarative hosts management"
# section from the documentation.
{ config, lib, flake-parts-lib, ... }:
2025-01-29 04:48:19 +00:00
let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption;
in {
2024-01-15 23:21:31 +00:00
options = {
flake = mkSubmoduleOptions {
images = lib.mkOption {
type = with lib.types; lazyAttrsOf (attrsOf package);
default = { };
description = ''
An attribute set of per-system NixOS configurations built as an image
output supported by
[nixos-generators](https://github.com/nix-community/nixos-generators).
This is exclusively used for foodogsquared's NixOS setup.
'';
};
};
perSystem = mkPerSystemOption {
options = {
images = lib.mkOption {
type = with lib.types; attrsOf package;
2024-01-16 07:19:51 +00:00
default = { };
2024-01-15 23:21:31 +00:00
description = ''
An attribute set of NixOS configurations built as an image output
supported by
[nixos-generators](https://github.com/nix-community/nixos-generators).
'';
};
};
};
};
config = {
2025-01-29 04:48:19 +00:00
flake.images = lib.mapAttrs (k: v: v.images)
(lib.filterAttrs (k: v: v.images != { }) config.allSystems);
2024-01-15 23:21:31 +00:00
perInput = system: flake:
lib.optionalAttrs (flake ? images.${system}) {
images = flake.images.${system};
};
};
}