From 31dd4950b13d83bfafa0ca9c0696290b04810072 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Wed, 28 Feb 2024 21:15:55 -0600 Subject: [PATCH] move more stuff --- flake.nix | 2 +- hosts/default.nix | 1 + hosts/desktop/configuration.nix | 90 ++++++++----------------- hosts/desktop/home.nix | 32 ++++++++- hosts/desktop/impermanence.nix | 21 ------ hosts/nas/configuration.nix | 77 +++++++++++---------- modules/hardware/gpu/amd/default.nix | 25 ------- modules/hardware/gpu/amd/options.nix | 9 --- modules/hardware/gpu/nvidia/default.nix | 42 ------------ modules/hardware/gpu/nvidia/options.nix | 8 --- share/amd/default.nix | 48 +++++++++++++ share/amd/options.nix | 22 ++++++ share/default.nix | 7 ++ share/impermanence/default.nix | 20 ++++++ share/nvidia/default.nix | 59 ++++++++++++++++ share/nvidia/options.nix | 27 ++++++++ 16 files changed, 287 insertions(+), 203 deletions(-) delete mode 100644 hosts/desktop/impermanence.nix delete mode 100644 modules/hardware/gpu/amd/default.nix delete mode 100644 modules/hardware/gpu/amd/options.nix delete mode 100644 modules/hardware/gpu/nvidia/default.nix delete mode 100644 modules/hardware/gpu/nvidia/options.nix create mode 100644 share/amd/default.nix create mode 100644 share/amd/options.nix create mode 100644 share/default.nix create mode 100644 share/impermanence/default.nix create mode 100644 share/nvidia/default.nix create mode 100644 share/nvidia/options.nix diff --git a/flake.nix b/flake.nix index 60e74d0..9f2d098 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ # kde.nixosModules.plasma6 nix-flatpak.nixosModules.nix-flatpak ./hosts/desktop/configuration.nix - ./hosts/desktop/impermanence.nix + ./share/impermanence home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/hosts/default.nix b/hosts/default.nix index 6bef595..057705d 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -6,6 +6,7 @@ in imports = [ ../modules + ../share ]; # Enable nix flakes and nix-command tools diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index 480b6bf..8a30f4c 100644 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -26,6 +26,12 @@ in ../default.nix ]; + share.hardware.amd = { + enable = true; + corectrl.enable = true; + corectrl.enablePolkit = true; + }; + # Configure bootloader with lanzaboot and secureboot boot = { loader = { @@ -54,7 +60,7 @@ in kernelPackages = pkgs.linuxPackages_latest; kernelParams = [ - "quiet" "amdgpu.ppfeaturemask=0xffffffff" + "quiet" ]; consoleLogLevel = 3; @@ -72,9 +78,9 @@ in # Steam udev rules for remote play steam-hardware.enable = true; - opengl.enable = true; - # Enables support for 32bit libs that steam uses - opengl.driSupport32Bit = true; + # opengl.enable = true; + # # Enables support for 32bit libs that steam uses + # opengl.driSupport32Bit = true; }; # Services configs @@ -112,25 +118,25 @@ in ]; }; - systemd.services.fix-wifi = { - path = [ pkgs.bash ]; - script = '' - sleep 5 - if ping -q -c1 10.0.1.1 &>/dev/null; then - echo "No need to fix wifi" - else - echo 1 | tee /sys/bus/pci/devices/0000\:09\:00.0/reset - rmmod iwlwifi - modprobe iwlwifi - fi - ''; - wantedBy = [ "multi-user.target" ]; - after = [ "NetworkManager.target" ]; - serviceConfig = { - Type="oneshot"; - RemainAfterExit=true; - }; - }; + # systemd.services.fix-wifi = { + # path = [ pkgs.bash ]; + # script = '' + # sleep 5 + # if ping -q -c1 10.0.1.1 &>/dev/null; then + # echo "No need to fix wifi" + # else + # echo 1 | tee /sys/bus/pci/devices/0000\:09\:00.0/reset + # rmmod iwlwifi + # modprobe iwlwifi + # fi + # ''; + # wantedBy = [ "multi-user.target" ]; + # after = [ "NetworkManager.target" ]; + # serviceConfig = { + # Type="oneshot"; + # RemainAfterExit=true; + # }; + # }; # Networking configs networking = { @@ -177,22 +183,6 @@ in groups = [ "wheel" ]; }]; }; - - # Configure polkit - polkit = { - enable = true; - extraConfig = '' - polkit.addRule(function(action, subject) { - if ((action.id == "org.corectrl.helper.init" || - action.id == "org.corectrl.helperkiller.init") && - subject.local == true && - subject.active == true && - subject.isInGroup("wheel")) { - return polkit.Result.YES; - } - }); - ''; - }; }; # Configure environment @@ -205,7 +195,6 @@ in nano os-prober efibootmgr - git sbctl gparted discover-wrapped @@ -218,26 +207,13 @@ in aspellDicts.en-science aha clinfo - neofetch - gamescope - gamescope-wsi - mangohud - goverlay - heroic - python3 - virt-manager - orca-slicer ]; - - # Force radv - # variables.AMD_VULKAN_ICD = "RADV"; }; # Configure programs programs = { fish.enable = true; java.enable = true; - # corectrl.enable = true; # Steam steam = { @@ -282,14 +258,6 @@ in isNormalUser = true; extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user. shell = pkgs.fish; - packages = with pkgs; [ - firefox - tree - lm_sensors - vmware-horizon-client - etcher - freerdp - ]; }; # This option defines the first version of NixOS you have installed on this particular machine, diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix index 89ac3e5..66de4b2 100644 --- a/hosts/desktop/home.nix +++ b/hosts/desktop/home.nix @@ -16,10 +16,40 @@ in enable = true; userName = "mjallen18"; userEmail = "matt.l.jallen@gmail.com"; + aliases = { + co = "checkout"; + ci = "commit"; + cia = "commit --amend"; + s = "status"; + st = "status"; + b = "branch"; + # p = "pull --rebase"; + pu = "push"; + }; }; - home.packages = [ + programs.command-not-found.enable = true; + + home.packages = with pkgs; [ + firefox + tree + lm_sensors + vmware-horizon-client + etcher + freerdp + neofetch + gamescope + gamescope-wsi + mangohud + goverlay + heroic + python3 + virt-manager + orca-slicer # Other packages vulkan-hdr-layer ]; + + # Garbage collect automatically every week + nix.gc.automatic = true; } diff --git a/hosts/desktop/impermanence.nix b/hosts/desktop/impermanence.nix deleted file mode 100644 index 5083590..0000000 --- a/hosts/desktop/impermanence.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ pkgs, lib, LT, config, utils, inputs, ... }@args: - -{ -# Set up impernance configuration for things like bluetooth -# In this configuration with /etc and /var/log being persistent, only directories outside of that need to be done here. See hardware configuration for all mountpoints. - - environment.persistence."/nix/persist/system" = { - hideMounts = true; - directories = [ - "/var/lib/bluetooth" - "/var/lib/nixos" - "/var/lib/systemd/coredump" - "/etc/NetworkManager/system-connections" - "/etc/secureboot" - { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } - ]; - files = [ - { file = "/etc/nix/id_rsa"; parentDirectory = { mode = "u=rwx,g=,o="; }; } - ]; - }; -} \ No newline at end of file diff --git a/hosts/nas/configuration.nix b/hosts/nas/configuration.nix index f6947c3..ceee60d 100644 --- a/hosts/nas/configuration.nix +++ b/hosts/nas/configuration.nix @@ -110,7 +110,12 @@ in ]; }; - + share.hardware.nvidia = { + enable = true; + enableBeta = true; + nvidiaSettings = true; + enableNvidiaDocker = true; + } # Configure bootloader with lanzaboot and secureboot boot = { @@ -142,43 +147,43 @@ in zfs.requestEncryptionCredentials = false; }; - # Hardware configs - hardware = { - # Nvidia - nvidia = { - package = config.boot.kernelPackages.nvidiaPackages.beta; + # # Hardware configs + # hardware = { + # # Nvidia + # nvidia = { + # package = config.boot.kernelPackages.nvidiaPackages.beta; - # Modesetting is required. - modesetting.enable = true; + # # Modesetting is required. + # modesetting.enable = true; - # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - powerManagement.enable = false; + # # Nvidia power management. Experimental, and can cause sleep/suspend to fail. + # 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; + # # 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; + # # 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; - }; + # # Enable the Nvidia settings menu, + # # accessible via `nvidia-settings`. + # nvidiaSettings = true; + # }; - # Enable OpenGL - opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - }; + # # Enable OpenGL + # opengl = { + # enable = true; + # driSupport = true; + # driSupport32Bit = true; + # }; + # }; # Services configs services = { @@ -186,8 +191,8 @@ in xserver = { enable = true; - # Load nvidia driver for Xorg and Wayland - videoDrivers = ["nvidia"]; + # # Load nvidia driver for Xorg and Wayland + # videoDrivers = ["nvidia"]; # Enable the Plasma 6 Desktop Environment. displayManager = { @@ -338,6 +343,8 @@ in "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCw9zq8DLGByI5v2gAn95hKNyOsm3g61a2buxu2BBMFysQJgmZPCCLUqRJKhSM5Vm/JOgsAmdpRBRZQoHD+6S844CJHb4v4VIbjkyQgYCuM7Rst2IOZ5QybvsA2/D0nwytZ+HXQqDj2AagUYDbz0gyyIHkDQ5YGBMkvkWz/h1Vci6aoBM7VihEDM4KlWoTVuPeASGM8r5IZ2FS83Djbqo4ov6AYvLMrKB9Z7hmFgH6R3LE0gxOkzbGVXtSuvJyrjvgytoT22UhATjjxSQ9D+YJXXkQoB3lUdg8OoIquUPjMZpl4mR8ffvseWPfcvD1XlD5t+TOHFqKpESO547tlOBYhdpew+NSgAXpamCU6oyV8tDCywLQu2ucxHRn78u6WXzWHkDtffdhzmk6TZaPhWqVHuTGjR4higBgGqUfSaKOMszt+FDRZAr3HtuQ2+zJ8bowK9fW5OqilTtK2HtQqroD9ApegDNbqOz6kGy5IycSXvqPURy/M4lxZxbtBPuemcJs= mattjallen@MacBook-Pro.local" # desktop windows "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDZ2PYPjZddOzR8OJj16G88KcUhCDLkvrEmpUQP0wKHDUuA27HQQ2ORo66asadwGHY3k1VDZ1ei9l9H++SIIeKOaaUr5yZdktvj4POUNtbd9ZhcS7sZU7BSF+NMDM+h3tImh6z0S7mWvRQOUv3ZM+ZER+5xTWJVG1OOJEpb1drxJk6Qz0wbZKSR7TPNFBLLXlVy7hkNYf07RtDyhCCxNB3hJfa8c+oztnWumwDhDQWLqiUXWIU2QH6iRLGl/WYnujtNvVVaV/Hn3JJkS6MM9dnV3cpoIO0+J7+WfsN9rZ0wXt5yY3GhiGXwmcO5eYVli8lHlLWtK7aYSETyry6CBsLbojzOQO5rSqhpwfF2njAAFAQU0UjLc8PahisIuFKCwHH4iyXXOagiv5K1Mc/0Ak+WhhMPee6vV2p7NTyNpXRvouDbWy5cSRH31WgQ9fK5mIGe5v8nGGqtEhUubUkiOgP+H3UbT2V/nTv/TFKdJcKw+WmizvTrxBmaMjWALlkYl+s= mattl@Jallen-PC" + # desktop nixos + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTBMydhOc6SnOdB5WrEd7X07DrboAtagCUgXiOJjLov matt@matt-nixos" ]; packages = with pkgs; [ neofetch @@ -367,7 +374,7 @@ in virtualisation = { docker = { enable = true; - enableNvidia = true; + # enableNvidia = true; enableOnBoot = true; }; diff --git a/modules/hardware/gpu/amd/default.nix b/modules/hardware/gpu/amd/default.nix deleted file mode 100644 index dd0ea00..0000000 --- a/modules/hardware/gpu/amd/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ lib, pkgs, config, ... }: -with lib; -let - cfg = config.hardware.gpu.amd; -in { - kernelParams = [ "amdgpu.ppfeaturemask=0xffffffff" ]; - - # Configure programs - programs = { corectrl.enable }; - - # Configure environment - environment = { - # Force radv - variables.AMD_VULKAN_ICD = "RADV"; - }; - # Hardware configs - hardware = { - # Enable OpenGL - opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - }; -} diff --git a/modules/hardware/gpu/amd/options.nix b/modules/hardware/gpu/amd/options.nix deleted file mode 100644 index 6ab49ed..0000000 --- a/modules/hardware/gpu/amd/options.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ lib, ... }: -with lib; -{ - options.hardware.gpu.amd = { - enable = mkEnableOption "amd hardware config"; - - - }; -} diff --git a/modules/hardware/gpu/nvidia/default.nix b/modules/hardware/gpu/nvidia/default.nix deleted file mode 100644 index 8e31ded..0000000 --- a/modules/hardware/gpu/nvidia/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ lib, pkgs, config, ... }: -with lib; -let - cfg = config.hardware.gpu.nvidia; -in { - hardware = { - # Nvidia - nvidia = { - package = config.boot.kernelPackages.nvidiaPackages.beta; - - # Modesetting is required. - modesetting.enable = true; - - # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - 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; - }; - - # Enable OpenGL - opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - }; -} diff --git a/modules/hardware/gpu/nvidia/options.nix b/modules/hardware/gpu/nvidia/options.nix deleted file mode 100644 index 473cba8..0000000 --- a/modules/hardware/gpu/nvidia/options.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ lib, ... }: -with lib; -{ - options.hardware.gpu.nvidia = { - enable = mkEnableOption "nvidia hardware config"; - - }; -} diff --git a/share/amd/default.nix b/share/amd/default.nix new file mode 100644 index 0000000..fac8da6 --- /dev/null +++ b/share/amd/default.nix @@ -0,0 +1,48 @@ +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.share.hardware.amd; +in { + imports = [ + ./options.nix + ]; + + config = mkIf cfg.enable { + boot.kernelParams = [ (if cfg.corectrl.enable then "amdgpu.ppfeaturemask=0xffffffff" else "") ]; + + # Configure programs + programs.corectrl.enable = cfg.corectrl.enable; + + # Configure environment + environment = { + # Force radv + variables.AMD_VULKAN_ICD = "RADV"; + }; + + # Hardware configs + hardware = { + # Enable OpenGL + opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + }; + + # Configure polkit + security.polkit = { + enable = cfg.corectrl.enablePolkit; + extraConfig = '' + polkit.addRule(function(action, subject) { + if ((action.id == "org.corectrl.helper.init" || + action.id == "org.corectrl.helperkiller.init") && + subject.local == true && + subject.active == true && + subject.isInGroup("${cfg.corectrl.polkitGroup}")) { + return polkit.Result.YES; + } + }); + ''; + }; + }; +} diff --git a/share/amd/options.nix b/share/amd/options.nix new file mode 100644 index 0000000..b0f4d3b --- /dev/null +++ b/share/amd/options.nix @@ -0,0 +1,22 @@ +{ lib, ... }: +with lib; +{ + options.share.hardware.amd = { + enable = mkEnableOption "amd hardware config"; + + corectrl.enable = mkOption { + type = types.bool; + default = false; + }; + + corectrl.enablePolkit = mkOption { + type = types.bool; + default = false; + }; + + corectrl.polkitGroup = mkOption { + type = types.str; + default = "wheel"; + }; + }; +} diff --git a/share/default.nix b/share/default.nix new file mode 100644 index 0000000..0a7b41a --- /dev/null +++ b/share/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ./amd + ./nvidia + ]; +} \ No newline at end of file diff --git a/share/impermanence/default.nix b/share/impermanence/default.nix new file mode 100644 index 0000000..5712bc5 --- /dev/null +++ b/share/impermanence/default.nix @@ -0,0 +1,20 @@ +{ pkgs, lib, LT, config, utils, inputs, ... }@args: +{ + # Set up impernance configuration for things like bluetooth + # In this configuration with /etc and /var/log being persistent, only directories outside of that need to be done here. See hardware configuration for all mountpoints. + + environment.persistence."/nix/persist/system" = { + hideMounts = true; + directories = [ + "/var/lib/bluetooth" + "/var/lib/nixos" + "/var/lib/systemd/coredump" + "/etc/NetworkManager/system-connections" + "/etc/secureboot" + { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } + ]; + files = [ + { file = "/etc/nix/id_rsa"; parentDirectory = { mode = "u=rwx,g=,o="; }; } + ]; + }; +} \ No newline at end of file diff --git a/share/nvidia/default.nix b/share/nvidia/default.nix new file mode 100644 index 0000000..2062a14 --- /dev/null +++ b/share/nvidia/default.nix @@ -0,0 +1,59 @@ +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.share.hardware.nvidia; +in { + imports = [ + ./options.nix + ]; + + config = mkIf cfg.enable { + hardware = { + # Nvidia + nvidia = { + package = if cfg.enableBeta then config.boot.kernelPackages.nvidiaPackages.beta else config.boot.kernelPackages.nvidiaPackages.latest; + + # Modesetting is required. + modesetting.enable = true; + + # Nvidia power management. Experimental, and can cause sleep/suspend to fail. + 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 = cfg.enableOpen; + + # Enable the Nvidia settings menu, + # accessible via `nvidia-settings`. + nvidiaSettings = cfg.nvidiaSettings; + }; + + # Enable OpenGL + opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + }; + + + # Services configs + services.xserver = { + # Load nvidia driver for Xorg and Wayland + videoDrivers = ["nvidia"]; + }; + + + # Virtualisation + virtualisation.docker.enableNvidia = cfg.enableNvidiaDocker; + }; +} diff --git a/share/nvidia/options.nix b/share/nvidia/options.nix new file mode 100644 index 0000000..5c73d96 --- /dev/null +++ b/share/nvidia/options.nix @@ -0,0 +1,27 @@ +{ lib, ... }: +with lib; +{ + options.share.hardware.nvidia = { + enable = mkEnableOption "nvidia hardware config"; + + enableOpen = mkOption { + type = types.bool; + default = false; + }; + + nvidiaSettings = mkOption { + type = types.bool; + default = false; + }; + + enableBeta = mkOption { + type = types.bool; + default = false; + }; + + enableNvidiaDocker = mkOption { + type = types.bool; + default = false; + }; + }; +}