diff --git a/flake.nix b/flake.nix index d79b5a0..3ac7643 100644 --- a/flake.nix +++ b/flake.nix @@ -4,14 +4,10 @@ nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; - outputs = inputs @ { self, nixpkgs, ... }: { - nixosConfigurations.backstage = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/backstage - ]; - specialArgs = { inherit inputs; }; - }; + outputs = inputs @ { self, nixpkgs, ... }: { + imports = [ + ./hosts + ]; }; } diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..fafd010 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,21 @@ +{inputs, self, ...}: +let + inherit (inputs.nixpkgs) lib; + isDirectory = _name: type: type == "directory"; + hostNames = builtins.attrNames ( + lib.filterAttrs isDirectory (builtins.readDir ./.) + ); + hosts = lib.genAttrs hostNames (name: { + imports = [ + (./. + "/${name}") + ]; + }); +in +{ + + nixosConfigurations = lib.map (host: lib.nixosSystem { + system = "x86_64-linux"; + modules = host; + specialArgs = { inherit inputs; }; + }) (builtins.attrValues hosts); +}