feat: build a much more minimal config for installing

This commit is contained in:
oddlama 2023-09-26 21:43:23 +02:00
parent 73897f648d
commit 73d7a42879
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
11 changed files with 136 additions and 113 deletions

View file

@ -12,15 +12,15 @@ inputs: let
;
# Creates a new nixosSystem with the correct specialArgs, pkgs and name definition
mkHost = name: system: let
pkgs = self.pkgs.${system};
mkHost = {minimal}: name: hostCfg: let
pkgs = self.pkgs.${hostCfg.system};
in
nixosSystem {
specialArgs = {
# Use the correct instance lib that has our overlays
inherit (pkgs) lib;
inherit (self) nodes;
inherit inputs;
inherit inputs minimal;
};
modules = [
{
@ -28,7 +28,7 @@ inputs: let
# inputs.nixpkgs.nixosModules.readOnlyPkgs, since some nixosModules
# like nixseparatedebuginfod depend on adding packages via nixpkgs.overlays.
# So we just mimic the options and overlays defined by the passed pkgs set.
nixpkgs.hostPlatform = system;
nixpkgs.hostPlatform = hostCfg.system;
nixpkgs.overlays = pkgs.overlays;
nixpkgs.config = pkgs.config;
node.name = name;
@ -45,7 +45,8 @@ inputs: let
# Get all hosts of type "nixos"
nixosHosts = filterAttrs (_: x: x.type == "nixos") hosts;
# Process each nixosHosts declaration and generatea nixosSystem definitions
nixosConfigurations = flip mapAttrs nixosHosts (name: hostCfg: mkHost name hostCfg.system);
nixosConfigurations = flip mapAttrs nixosHosts (mkHost {minimal = false;});
nixosConfigurationsMinimal = flip mapAttrs nixosHosts (mkHost {minimal = true;});
# True NixOS nodes can define additional microvms (guest nodes) that are built
# together with the true host. We collect all defined microvm nodes
@ -59,5 +60,6 @@ in {
hosts
microvmConfigurations
nixosConfigurations
nixosConfigurationsMinimal
;
}