From 8b4d73b2e3175c2af538ca3296c9434d6e152a8f Mon Sep 17 00:00:00 2001 From: blake Date: Sat, 4 Oct 2025 11:46:34 -0500 Subject: [PATCH] restructure system to be toggable --- hosts/snowbelle/configuration.nix | 26 +++++++++++++++++-------- modules/system/docker.nix | 14 ++++++++++---- modules/system/nvidia.nix | 32 ++++++++++++++++++------------- modules/system/ssh.nix | 22 ++++++++++++--------- modules/system/syncthing.nix | 24 ++++++++++++++--------- modules/system/tailscale.nix | 14 ++++++++++---- 6 files changed, 85 insertions(+), 47 deletions(-) diff --git a/hosts/snowbelle/configuration.nix b/hosts/snowbelle/configuration.nix index fd1b2a6..6d9bb43 100644 --- a/hosts/snowbelle/configuration.nix +++ b/hosts/snowbelle/configuration.nix @@ -5,20 +5,30 @@ [ # Include the results of the hardware scan. ./hardware-configuration.nix ../../users/blake/blake.nix - ../../modules/system/ssh.nix - ../../modules/system/docker.nix - ../../modules/system/syncthing.nix - ../../modules/system/tailscale.nix + ../../modules/system/system.nix +# ../../modules/system/ssh.nix +# ../../modules/system/docker.nix +# ../../modules/system/syncthing.nix +# ../../modules/system/tailscale.nix ../../modules/homelab/homelab.nix # ../../modules/homelab/zfs.nix # ../../modules/homelab/smb.nix # ../../modules/homelab/nfs.nix ]; - modules.homelab = { - zfs.enable = true; - smb.enable = false; - nfs.enable = true; + modules = { + system = { + ssh.enable = true; + docker.enable = true; + syncthing.enable = true; + tailscale.enable = true; + #nvidia.enable = true; + }; + homelab = { + zfs.enable = true; + smb.enable = true; + nfs.enable = true; + }; }; diff --git a/modules/system/docker.nix b/modules/system/docker.nix index d0698bc..cc14094 100644 --- a/modules/system/docker.nix +++ b/modules/system/docker.nix @@ -1,10 +1,16 @@ { config, pkgs, ... }: { - virtualisation.docker = { - enable = true; - daemon.settings = { - experimental = true; + options = { + modules.system.docker.enable = lib.mkEnableOption "enables docker"; + }; + + config = lib.mkIf config.modules.system.docker.enable { + virtualisation.docker = { + enable = true; + daemon.settings = { + experimental = true; + }; }; }; } diff --git a/modules/system/nvidia.nix b/modules/system/nvidia.nix index 6a6dd65..f7bcead 100644 --- a/modules/system/nvidia.nix +++ b/modules/system/nvidia.nix @@ -1,20 +1,26 @@ { config, pkgs, lib, ... }: { - # enable nvidia proprietary driver - hardware.nvidia = { - modesetting.enable = true; # required - open = false; # use proprietary driver - nvidiaSettings = true; # no shit - powerManagement.enable = false; # can cause sleep issues - package = config.boot.kernelPackages.nvidiaPackages.stable; + options = { + modules.system.nvidia.enable = lib.mkEnableOption "enables nvidia"; }; - # install nvidia-smi - environment.systemPackages = with pkgs; [ - nvidia-smi - ]; + config = lib.mkIf config.modules.system.nvidia.enable { + # enable nvidia proprietary driver + hardware.nvidia = { + modesetting.enable = true; # required + open = false; # use proprietary driver + nvidiaSettings = true; # no shit + powerManagement.enable = false; # can cause sleep issues + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; - # enable docker gpu passthrough - virtualisation.docker.enableNvidia = true; + # install nvidia-smi + environment.systemPackages = with pkgs; [ + nvidia-smi + ]; + + # enable docker gpu passthrough + virtualisation.docker.enableNvidia = true; + }; } diff --git a/modules/system/ssh.nix b/modules/system/ssh.nix index c3327fa..527492e 100644 --- a/modules/system/ssh.nix +++ b/modules/system/ssh.nix @@ -1,15 +1,19 @@ { config, lib, pkgs, ... }: { - # enable and configure openssh - services.openssh = { - enable = true; - settings = { - PasswordAuthentication = true; - PermitRootLogin = "no"; - X11Forwarding = false; - }; + options = { + modules.system.ssh.enable = lib.mkEnableOption "enables ssh"; }; - + config = lib.mkIf config.modules.system.ssh.enable { + # enable and configure openssh + services.openssh = { + enable = true; + settings = { + PasswordAuthentication = true; + PermitRootLogin = "no"; + X11Forwarding = false; + }; + }; + }; } diff --git a/modules/system/syncthing.nix b/modules/system/syncthing.nix index 4db4f65..759a764 100644 --- a/modules/system/syncthing.nix +++ b/modules/system/syncthing.nix @@ -1,16 +1,22 @@ { config, pkgs, ... }: { - services.syncthing = { - enable = true; - user = "blake"; - group = "blake"; + options = { + modules.system.syncthing.enable = lib.mkEnableOption "enables syncthing"; + }; - dataDir = "/home/blake/.local/state/syncthing"; - configDir = "/home/blake/.config/syncthing"; + config = lib.mkIf config.modules.system.syncthing.enable { + services.syncthing = { + enable = true; + user = "blake"; + group = "blake"; - # webui - guiAddress = "0.0.0.0:2222"; - openDefaultPorts = true; + dataDir = "/home/blake/.local/state/syncthing"; + configDir = "/home/blake/.config/syncthing"; + + # webui + guiAddress = "0.0.0.0:2222"; + openDefaultPorts = true; + }; }; } diff --git a/modules/system/tailscale.nix b/modules/system/tailscale.nix index f0d85da..a861e64 100644 --- a/modules/system/tailscale.nix +++ b/modules/system/tailscale.nix @@ -1,10 +1,16 @@ { config, pkgs, ... }: { - services.tailscale = { - enable = true; + options = { + modules.system.tailscale.enable = lib.mkEnableOption "enables tailscale"; + }; - useRoutingFeatures = "both"; - authKeyFile = "/home/blake/.nix/.keyring/tailscale/authkey"; + config = lib.mkIf config.modules.system.tailscale.enable { + services.tailscale = { + enable = true; + + useRoutingFeatures = "both"; + authKeyFile = "/home/blake/.nix/.keyring/tailscale/authkey"; + }; }; }