From 2213d099d0f4239a2c648ba10188427132114872 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Fri, 20 Sep 2024 21:28:53 -0500 Subject: [PATCH] moved hardware configuration software options to hardware.nix --- README.md | 2 +- hosts/defiant/hardware-configuration.nix | 12 ++-- hosts/hardware-common.nix | 16 +++++ hosts/horizon/hardware-configuration.nix | 17 +++-- hosts/twilight/configuration.nix | 3 - hosts/twilight/hardware-configuration.nix | 88 ++++++++++++----------- users/leyla/default.nix | 3 - users/leyla/packages.nix | 6 +- 8 files changed, 85 insertions(+), 62 deletions(-) create mode 100644 hosts/hardware-common.nix diff --git a/README.md b/README.md index 06850ce..96a36ab 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ updating passwords: `sops secrets/secrets.yaml` ## Tech Debt - allowUnfree should be enabled user side not host side (this isn't enabled at all right now for some reason???) -- Move configs for pipe mouse, open rgb, and via keyboard to hardware config and install users side from those configs - have nfs binds and exports defined by same code - move services from defiant into own flake - made base domain in nas services configurable - vscode extensions should be in own flake (make sure to add the nixpkgs.overlays in it too) +- server service system users should also be on local systems for file permission reasons ## New Features - GNOME default monitors per hardware configuration? - offline access for nfs mounts (overlay with rsync might be a good option here? https://www.spinics.net/lists/linux-unionfs/msg07105.html note about nfs4 and overlay fs) diff --git a/hosts/defiant/hardware-configuration.nix b/hosts/defiant/hardware-configuration.nix index 3ba63d0..60e940b 100644 --- a/hosts/defiant/hardware-configuration.nix +++ b/hosts/defiant/hardware-configuration.nix @@ -4,9 +4,10 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ../hardware-common.nix + ]; boot = { initrd = { @@ -41,5 +42,8 @@ }; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware = { + # TODO: hardware graphics + cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; } \ No newline at end of file diff --git a/hosts/hardware-common.nix b/hosts/hardware-common.nix new file mode 100644 index 0000000..dea9450 --- /dev/null +++ b/hosts/hardware-common.nix @@ -0,0 +1,16 @@ +{ lib, ... }: +{ + options = { + hardware = { + piperMouse = { + enable = lib.mkEnableOption "host has a piper mouse"; + }; + viaKeyboard = { + enable = lib.mkEnableOption "host has a via keyboard"; + }; + openRGB = { + enable = lib.mkEnableOption "host has open rgb hardware"; + }; + }; + }; +} \ No newline at end of file diff --git a/hosts/horizon/hardware-configuration.nix b/hosts/horizon/hardware-configuration.nix index 59a900d..82e1bf7 100644 --- a/hosts/horizon/hardware-configuration.nix +++ b/hosts/horizon/hardware-configuration.nix @@ -4,9 +4,10 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ../hardware-common.nix + ]; boot = { initrd = { @@ -23,9 +24,6 @@ }; }; - - hardware.graphics.enable = true; - fileSystems = { "/" = { device = "/dev/disk/by-uuid/866d422b-f816-4ad9-9846-791839cb9337"; @@ -100,5 +98,10 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + + hardware = { + graphics.enable = true; + cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; } diff --git a/hosts/twilight/configuration.nix b/hosts/twilight/configuration.nix index 1352c8b..727f028 100644 --- a/hosts/twilight/configuration.nix +++ b/hosts/twilight/configuration.nix @@ -14,9 +14,6 @@ users = { leyla = { isFullUser = true; - hasPiperMouse = true; - hasOpenRGBHardware = true; - hasViaKeyboard = true; hasGPU = true; }; ester.isFullUser = true; diff --git a/hosts/twilight/hardware-configuration.nix b/hosts/twilight/hardware-configuration.nix index ab24b97..0f77e81 100644 --- a/hosts/twilight/hardware-configuration.nix +++ b/hosts/twilight/hardware-configuration.nix @@ -4,9 +4,10 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ../hardware-common.nix + ]; boot = { initrd = { @@ -31,43 +32,6 @@ displayManager.gdm.wayland = false; }; - hardware = { - # Enable OpenGL - graphics.enable = true; - - # install graphics drivers - nvidia = { - # Modesetting is required. - modesetting.enable = true; - - # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - # Enable this if you have graphical corruption issues or application crashes after waking - # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead - # of just the bare essentials. - powerManagement.enable = false; - - # Fine-grained power management. Turns off GPU when not in use. - # Experimental and only works on modern Nvidia GPUs (Turing or newer). - powerManagement.finegrained = false; - - # Use the NVidia open source kernel module (not to be confused with the - # independent third-party "nouveau" open source driver). - # Support is limited to the Turing and later architectures. Full list of - # supported GPUs is at: - # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus - # Only available from driver 515.43.04+ - # Currently alpha-quality/buggy, so false is currently the recommended setting. - open = false; - - # Enable the Nvidia settings menu, - # accessible via `nvidia-settings`. - nvidiaSettings = true; - - # Optionally, you may need to select the appropriate driver version for your specific GPU. - package = config.boot.kernelPackages.nvidiaPackages.production; - }; - }; - fileSystems = { "/" = { device = "/dev/disk/by-uuid/8be49c65-2b57-48f1-b74d-244d26061adb"; @@ -114,6 +78,48 @@ }; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + hardware = { + piperMouse.enable = true; + viaKeyboard.enable = true; + openRGB.enable = true; + + # Enable OpenGL + graphics.enable = true; + + # install graphics drivers + nvidia = { + # Modesetting is required. + modesetting.enable = true; + + # Nvidia power management. Experimental, and can cause sleep/suspend to fail. + # Enable this if you have graphical corruption issues or application crashes after waking + # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead + # of just the bare essentials. + powerManagement.enable = false; + + # Fine-grained power management. Turns off GPU when not in use. + # Experimental and only works on modern Nvidia GPUs (Turing or newer). + powerManagement.finegrained = false; + + # Use the NVidia open source kernel module (not to be confused with the + # independent third-party "nouveau" open source driver). + # Support is limited to the Turing and later architectures. Full list of + # supported GPUs is at: + # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus + # Only available from driver 515.43.04+ + # Currently alpha-quality/buggy, so false is currently the recommended setting. + open = false; + + # Enable the Nvidia settings menu, + # accessible via `nvidia-settings`. + nvidiaSettings = true; + + # Optionally, you may need to select the appropriate driver version for your specific GPU. + package = config.boot.kernelPackages.nvidiaPackages.production; + }; + + cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + }; } diff --git a/users/leyla/default.nix b/users/leyla/default.nix index 7a8dc54..42fd3ab 100644 --- a/users/leyla/default.nix +++ b/users/leyla/default.nix @@ -10,9 +10,6 @@ in options.users.leyla = { isFullUser = lib.mkEnableOption "create usable leyla user"; isThinUser = lib.mkEnableOption "create usable user but witohut user applications"; - hasPiperMouse = lib.mkEnableOption "install programs for managing piper supported mouses"; - hasOpenRGBHardware = lib.mkEnableOption "install programs for managing openRGB supported hardware"; - hasViaKeyboard = lib.mkEnableOption "install programs for managing via supported keyboards"; hasGPU = lib.mkEnableOption "installs gpu intensive programs"; }; diff --git a/users/leyla/packages.nix b/users/leyla/packages.nix index 223f568..756593a 100644 --- a/users/leyla/packages.nix +++ b/users/leyla/packages.nix @@ -118,9 +118,9 @@ in noisetorch # hardware managment tools - (lib.mkIf cfg.hasPiperMouse piper) - (lib.mkIf cfg.hasOpenRGBHardware openrgb) - (lib.mkIf cfg.hasViaKeyboard via) + (lib.mkIf config.hardware.piperMouse.enable piper) + (lib.mkIf config.hardware.openRGB.enable openrgb) + (lib.mkIf config.hardware.viaKeyboard.enable via) ] ) )