diff --git a/flake.nix b/flake.nix index 6828dd0..4cec465 100644 --- a/flake.nix +++ b/flake.nix @@ -8,24 +8,32 @@ }; outputs = - { nixpkgs, home-manager, ... }: - { - nixosConfigurations = { - nixvm = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./configuration.nix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.xory = ./home.nix; + { self, nixpkgs, home-manager, ... } @ inputs: + let + system = "x86_64-linux"; + username = "xory"; - # Optionally, use home-manager.extraSpecialArgs to pass - # arguments to home.nix - } - ]; - }; - }; - }; + mkNixosHost = hostName: + nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + ./hosts/${hostName}/configuration.nix + ./hosts/${hostName}/hardware-configuration.nix + + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${username} = import ./hosts/${hostName}/home.nix; + } + ]; + }; + in { + nixosConfigurations = nixpkgs.lib.mapAttrs' + (name: value: { + name = name; + value = mkNixosHost name; + }) + (nixpkgs.lib.filterAttrs (name: value: value == "directory") + (builtins.readDir ./hosts)); + }; }