From 98069fa8d9dd6a52ac5700b3afc33c760e34354f Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Sun, 24 May 2026 15:43:18 +0200 Subject: [PATCH] Refactor to pass host vars as arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- flake.nix | 21 +++++---------------- hosts/Garand-Desktop/variables.nix | 3 --- hosts/default/variables.nix | 3 --- modules/core/docker.nix | 6 ++---- modules/core/network.nix | 5 ++--- modules/core/nfs.nix | 4 +--- modules/core/printing.nix | 8 ++++---- modules/core/stylix.nix | 6 ++---- modules/core/system.nix | 6 ++---- modules/core/user.nix | 16 +++++++++++++--- modules/core/xserver.nix | 4 +--- modules/home/bash/default.nix | 4 +--- modules/home/fish/default.nix | 6 ++---- modules/home/git.nix | 8 +++++--- modules/home/hyprland/hyprland.nix | 7 +++---- modules/home/noctalia/settings/general.nix | 6 ++---- modules/home/noctalia/settings/location.nix | 6 ++---- profiles/nvidia-laptop/default.nix | 9 ++++++--- 18 files changed, 53 insertions(+), 75 deletions(-) diff --git a/flake.nix b/flake.nix index 00d0071..302f66f 100644 --- a/flake.nix +++ b/flake.nix @@ -65,25 +65,14 @@ hostDirs = builtins.attrNames (builtins.readDir ./hosts); mkHost = hostName: let - inherit - (import ./hosts/${hostName}/variables.nix) - host - username - profile - system - ; + hostVars = import ./hosts/${hostName}/variables.nix; + hostPrinterVars = import ./hosts/${hostName}/printers.nix; in nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit username; - inherit host; - inherit profile; - inherit system; - }; + inherit (hostVars) system; + specialArgs = hostVars // hostPrinterVars // {inherit inputs;}; modules = [ - ./profiles/${profile} + ./profiles/${hostVars.profile} nix-flatpak.nixosModules.nix-flatpak garandos-tui.nixosModules.garandos-tui ]; diff --git a/hosts/Garand-Desktop/variables.nix b/hosts/Garand-Desktop/variables.nix index 38bc5e7..60bc67c 100644 --- a/hosts/Garand-Desktop/variables.nix +++ b/hosts/Garand-Desktop/variables.nix @@ -39,9 +39,6 @@ # Enable NFS enableNFS = false; - # Enable Printing Support - printEnable = true; - # Set Stylix Image # This will set your color palette # Default background diff --git a/hosts/default/variables.nix b/hosts/default/variables.nix index 877835f..62e6139 100644 --- a/hosts/default/variables.nix +++ b/hosts/default/variables.nix @@ -41,9 +41,6 @@ # Enable NFS enableNFS = false; - # Enable Printing Support - printEnable = false; - # Themes, waybar and animation. # Only uncomment your selection # The others much be commented out. diff --git a/modules/core/docker.nix b/modules/core/docker.nix index da6d736..2392172 100644 --- a/modules/core/docker.nix +++ b/modules/core/docker.nix @@ -2,11 +2,9 @@ pkgs, lib, config, - host, + profile, ... -}: let - inherit (import ../../hosts/${host}/variables.nix) profile; -in { +}: { options.docker.enable = lib.mkEnableOption "Docker"; config.virtualisation.docker = lib.mkIf config.docker.enable { diff --git a/modules/core/network.nix b/modules/core/network.nix index f0e6931..2957b51 100644 --- a/modules/core/network.nix +++ b/modules/core/network.nix @@ -1,10 +1,9 @@ { host, + hostId, options, ... -}: let - inherit (import ../../hosts/${host}/variables.nix) hostId; -in { +}: { # Defensive assertion for hostname validity (clearer message at eval time) assertions = [ { diff --git a/modules/core/nfs.nix b/modules/core/nfs.nix index adbcde8..0e31958 100644 --- a/modules/core/nfs.nix +++ b/modules/core/nfs.nix @@ -1,6 +1,4 @@ -{host, ...}: let - inherit (import ../../hosts/${host}/variables.nix) enableNFS; -in { +{enableNFS, ...}: { services = { rpcbind.enable = enableNFS; nfs.server.enable = enableNFS; diff --git a/modules/core/printing.nix b/modules/core/printing.nix index dfb62d5..41ac10b 100644 --- a/modules/core/printing.nix +++ b/modules/core/printing.nix @@ -1,11 +1,11 @@ { pkgs, lib, - host, + printEnable, + ensureDefaultPrinter, + ensurePrinters, ... -}: let - inherit (import ../../hosts/${host}/printers.nix) printEnable ensureDefaultPrinter ensurePrinters; -in { +}: { services = lib.mkIf printEnable { printing = { enable = true; diff --git a/modules/core/stylix.nix b/modules/core/stylix.nix index ad8032c..3c91afb 100644 --- a/modules/core/stylix.nix +++ b/modules/core/stylix.nix @@ -1,10 +1,8 @@ { pkgs, - host, + stylixImage, ... -}: let - inherit (import ../../hosts/${host}/variables.nix) stylixImage; -in { +}: { # Styling Options stylix = { enable = true; diff --git a/modules/core/system.nix b/modules/core/system.nix index 6010240..50e58f4 100644 --- a/modules/core/system.nix +++ b/modules/core/system.nix @@ -1,10 +1,8 @@ { - host, + consoleKeyMap, inputs, ... -}: let - inherit (import ../../hosts/${host}/variables.nix) consoleKeyMap; -in { +}: { nix = { nixPath = ["nixpkgs=${inputs.nixpkgs}"]; settings = { diff --git a/modules/core/user.nix b/modules/core/user.nix index c5632a2..6ddc45c 100644 --- a/modules/core/user.nix +++ b/modules/core/user.nix @@ -5,10 +5,14 @@ host, profile, system, + gitUsername, + shell, + extraMonitorSettings, + keyboardLayout, + gitEmail, + location, ... -}: let - inherit (import ../../hosts/${host}/variables.nix) gitUsername shell; -in { +}: { imports = [inputs.home-manager.nixosModules.home-manager]; home-manager = { useUserPackages = true; @@ -21,6 +25,12 @@ in { host profile system + extraMonitorSettings + shell + keyboardLayout + gitEmail + gitUsername + location ; }; users.${username} = { diff --git a/modules/core/xserver.nix b/modules/core/xserver.nix index 7429bd0..f7f862b 100644 --- a/modules/core/xserver.nix +++ b/modules/core/xserver.nix @@ -1,6 +1,4 @@ -{host, ...}: let - inherit (import ../../hosts/${host}/variables.nix) keyboardLayout; -in { +{keyboardLayout, ...}: { services.xserver = { enable = true; xkb = { diff --git a/modules/home/bash/default.nix b/modules/home/bash/default.nix index 514d84a..e78c8c4 100644 --- a/modules/home/bash/default.nix +++ b/modules/home/bash/default.nix @@ -1,6 +1,4 @@ -{host, ...}: let - inherit (import ../../../hosts/${host}/variables.nix) shell; -in { +{shell, ...}: { programs.bash = { enable = if shell == "bash" diff --git a/modules/home/fish/default.nix b/modules/home/fish/default.nix index 51f04b7..8a2cefa 100644 --- a/modules/home/fish/default.nix +++ b/modules/home/fish/default.nix @@ -1,10 +1,8 @@ { pkgs, - host, + shell, ... -}: let - inherit (import ../../../hosts/${host}/variables.nix) shell; -in { +}: { programs = { fish = { enable = diff --git a/modules/home/git.nix b/modules/home/git.nix index 4d158b4..9d01834 100644 --- a/modules/home/git.nix +++ b/modules/home/git.nix @@ -1,6 +1,8 @@ -{host, ...}: let - inherit (import ../../hosts/${host}/variables.nix) gitUsername gitEmail; -in { +{ + gitUsername, + gitEmail, + ... +}: { programs.git = { enable = true; settings = { diff --git a/modules/home/hyprland/hyprland.nix b/modules/home/hyprland/hyprland.nix index 1b21639..48b68fd 100644 --- a/modules/home/hyprland/hyprland.nix +++ b/modules/home/hyprland/hyprland.nix @@ -1,10 +1,9 @@ { - host, + extraMonitorSettings, + keyboardLayout, pkgs, ... -}: let - inherit (import ../../../hosts/${host}/variables.nix) extraMonitorSettings keyboardLayout; -in { +}: { systemd.user.targets.hyprland-session.Unit.Wants = [ "xdg-desktop-autostart.target" ]; diff --git a/modules/home/noctalia/settings/general.nix b/modules/home/noctalia/settings/general.nix index 0743800..43424f2 100644 --- a/modules/home/noctalia/settings/general.nix +++ b/modules/home/noctalia/settings/general.nix @@ -1,11 +1,9 @@ { lib, - host, + keyboardLayout, username, ... -}: let - inherit (import ../../../../hosts/${host}/variables.nix) keyboardLayout; -in { +}: { programs.noctalia-shell.settings.general = lib.mkForce { avatarImage = "/home/${username}/.face.icon"; dimmerOpacity = 0.2; diff --git a/modules/home/noctalia/settings/location.nix b/modules/home/noctalia/settings/location.nix index d73bf3a..86c9cc0 100644 --- a/modules/home/noctalia/settings/location.nix +++ b/modules/home/noctalia/settings/location.nix @@ -1,10 +1,8 @@ { lib, - host, + location, ... -}: let - inherit (import ../../../../hosts/${host}/variables.nix) location; -in { +}: { programs.noctalia-shell.settings.location = lib.mkForce { name = "${location}"; weatherEnabled = true; diff --git a/profiles/nvidia-laptop/default.nix b/profiles/nvidia-laptop/default.nix index 2c4444b..73bc064 100644 --- a/profiles/nvidia-laptop/default.nix +++ b/profiles/nvidia-laptop/default.nix @@ -1,6 +1,9 @@ -{host, ...}: let - inherit (import ../../hosts/${host}/variables.nix) intelID nvidiaID; -in { +{ + host, + intelID, + nvidiaID, + ... +}: { imports = [ ../../hosts/${host} ../../modules/drivers