config: refactor with host image format set

This commit is contained in:
Gabriel Arazas 2022-11-30 08:34:52 +08:00
parent 997a0ee9aa
commit fa2509b578

View File

@ -313,6 +313,16 @@
# Our own modules.
++ extraModules;
};
# A set of images with their metadata that is usually built for usual
# purposes. The format used here is whatever formats nixos-generators
# support.
images = {
bootstrap.format = "install-iso";
graphical-installer.format = "install-iso";
plover.format = "gce";
void.format = "vm";
};
in
{
# Exposes only my library with the custom functions to make it easier to
@ -332,13 +342,10 @@
# modules.
networking.hostName = lib.mkOverride 2000 host';
})
(lib'.optionalAttrs (images ? host') inputs.nixos-generators.nixosModules.${images.${host'}.format})
hostSharedConfig
path
]
++ lib'.optional (host' == "bootstrap") inputs.nixos-generators.nixosModules.install-iso
++ lib'.optional (host' == "graphical-installer") inputs.nixos-generators.nixosModules.install-iso
++ lib'.optional (host' == "plover") inputs.nixos-generators.nixosModules.gce
++ lib'.optional (host' == "void") inputs.nixos-generators.nixosModules.vm;
];
in
mkHost { inherit extraModules; })
(lib'.filesToAttr ./hosts);
@ -383,15 +390,6 @@
# "x86_64-linux". I just want to try out supporting other systems.
packages = forAllSystems (system: let
pkgs = import nixpkgs { inherit system overlays; };
# A set of images with their metadata that is usually built for usual
# purposes.
images = {
bootstrap.format = "install-iso";
graphical-installer.format = "install-iso";
plover.format = "gce";
void.format = "vm";
};
in
inputs.flake-utils.lib.flattenTree (import ./pkgs { inherit pkgs; })
// lib'.mapAttrs'