From de18f587c77ecbb7c26afa64ed6c124d0345195f Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Sat, 11 Oct 2025 21:40:42 +0200 Subject: [PATCH] Simplify host imports --- flake-parts/hosts.nix | 29 +++++++---------------------- hosts/desktop/default.nix | 8 +++++++- hosts/desktop/hardware.nix | 5 +---- hosts/laptop/default.nix | 8 +++++++- hosts/laptop/hardware.nix | 5 +---- hosts/srv-monitor/default.nix | 8 +++++++- hosts/srv-monitor/hardware.nix | 7 ++----- hosts/srv-private/default.nix | 8 +++++++- hosts/srv-private/hardware.nix | 7 ++----- hosts/srv-public/default.nix | 8 +++++++- hosts/srv-public/hardware.nix | 7 ++----- 11 files changed, 50 insertions(+), 50 deletions(-) diff --git a/flake-parts/hosts.nix b/flake-parts/hosts.nix index 620f491..042f2fd 100644 --- a/flake-parts/hosts.nix +++ b/flake-parts/hosts.nix @@ -9,28 +9,13 @@ let hostName: inputs.nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs self; }; - modules = - let - hostFiles = - "${self}/hosts/${hostName}" - |> lib.filesystem.listFilesRecursive - |> lib.filter (lib.hasSuffix ".nix"); - - userFiles = - "${self}/users" - |> builtins.readDir - |> lib.filterAttrs (_: type: type == "directory") - |> lib.attrNames - |> map (user: "${self}/users/${user}/@${hostName}/default.nix") - |> lib.filter (path: lib.pathExists path); - in - [ - { networking = { inherit hostName; }; } - "${self}/hosts/common.nix" - "${self}/users/seb/default.nix" - ] - ++ hostFiles - ++ userFiles; + modules = [ + { networking = { inherit hostName; }; } + "${self}/hosts/common.nix" + "${self}/hosts/${hostName}" + "${self}/users/seb" + ] + ++ lib.optional (lib.pathExists "${self}/users/seb/@${hostName}") "${self}/users/seb/@${hostName}"; }; mkDeployNode = hostname: { diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 979ab15..a7a6a88 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,5 +1,11 @@ -{ pkgs, ... }: +{ inputs, pkgs, ... }: { + imports = [ + ./hardware.nix + ./disko.nix + inputs.disko.nixosModules.default + ]; + system.stateVersion = "23.11"; boot.kernelPackages = pkgs.linuxPackages_latest; diff --git a/hosts/desktop/hardware.nix b/hosts/desktop/hardware.nix index 4bf05e5..c6ac425 100644 --- a/hosts/desktop/hardware.nix +++ b/hosts/desktop/hardware.nix @@ -1,7 +1,4 @@ -{ inputs, ... }: -{ - imports = [ inputs.disko.nixosModules.default ]; - +_: { nixpkgs.hostPlatform = "x86_64-linux"; hardware = { diff --git a/hosts/laptop/default.nix b/hosts/laptop/default.nix index da9daae..af6801e 100644 --- a/hosts/laptop/default.nix +++ b/hosts/laptop/default.nix @@ -1,5 +1,11 @@ -{ pkgs, ... }: +{ inputs, pkgs, ... }: { + imports = [ + ./hardware.nix + ./disko.nix + inputs.disko.nixosModules.default + ]; + system.stateVersion = "24.11"; boot.kernelPackages = pkgs.linuxPackages_latest; diff --git a/hosts/laptop/hardware.nix b/hosts/laptop/hardware.nix index bb2f58c..7eb87fc 100644 --- a/hosts/laptop/hardware.nix +++ b/hosts/laptop/hardware.nix @@ -1,9 +1,6 @@ { inputs, ... }: { - imports = [ - inputs.disko.nixosModules.default - inputs.nixos-hardware.nixosModules.framework-13-7040-amd - ]; + imports = [ inputs.nixos-hardware.nixosModules.framework-13-7040-amd ]; nixpkgs.hostPlatform = "x86_64-linux"; diff --git a/hosts/srv-monitor/default.nix b/hosts/srv-monitor/default.nix index 32a0420..3a919de 100644 --- a/hosts/srv-monitor/default.nix +++ b/hosts/srv-monitor/default.nix @@ -1,5 +1,11 @@ -{ config, ... }: +{ config, inputs, ... }: { + imports = [ + ./hardware.nix + ./disko.nix + inputs.disko.nixosModules.default + ]; + system.stateVersion = "25.05"; meta = { diff --git a/hosts/srv-monitor/hardware.nix b/hosts/srv-monitor/hardware.nix index 1ff17ba..e010835 100644 --- a/hosts/srv-monitor/hardware.nix +++ b/hosts/srv-monitor/hardware.nix @@ -1,9 +1,6 @@ -{ modulesPath, inputs, ... }: +{ modulesPath, ... }: { - imports = [ - inputs.disko.nixosModules.default - "${modulesPath}/profiles/qemu-guest.nix" - ]; + imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; nixpkgs.hostPlatform = "x86_64-linux"; diff --git a/hosts/srv-private/default.nix b/hosts/srv-private/default.nix index 4cee387..a45c62f 100644 --- a/hosts/srv-private/default.nix +++ b/hosts/srv-private/default.nix @@ -1,5 +1,11 @@ -{ config, ... }: +{ config, inputs, ... }: { + imports = [ + ./hardware.nix + ./disko.nix + inputs.disko.nixosModules.default + ]; + system.stateVersion = "25.05"; meta = { diff --git a/hosts/srv-private/hardware.nix b/hosts/srv-private/hardware.nix index d58ab44..4ec1054 100644 --- a/hosts/srv-private/hardware.nix +++ b/hosts/srv-private/hardware.nix @@ -1,9 +1,6 @@ -{ modulesPath, inputs, ... }: +{ modulesPath, ... }: { - imports = [ - inputs.disko.nixosModules.default - "${modulesPath}/profiles/qemu-guest.nix" - ]; + imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; nixpkgs.hostPlatform = "x86_64-linux"; diff --git a/hosts/srv-public/default.nix b/hosts/srv-public/default.nix index aae56b2..343019e 100644 --- a/hosts/srv-public/default.nix +++ b/hosts/srv-public/default.nix @@ -1,5 +1,11 @@ -{ config, ... }: +{ config, inputs, ... }: { + imports = [ + ./hardware.nix + ./disko.nix + inputs.disko.nixosModules.default + ]; + system.stateVersion = "25.05"; meta = { diff --git a/hosts/srv-public/hardware.nix b/hosts/srv-public/hardware.nix index 57f8ad5..49ad185 100644 --- a/hosts/srv-public/hardware.nix +++ b/hosts/srv-public/hardware.nix @@ -1,9 +1,6 @@ -{ modulesPath, inputs, ... }: +{ modulesPath, ... }: { - imports = [ - inputs.disko.nixosModules.default - "${modulesPath}/profiles/qemu-guest.nix" - ]; + imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; nixpkgs.hostPlatform = "x86_64-linux";