Refactor to pass host vars as arguments

Remove per‑host imports across flake, modules, and profiles, exposing
needed
variables (system, printer settings, consoleKeyMap, etc.) as arguments.
Drop unused printEnable flags from host variable files.
This commit is contained in:
2026-05-24 15:43:18 +02:00
parent 077d8f07e7
commit 98069fa8d9
18 changed files with 53 additions and 75 deletions
+5 -16
View File
@@ -65,25 +65,14 @@
hostDirs = builtins.attrNames (builtins.readDir ./hosts); hostDirs = builtins.attrNames (builtins.readDir ./hosts);
mkHost = hostName: let mkHost = hostName: let
inherit hostVars = import ./hosts/${hostName}/variables.nix;
(import ./hosts/${hostName}/variables.nix) hostPrinterVars = import ./hosts/${hostName}/printers.nix;
host
username
profile
system
;
in in
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit (hostVars) system;
specialArgs = { specialArgs = hostVars // hostPrinterVars // {inherit inputs;};
inherit inputs;
inherit username;
inherit host;
inherit profile;
inherit system;
};
modules = [ modules = [
./profiles/${profile} ./profiles/${hostVars.profile}
nix-flatpak.nixosModules.nix-flatpak nix-flatpak.nixosModules.nix-flatpak
garandos-tui.nixosModules.garandos-tui garandos-tui.nixosModules.garandos-tui
]; ];
-3
View File
@@ -39,9 +39,6 @@
# Enable NFS # Enable NFS
enableNFS = false; enableNFS = false;
# Enable Printing Support
printEnable = true;
# Set Stylix Image # Set Stylix Image
# This will set your color palette # This will set your color palette
# Default background # Default background
-3
View File
@@ -41,9 +41,6 @@
# Enable NFS # Enable NFS
enableNFS = false; enableNFS = false;
# Enable Printing Support
printEnable = false;
# Themes, waybar and animation. # Themes, waybar and animation.
# Only uncomment your selection # Only uncomment your selection
# The others much be commented out. # The others much be commented out.
+2 -4
View File
@@ -2,11 +2,9 @@
pkgs, pkgs,
lib, lib,
config, config,
host, profile,
... ...
}: let }: {
inherit (import ../../hosts/${host}/variables.nix) profile;
in {
options.docker.enable = lib.mkEnableOption "Docker"; options.docker.enable = lib.mkEnableOption "Docker";
config.virtualisation.docker = lib.mkIf config.docker.enable { config.virtualisation.docker = lib.mkIf config.docker.enable {
+2 -3
View File
@@ -1,10 +1,9 @@
{ {
host, host,
hostId,
options, options,
... ...
}: let }: {
inherit (import ../../hosts/${host}/variables.nix) hostId;
in {
# Defensive assertion for hostname validity (clearer message at eval time) # Defensive assertion for hostname validity (clearer message at eval time)
assertions = [ assertions = [
{ {
+1 -3
View File
@@ -1,6 +1,4 @@
{host, ...}: let {enableNFS, ...}: {
inherit (import ../../hosts/${host}/variables.nix) enableNFS;
in {
services = { services = {
rpcbind.enable = enableNFS; rpcbind.enable = enableNFS;
nfs.server.enable = enableNFS; nfs.server.enable = enableNFS;
+4 -4
View File
@@ -1,11 +1,11 @@
{ {
pkgs, pkgs,
lib, lib,
host, printEnable,
ensureDefaultPrinter,
ensurePrinters,
... ...
}: let }: {
inherit (import ../../hosts/${host}/printers.nix) printEnable ensureDefaultPrinter ensurePrinters;
in {
services = lib.mkIf printEnable { services = lib.mkIf printEnable {
printing = { printing = {
enable = true; enable = true;
+2 -4
View File
@@ -1,10 +1,8 @@
{ {
pkgs, pkgs,
host, stylixImage,
... ...
}: let }: {
inherit (import ../../hosts/${host}/variables.nix) stylixImage;
in {
# Styling Options # Styling Options
stylix = { stylix = {
enable = true; enable = true;
+2 -4
View File
@@ -1,10 +1,8 @@
{ {
host, consoleKeyMap,
inputs, inputs,
... ...
}: let }: {
inherit (import ../../hosts/${host}/variables.nix) consoleKeyMap;
in {
nix = { nix = {
nixPath = ["nixpkgs=${inputs.nixpkgs}"]; nixPath = ["nixpkgs=${inputs.nixpkgs}"];
settings = { settings = {
+13 -3
View File
@@ -5,10 +5,14 @@
host, host,
profile, profile,
system, system,
gitUsername,
shell,
extraMonitorSettings,
keyboardLayout,
gitEmail,
location,
... ...
}: let }: {
inherit (import ../../hosts/${host}/variables.nix) gitUsername shell;
in {
imports = [inputs.home-manager.nixosModules.home-manager]; imports = [inputs.home-manager.nixosModules.home-manager];
home-manager = { home-manager = {
useUserPackages = true; useUserPackages = true;
@@ -21,6 +25,12 @@ in {
host host
profile profile
system system
extraMonitorSettings
shell
keyboardLayout
gitEmail
gitUsername
location
; ;
}; };
users.${username} = { users.${username} = {
+1 -3
View File
@@ -1,6 +1,4 @@
{host, ...}: let {keyboardLayout, ...}: {
inherit (import ../../hosts/${host}/variables.nix) keyboardLayout;
in {
services.xserver = { services.xserver = {
enable = true; enable = true;
xkb = { xkb = {
+1 -3
View File
@@ -1,6 +1,4 @@
{host, ...}: let {shell, ...}: {
inherit (import ../../../hosts/${host}/variables.nix) shell;
in {
programs.bash = { programs.bash = {
enable = enable =
if shell == "bash" if shell == "bash"
+2 -4
View File
@@ -1,10 +1,8 @@
{ {
pkgs, pkgs,
host, shell,
... ...
}: let }: {
inherit (import ../../../hosts/${host}/variables.nix) shell;
in {
programs = { programs = {
fish = { fish = {
enable = enable =
+5 -3
View File
@@ -1,6 +1,8 @@
{host, ...}: let {
inherit (import ../../hosts/${host}/variables.nix) gitUsername gitEmail; gitUsername,
in { gitEmail,
...
}: {
programs.git = { programs.git = {
enable = true; enable = true;
settings = { settings = {
+3 -4
View File
@@ -1,10 +1,9 @@
{ {
host, extraMonitorSettings,
keyboardLayout,
pkgs, pkgs,
... ...
}: let }: {
inherit (import ../../../hosts/${host}/variables.nix) extraMonitorSettings keyboardLayout;
in {
systemd.user.targets.hyprland-session.Unit.Wants = [ systemd.user.targets.hyprland-session.Unit.Wants = [
"xdg-desktop-autostart.target" "xdg-desktop-autostart.target"
]; ];
+2 -4
View File
@@ -1,11 +1,9 @@
{ {
lib, lib,
host, keyboardLayout,
username, username,
... ...
}: let }: {
inherit (import ../../../../hosts/${host}/variables.nix) keyboardLayout;
in {
programs.noctalia-shell.settings.general = lib.mkForce { programs.noctalia-shell.settings.general = lib.mkForce {
avatarImage = "/home/${username}/.face.icon"; avatarImage = "/home/${username}/.face.icon";
dimmerOpacity = 0.2; dimmerOpacity = 0.2;
+2 -4
View File
@@ -1,10 +1,8 @@
{ {
lib, lib,
host, location,
... ...
}: let }: {
inherit (import ../../../../hosts/${host}/variables.nix) location;
in {
programs.noctalia-shell.settings.location = lib.mkForce { programs.noctalia-shell.settings.location = lib.mkForce {
name = "${location}"; name = "${location}";
weatherEnabled = true; weatherEnabled = true;
+6 -3
View File
@@ -1,6 +1,9 @@
{host, ...}: let {
inherit (import ../../hosts/${host}/variables.nix) intelID nvidiaID; host,
in { intelID,
nvidiaID,
...
}: {
imports = [ imports = [
../../hosts/${host} ../../hosts/${host}
../../modules/drivers ../../modules/drivers