From 0ec0ecec20361e205ef84f6836a0745eb4344fa0 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Sun, 25 Aug 2024 22:58:58 +0200 Subject: [PATCH] avoid repeating code and add common modules in function --- flake.nix | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index 40a819c..7178c7a 100644 --- a/flake.nix +++ b/flake.nix @@ -23,45 +23,37 @@ outputs = { nixpkgs, home-manager, nixvim, sops-nix, shells, ... }@inputs: let username = "nezia"; + system = "x86_64-linux"; + + commonModules = hostname: [ + ./hosts/${hostname} + sops-nix.nixosModules.sops + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.sharedModules = [ nixvim.homeManagerModules.nixvim ]; + home-manager.extraSpecialArgs = { inherit inputs; }; + } + { _module.args = { inherit hostname username; }; } + ]; in { nixosConfigurations = { vamos = let hostname = "vamos"; in nixpkgs.lib.nixosSystem { - - system = "x86_64-linux"; - - modules = [ - ./hosts/${hostname} - sops-nix.nixosModules.sops - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.sharedModules = [ nixvim.homeManagerModules.nixvim ]; - home-manager.users.nezia = import ./home/laptop; - home-manager.extraSpecialArgs = { inherit inputs; }; - } - { _module.args = { inherit hostname username; }; } + system = system; + modules = commonModules hostname ++ [ + { home-manager.users.nezia = import ./home/laptop; } ]; }; solaire = let hostname = "solaire"; in nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/${hostname} - sops-nix.nixosModules.sops - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.sharedModules = [ nixvim.homeManagerModules.nixvim ]; - home-manager.users.nezia = import ./home/desktop; - home-manager.extraSpecialArgs = { inherit inputs; }; - } - { _module.args = { inherit hostname username; }; } + system = system; + modules = commonModules hostname ++ [ + { home-manager.users.nezia = import ./home/desktop; } ]; }; };