NixOS system configurations + dotfiles via home-manager

hosts: refactor config generation

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