Auto import all hosts

This commit is contained in:
SebastianStork 2024-07-15 19:15:33 +02:00
parent ad7ae417b9
commit 8559359248
5 changed files with 26 additions and 33 deletions

View file

@ -57,7 +57,7 @@
systems = [ "x86_64-linux" ]; systems = [ "x86_64-linux" ];
imports = [ imports = [
./flake/nixosConfigurations.nix ./flake/hosts.nix
./flake/devShells.nix ./flake/devShells.nix
./flake/formatter.nix ./flake/formatter.nix
]; ];

25
flake/hosts.nix Normal file
View file

@ -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; }
];
}
);
}

View file

@ -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"
];
};
};
};
}

View file

@ -5,7 +5,6 @@
./hardware.nix ./hardware.nix
]; ];
networking.hostName = "inspiron";
system.stateVersion = "23.11"; system.stateVersion = "23.11";
boot.kernelPackages = pkgs.linuxPackages_latest; boot.kernelPackages = pkgs.linuxPackages_latest;

View file

@ -5,7 +5,6 @@
./hardware.nix ./hardware.nix
]; ];
networking.hostName = "north";
system.stateVersion = "23.11"; system.stateVersion = "23.11";
boot.kernelPackages = pkgs.linuxPackages_6_8; boot.kernelPackages = pkgs.linuxPackages_6_8;