NixOS system configurations + dotfiles via home-manager

hosts: refactor config generation

+20 -29
flake/hosts.nix
··· 1 + { inputs, config, ... }: 2 + let 3 + inherit (inputs.nixpkgs) lib; 4 + hostOptions = lib.types.submodule ( 5 + { name, config, ... }: 6 + { 7 + options.modules = lib.mkOption { 8 + default = [ 9 + { networking.hostName = name; } 10 + inputs.self.modules.nixos.core 11 + inputs.self.modules.nixos.${name} 12 + { local.home.imports = [ inputs.self.modules.homeManager.${name} or { } ]; } 13 + ]; 14 + }; 15 + options.nixos = lib.mkOption { default = lib.nixosSystem { inherit (config) modules; }; }; 16 + } 17 + ); 18 + in 1 19 { 2 - self, 3 - inputs, 4 - config, 5 - lib, 6 - withSystem, 7 - ... 8 - }: 9 - { 10 - options.local.hosts = lib.mkOption { 11 - type = lib.types.attrsOf ( 12 - lib.types.submodule { 13 - options.system = lib.mkOption { default = "x86_64-linux"; }; 14 - } 15 - ); 16 - }; 17 - 18 - config.flake.modules.nixos = builtins.mapAttrs (name: config: { 19 - imports = [ self.modules.nixos.core ]; 20 - networking.hostName = name; 21 - nixpkgs.system = config.system; 22 - nixpkgs.overlays = withSystem config.system ({ pkgs, ... }: pkgs.overlays); 23 - local.home.imports = [ 24 - (self.modules.homeManager.${name} or { }) 25 - ]; 26 - }) config.local.hosts; 27 - 28 - config.flake.nixosConfigurations = builtins.mapAttrs ( 29 - name: _: inputs.nixpkgs.lib.nixosSystem { modules = [ self.modules.nixos.${name} ]; } 30 - ) config.local.hosts; 20 + options.local.hosts = lib.mkOption { type = lib.types.attrsOf hostOptions; }; 21 + config.flake.nixosConfigurations = builtins.mapAttrs (_: host: host.nixos) config.local.hosts; 31 22 }
+3 -1
hosts/crossbell/hardware-configuration.nix
··· 1 - { inputs, ... }: 1 + { lib, inputs, ... }: 2 2 { 3 3 flake.modules.nixos.crossbell = { 4 4 imports = [ inputs.nixos-hardware.nixosModules.common-pc-ssd ]; 5 + 6 + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 5 7 6 8 boot.initrd.availableKernelModules = [ 7 9 "ahci"
+3 -1
hosts/grancel/hardware-configuration.nix
··· 1 - { inputs, ... }: 1 + { lib, inputs, ... }: 2 2 { 3 3 flake.modules.nixos.grancel = 4 4 { pkgs, ... }: ··· 8 8 inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower 9 9 inputs.nixos-hardware.nixosModules.common-gpu-amd 10 10 ]; 11 + 12 + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 11 13 12 14 hardware.enableRedistributableFirmware = true; 13 15 hardware.amdgpu.initrd.enable = true;
+1 -3
hosts/jurai/default.nix
··· 1 1 { inputs, ... }: 2 2 { 3 - local.hosts.jurai = { 4 - system = "aarch64-linux"; 5 - }; 3 + local.hosts.jurai = { }; 6 4 7 5 flake.modules.nixos.jurai = 8 6 { lib, pkgs, ... }:
+2
hosts/jurai/hardware-configuration.nix
··· 12 12 { 13 13 imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; 14 14 15 + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; 16 + 15 17 boot.initrd.availableKernelModules = [ "xhci_pci" ]; 16 18 boot.initrd.kernelModules = [ ]; 17 19 boot.kernelModules = [ ];
+3 -1
hosts/ruan/hardware-configuration.nix
··· 1 - { inputs, ... }: 1 + { lib, inputs, ... }: 2 2 { 3 3 flake.modules.nixos.ruan = { 4 4 imports = [ ··· 6 6 inputs.nixos-hardware.nixosModules.common-cpu-amd-zenpower 7 7 inputs.nixos-hardware.nixosModules.common-gpu-amd 8 8 ]; 9 + 10 + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 9 11 10 12 boot.initrd.availableKernelModules = [ 11 13 "xhci_pci"
+4 -5
modules/machines.nix
··· 1 1 { inputs, config, ... }: 2 2 let 3 - hosts = config.flake.nixosConfigurations; 3 + hosts = config.local.hosts; 4 4 in 5 5 { 6 6 flake.modules.nixos.machine = ··· 30 30 inherit (cfg) autoStart; 31 31 privateNetwork = true; 32 32 hostAddress = "192.168.100.100"; 33 - localAddress = "192.168.100.${toString host.config.local.id}"; 33 + localAddress = "192.168.100.${toString host.nixos.config.local.id}"; 34 34 hostAddress6 = "fc00::100"; 35 - localAddress6 = "fc00::${toString host.config.local.id}"; 36 - config.imports = [ 35 + localAddress6 = "fc00::${toString host.nixos.config.local.id}"; 36 + config.imports = host.modules ++ [ 37 37 inputs.self.modules.nixos.machine 38 - inputs.self.modules.nixos.${hostname} 39 38 { inherit options; } 40 39 { 41 40 disabledModules = [ { inherit key; } ];