From b00e9f7364b2baaf100eac2823339631d701ac40 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 5 Jun 2024 22:08:30 -0400 Subject: [PATCH] Use attribute sets in flake.nix This will let me be more fine grained in what is applied where and will allow importing of host-specific modules like those from https://github.com/NixOS/nixos-hardware --- flake.nix | 87 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 21 deletions(-) diff --git a/flake.nix b/flake.nix index a0fa5c3..8fccef3 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,7 @@ home-manager, nix-darwin, nix-flatpak, nix-homebrew, nixpkgs-terraform, sops-nix, ... }: let # creates a macOS system config - darwinHostConfig = system: hostname: username: nix-darwin.lib.darwinSystem { + darwinHostConfig = { system, hostname, username, additionaModules, additionaSpecialArgs }: nix-darwin.lib.darwinSystem { pkgs = import nixpkgs { inherit system; config = { @@ -68,7 +68,7 @@ }; overlays = [ nixpkgs-terraform.overlays.default ]; }; - specialArgs = { inherit inputs hostname username; }; + specialArgs = { inherit inputs hostname username; } // additionaSpecialArgs; modules = [ nix-homebrew.darwinModules.nix-homebrew { nix-homebrew = { @@ -92,11 +92,11 @@ ./modules/system/common/all-darwin.nix # system-wide stuff ./modules/hosts/darwin/${hostname} # host specific stuff - ]; # end modules + ] ++ additionaModules; # end modules }; # end darwinSystem # creates a nixos system config - nixosHostConfig = system: hostname: username: nixpkgs.lib.nixosSystem { + nixosHostConfig = { system, hostname, username, additionaModules, additionaSpecialArgs }: nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs compose2nix hostname username; pkgs = import nixpkgs { inherit system; @@ -106,7 +106,7 @@ }; overlays = [ nixpkgs-terraform.overlays.default ]; }; - }; + } // additionaSpecialArgs; modules = [ disko.nixosModules.disko @@ -126,10 +126,10 @@ sops-nix.nixosModules.sops # system wide secrets management ./modules/system/common/all-nixos.nix # system-wide stuff ./modules/hosts/nixos/${hostname} # host specific stuff - ]; + ] ++ additionaModules; }; # end nixosSystem - linuxHomeConfig = system: hostname: username: home-manager.lib.homeManagerConfiguration { + linuxHomeConfig = { system, hostname, username, additionaModules, additionaSpecialArgs }: home-manager.lib.homeManagerConfiguration { extraSpecialArgs = { inherit genebean-omp-themes hostname username; pkgs = import nixpkgs { inherit system; @@ -139,7 +139,7 @@ }; overlays = [ nixpkgs-terraform.overlays.default ]; }; - }; + } // additionaSpecialArgs; modules = [ ./modules/home-manager/hosts/${hostname}/${username}.nix { @@ -149,24 +149,69 @@ }; } sops-nix.homeManagerModules.sops - ]; + ] ++ additionaModules; }; # end homeManagerConfiguration in { - darwinConfigurations = { - AirPuppet = darwinHostConfig "x86_64-darwin" "AirPuppet" "gene"; - Blue-Rock = darwinHostConfig "x86_64-darwin" "Blue-Rock" "gene.liverman"; - mightymac = darwinHostConfig "aarch64-darwin" "mightymac" "gene.liverman"; + # Darwin (macOS) hosts + darwinConfigurations = { + AirPuppet = darwinHostConfig { + system = "x86_64-darwin"; + hostname = "AirPuppet"; + username = "gene"; + additionaModules = []; + additionaSpecialArgs = {}; }; - - nixosConfigurations = { - hetznix01 = nixosHostConfig "aarch64-linux" "hetznix01" "gene"; - nixnuc = nixosHostConfig "x86_64-linux" "nixnuc" "gene"; - rainbow-planet = nixosHostConfig "x86_64-linux" "rainbow-planet" "gene"; + Blue-Rock = darwinHostConfig { + system = "x86_64-darwin"; + hostname = "Blue-Rock"; + username = "gene.liverman"; + additionaModules = []; + additionaSpecialArgs = {}; }; + mightymac = darwinHostConfig { + system = "aarch64-darwin"; + hostname = "mightymac"; + username = "gene.liverman"; + additionaModules = []; + additionaSpecialArgs = {}; + }; + }; # end darwinConfigurations - homeConfigurations = { - gene = linuxHomeConfig "x86_64-linux" "mini-watcher" "gene"; - }; + # NixOS hosts + nixosConfigurations = { + hetznix01 = nixosHostConfig { + system = "aarch64-linux"; + hostname = "hetznix01"; + username = "gene"; + additionaModules = []; + additionaSpecialArgs = {}; + }; + nixnuc = nixosHostConfig { + system = "x86_64-linux"; + hostname = "nixnuc"; + username = "gene"; + additionaModules = []; + additionaSpecialArgs = {}; + }; + rainbow-planet = nixosHostConfig { + system = "x86_64-linux"; + hostname = "rainbow-planet"; + username = "gene"; + additionaModules = []; + additionaSpecialArgs = {}; + }; + }; # end nixosConfigurations + + # Home Manager (only) users + homeConfigurations = { + gene = linuxHomeConfig { + system = "x86_64-linux"; + hostname = "mini-watcher"; + username = "gene"; + additionaModules = []; + additionaSpecialArgs = {}; + }; + }; # end homeConfigurations }; }