From 898113b5fbe7a2f2e569f766d1485bb7f239c2df Mon Sep 17 00:00:00 2001 From: Romain Paquet Date: Sun, 16 Feb 2025 14:52:54 +0100 Subject: [PATCH] refactor nixos configs --- flake.nix | 59 ++++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/flake.nix b/flake.nix index f6154a3..fb23aa1 100644 --- a/flake.nix +++ b/flake.nix @@ -12,49 +12,42 @@ self, ... }: - { - nixosConfigurations = { - + let + inherit (nixpkgs) lib; + hosts = { # VivoBook laptop - haze = nixpkgs.lib.nixosSystem { - specialArgs = { - inherit inputs; - inherit (import ./parts) keys; - }; + haze = { system = "x86_64-linux"; - modules = [ - ./hosts/haze - ./system - ]; }; - # Hetzner VPS - crocus = nixpkgs.lib.nixosSystem { - specialArgs = { - inherit inputs; - inherit (import ./parts) keys; - }; + crocus = { system = "x86_64-linux"; - modules = [ - ./hosts/crocus - ./system - ]; }; - # Raspberry Pi 4 - genepi = nixpkgs.lib.nixosSystem { - specialArgs = { - inherit inputs self; - inherit (import ./parts) keys; - }; + genepi = { system = "aarch64-linux"; - modules = [ - ./hosts/genepi - ./system - ]; }; - }; + in + { + nixosConfigurations = + let + mkNixosConfig = + hostname: + { system }: + lib.nixosSystem { + inherit system; + specialArgs = { + inherit inputs self; + inherit (import ./parts) keys; + }; + modules = [ + ./hosts/${hostname} + ./system + ]; + }; + in + builtins.mapAttrs mkNixosConfig hosts; # Raspberry Pi 4 installer ISO. packages.aarch64-linux.installer-sd-image = nixos-generators.nixosGenerate {