From 85593592489c2228455a5aa831c6704302cd4ebb Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Mon, 15 Jul 2024 19:15:33 +0200 Subject: [PATCH] Auto import all hosts --- flake.nix | 2 +- flake/hosts.nix | 25 +++++++++++++++++++++++++ flake/nixosConfigurations.nix | 30 ------------------------------ hosts/inspiron/default.nix | 1 - hosts/north/default.nix | 1 - 5 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 flake/hosts.nix delete mode 100644 flake/nixosConfigurations.nix diff --git a/flake.nix b/flake.nix index 552c4ec..b4f9fe7 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,7 @@ systems = [ "x86_64-linux" ]; imports = [ - ./flake/nixosConfigurations.nix + ./flake/hosts.nix ./flake/devShells.nix ./flake/formatter.nix ]; diff --git a/flake/hosts.nix b/flake/hosts.nix new file mode 100644 index 0000000..7af204e --- /dev/null +++ b/flake/hosts.nix @@ -0,0 +1,25 @@ +{ + self, + inputs, + lib, + ... +}: +let + subdirsOf = + dir: builtins.attrNames (lib.filterAttrs (_: v: v == "directory") (builtins.readDir dir)); +in +{ + flake.nixosConfigurations = lib.genAttrs (subdirsOf "${self}/hosts") ( + name: + inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit self inputs; + }; + modules = [ + "${self}/hosts/${name}" + "${self}/users/seb/@${name}" + { networking.hostName = name; } + ]; + } + ); +} diff --git a/flake/nixosConfigurations.nix b/flake/nixosConfigurations.nix deleted file mode 100644 index 1842e1b..0000000 --- a/flake/nixosConfigurations.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - nixpkgs, - self, - inputs, - ... -}: -{ - flake = { - nixosConfigurations = { - north = inputs.nixpkgs.lib.nixosSystem { - specialArgs = { - inherit self inputs; - }; - modules = [ - "${self}/hosts/north" - "${self}/users/seb/@north" - ]; - }; - inspiron = inputs.nixpkgs.lib.nixosSystem { - specialArgs = { - inherit self inputs; - }; - modules = [ - "${self}/hosts/inspiron" - "${self}/users/seb/@inspiron" - ]; - }; - }; - }; -} diff --git a/hosts/inspiron/default.nix b/hosts/inspiron/default.nix index 22f89b5..6613282 100644 --- a/hosts/inspiron/default.nix +++ b/hosts/inspiron/default.nix @@ -5,7 +5,6 @@ ./hardware.nix ]; - networking.hostName = "inspiron"; system.stateVersion = "23.11"; boot.kernelPackages = pkgs.linuxPackages_latest; diff --git a/hosts/north/default.nix b/hosts/north/default.nix index 37beb65..3aa0dc3 100644 --- a/hosts/north/default.nix +++ b/hosts/north/default.nix @@ -5,7 +5,6 @@ ./hardware.nix ]; - networking.hostName = "north"; system.stateVersion = "23.11"; boot.kernelPackages = pkgs.linuxPackages_6_8;