From a83e4dba54212933640fd7dd4e1ad2ac481c89b6 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Tue, 23 Jul 2024 17:24:18 +0300 Subject: [PATCH] feat(roles/graphics): merge graphics roles --- hosts/alice/default.nix | 5 ++++- hosts/arwen/default.nix | 5 ++++- roles/amdgpu.nix | 24 ------------------------ roles/default.nix | 3 +-- roles/graphics/amd.nix | 13 +++++++++++++ roles/graphics/default.nix | 26 ++++++++++++++++++++++++++ roles/{ => graphics}/nvidia.nix | 14 ++------------ 7 files changed, 50 insertions(+), 40 deletions(-) delete mode 100644 roles/amdgpu.nix create mode 100644 roles/graphics/amd.nix create mode 100644 roles/graphics/default.nix rename roles/{ => graphics}/nvidia.nix (56%) diff --git a/hosts/alice/default.nix b/hosts/alice/default.nix index 0f6d798..31b035d 100644 --- a/hosts/alice/default.nix +++ b/hosts/alice/default.nix @@ -33,7 +33,10 @@ roles.zellij.enable = true; roles.kitty.enable = true; - roles.nvidia.enable = true; + roles.graphics = { + enable = true; + nvidia.enable = true; + }; roles.plasma.enable = true; roles.gaming = { diff --git a/hosts/arwen/default.nix b/hosts/arwen/default.nix index 689aa78..91c98c6 100644 --- a/hosts/arwen/default.nix +++ b/hosts/arwen/default.nix @@ -37,7 +37,10 @@ roles.zellij.enable = true; roles.kitty.enable = true; - roles.amdgpu.enable = true; + roles.graphics = { + enable = true; + amd.enable = true; + }; roles.hyprland.enable = true; roles.gaming = { diff --git a/roles/amdgpu.nix b/roles/amdgpu.nix deleted file mode 100644 index 830b8b4..0000000 --- a/roles/amdgpu.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - config, - lib, - ... -}: let - cfg = config.roles.amdgpu; -in { - options.roles.amdgpu = { - enable = lib.mkEnableOption "AMDGPU drivers"; - }; - - - config = lib.mkIf cfg.enable { - boot.initrd.kernelModules = ["amdgpu"]; - - services.xserver.videoDrivers = ["amdgpu"]; - - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - }; -} diff --git a/roles/default.nix b/roles/default.nix index 7266cae..edeb495 100644 --- a/roles/default.nix +++ b/roles/default.nix @@ -1,9 +1,9 @@ {...}: { imports = [ ./gaming + ./graphics ./shell - ./amdgpu.nix # FIXME: merge with nvidia.nix to graphics/ role ./audio.nix ./bluetooth.nix ./base.nix @@ -11,7 +11,6 @@ ./hyprland.nix ./kitty.nix ./nix.nix - ./nvidia.nix ./plasma.nix ./qutebrowser.nix ./zellij.nix diff --git a/roles/graphics/amd.nix b/roles/graphics/amd.nix new file mode 100644 index 0000000..2824236 --- /dev/null +++ b/roles/graphics/amd.nix @@ -0,0 +1,13 @@ +{ + config, + lib, + ... +}: let + cfg = config.roles.graphics; +in { + config = lib.mkIf cfg.amd.enable { + boot.initrd.kernelModules = ["amdgpu"]; + + services.xserver.videoDrivers = ["amdgpu"]; + }; +} diff --git a/roles/graphics/default.nix b/roles/graphics/default.nix new file mode 100644 index 0000000..5bacd57 --- /dev/null +++ b/roles/graphics/default.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + ... +}: let + cfg = config.roles.graphics; +in { + imports = [ + ./amd.nix + ./nvidia.nix + ]; + + options.roles.graphics = { + enable = lib.mkEnableOption "graphics drivers"; + amd.enable = lib.mkEnableOption "AMDGPU drivers"; + nvidia.enable = lib.mkEnableOption "NVIDIA drivers"; + }; + + config = lib.mkIf cfg.enable { + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + }; + } diff --git a/roles/nvidia.nix b/roles/graphics/nvidia.nix similarity index 56% rename from roles/nvidia.nix rename to roles/graphics/nvidia.nix index 1e79f45..1b24981 100644 --- a/roles/nvidia.nix +++ b/roles/graphics/nvidia.nix @@ -3,23 +3,13 @@ lib, ... }: let - cfg = config.roles.nvidia; + cfg = config.roles.graphics; in { - options.roles.nvidia = { - enable = lib.mkEnableOption "NVIDIA drivers"; - }; - - config = lib.mkIf cfg.enable { + config = lib.mkIf cfg.nvidia.enable { arta.unfree.allow = ["nvidia-x11"]; services.xserver.videoDrivers = ["nvidia"]; - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - hardware.nvidia = { modesetting.enable = true; powerManagement.enable = true; -- 2.44.1