diff --git a/flake.nix b/flake.nix index 85c6a1a..7644915 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,8 @@ outputs = { self, home-manager, nixpkgs, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; + fs = pkgs.lib.fileset; + st = pkgs.lib.strings; hostConfig = extraModules: nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; @@ -23,6 +25,15 @@ ./nixosModules ] ++ extraModules; }; + hostFilter = { name, ...}: name == "host.nix"; + hostPaths = fs.toList (fs.fileFilter hostFilter ./hosts); + + hosts = builtins.listToAttrs (map (path: { + value = hostConfig [ path ]; + name = builtins.unsafeDiscardStringContext (st.removeSuffix "/host.nix" ( + builtins.elemAt (st.splitString "/hosts/" path) 1 + )); + }) hostPaths); userConfig = extraModules: home-manager.lib.homeManagerConfiguration { inherit pkgs; @@ -31,12 +42,11 @@ ./hmModules ] ++ extraModules; }; - in - { - nixosConfigurations.onizuka = hostConfig [ ./hosts/onizuka ]; - homeConfigurations."pan@onizuka" = userConfig [ ./hosts/onizuka/users/pan ]; - nixosConfigurations.jibril = hostConfig [ ./hosts/jibril ]; + in { + nixosConfigurations = hosts; + + homeConfigurations."pan@onizuka" = userConfig [ ./hosts/onizuka/users/pan ]; homeConfigurations."pan@jibril" = userConfig [ ./hosts/jibril/users/pan ]; }; } diff --git a/hosts/jibril/default.nix b/hosts/jibril/host.nix similarity index 100% rename from hosts/jibril/default.nix rename to hosts/jibril/host.nix diff --git a/hosts/onizuka/default.nix b/hosts/onizuka/host.nix similarity index 100% rename from hosts/onizuka/default.nix rename to hosts/onizuka/host.nix