From f8fc66d9ad405a6b692026a2b517b9c2968176f6 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Mon, 8 Apr 2024 00:43:06 +0200 Subject: [PATCH] flake.nix: Use foldl --- flake.nix | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index f44acf9..358b6a7 100644 --- a/flake.nix +++ b/flake.nix @@ -20,29 +20,22 @@ ... }: let - common-modules = [ - home-manager.nixosModules.home-manager - (import ./home/common-home-manager.nix { inherit inputs; }) + systems = [ + { name = "nixos-test"; system = "x86_64-linux"; } + { name = "perso-laptop"; system = "x86_64-linux"; } + { name = "perso-desktop"; system = "x86_64-linux"; } ]; in { - nixosConfigurations = { - nixos-test = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - - modules = [ ./hosts/nixos-test ] ++ common-modules; - }; - - perso-laptop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - - modules = [ ./hosts/perso-laptop ] ++ common-modules; - }; - - perso-desktop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - - modules = [ ./hosts/perso-desktop ] ++ common-modules; - }; - }; + nixosConfigurations = nixpkgs.lib.foldl (c: s: + c // { + ${s.name} = nixpkgs.lib.nixosSystem { + system = s.system; + modules = [ + ./hosts/${s.name} + home-manager.nixosModules.home-manager + (import ./home/common-home-manager.nix { inherit inputs; }) + ]; + }; + }) {} systems; }; }