From fe1a1d3fb27784a9e2e30573f474300707efdb6d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 4 Feb 2024 14:37:31 +0000 Subject: [PATCH 1/5] nixos: hardware: add graphics --- modules/nixos/hardware/default.nix | 1 + modules/nixos/hardware/graphics/default.nix | 75 +++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 modules/nixos/hardware/graphics/default.nix diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 2a686f7..95e6a22 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -6,6 +6,7 @@ ./bluetooth ./ergodox ./firmware + ./graphics ./mx-ergo ./networking ./sound diff --git a/modules/nixos/hardware/graphics/default.nix b/modules/nixos/hardware/graphics/default.nix new file mode 100644 index 0000000..3baac02 --- /dev/null +++ b/modules/nixos/hardware/graphics/default.nix @@ -0,0 +1,75 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.hardware.graphics; +in +{ + options.my.hardware.graphics = with lib; { + enable = mkEnableOption "graphics configuration"; + + gpuFlavor = mkOption { + type = with types; nullOr (enum [ "amd" "intel" ]); + default = null; + example = "intel"; + description = "Which kind of GPU to install driver for"; + }; + + amd = { + enableKernelModule = lib.my.mkDisableOption "Kernel driver module"; + + amdvlk = lib.mkEnableOption "Use AMDVLK instead of Mesa RADV driver"; + }; + + intel = { + enableKernelModule = lib.my.mkDisableOption "Kernel driver module"; + }; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + hardware.opengl = { + enable = true; + }; + } + + # AMD GPU + (lib.mkIf (cfg.gpuFlavor == "amd") { + boot.initrd.kernelModules = lib.mkIf cfg.amd.enableKernelModule [ "amdgpu" ]; + + hardware.opengl = { + extraPackages = with pkgs; [ + # OpenCL + rocmPackages.clr + rocmPackages.clr.icd + ] + ++ lib.optional cfg.amd.amdvlk amdvlk + ; + + extraPackages32 = with pkgs; [ + ] + ++ lib.optional cfg.amd.amdvlk driversi686Linux.amdvlk + ; + }; + }) + + # Intel GPU + (lib.mkIf (cfg.gpuFlavor == "intel") { + boot.initrd.kernelModules = lib.mkIf cfg.intel.enableKernelModule [ "i915" ]; + + environment.variables = { + VDPAU_DRIVER = "va_gl"; + }; + + hardware.opengl = { + extraPackages = with pkgs; [ + # Open CL + intel-compute-runtime + + # VA API + intel-media-driver + intel-vaapi-driver + libvdpau-va-gl + ]; + }; + }) + ]); +} From b7d9ef4800f6051f8cf9b8902f5ffd2ca475fadf Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 4 Feb 2024 14:39:29 +0000 Subject: [PATCH 2/5] hosts: nixos: aramis: hardware: enable graphics --- hosts/nixos/aramis/hardware.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hosts/nixos/aramis/hardware.nix b/hosts/nixos/aramis/hardware.nix index c66b426..99bc77e 100644 --- a/hosts/nixos/aramis/hardware.nix +++ b/hosts/nixos/aramis/hardware.nix @@ -26,6 +26,12 @@ firmware = { cpuFlavor = "intel"; }; + + graphics = { + enable = true; + + gpuFlavor = "intel"; + }; }; hardware = { From f54cee8f70cd569fcc77093e7330f327ee1b3970 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 4 Feb 2024 14:37:31 +0000 Subject: [PATCH 3/5] nixos: hardware: add graphics I did not add an Nvidia knob to this module, as I do not foresee *ever* using one of their graphics card. --- modules/nixos/hardware/default.nix | 1 + modules/nixos/hardware/graphics/default.nix | 75 +++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 modules/nixos/hardware/graphics/default.nix diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 2a686f7..95e6a22 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -6,6 +6,7 @@ ./bluetooth ./ergodox ./firmware + ./graphics ./mx-ergo ./networking ./sound diff --git a/modules/nixos/hardware/graphics/default.nix b/modules/nixos/hardware/graphics/default.nix new file mode 100644 index 0000000..3baac02 --- /dev/null +++ b/modules/nixos/hardware/graphics/default.nix @@ -0,0 +1,75 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.hardware.graphics; +in +{ + options.my.hardware.graphics = with lib; { + enable = mkEnableOption "graphics configuration"; + + gpuFlavor = mkOption { + type = with types; nullOr (enum [ "amd" "intel" ]); + default = null; + example = "intel"; + description = "Which kind of GPU to install driver for"; + }; + + amd = { + enableKernelModule = lib.my.mkDisableOption "Kernel driver module"; + + amdvlk = lib.mkEnableOption "Use AMDVLK instead of Mesa RADV driver"; + }; + + intel = { + enableKernelModule = lib.my.mkDisableOption "Kernel driver module"; + }; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + hardware.opengl = { + enable = true; + }; + } + + # AMD GPU + (lib.mkIf (cfg.gpuFlavor == "amd") { + boot.initrd.kernelModules = lib.mkIf cfg.amd.enableKernelModule [ "amdgpu" ]; + + hardware.opengl = { + extraPackages = with pkgs; [ + # OpenCL + rocmPackages.clr + rocmPackages.clr.icd + ] + ++ lib.optional cfg.amd.amdvlk amdvlk + ; + + extraPackages32 = with pkgs; [ + ] + ++ lib.optional cfg.amd.amdvlk driversi686Linux.amdvlk + ; + }; + }) + + # Intel GPU + (lib.mkIf (cfg.gpuFlavor == "intel") { + boot.initrd.kernelModules = lib.mkIf cfg.intel.enableKernelModule [ "i915" ]; + + environment.variables = { + VDPAU_DRIVER = "va_gl"; + }; + + hardware.opengl = { + extraPackages = with pkgs; [ + # Open CL + intel-compute-runtime + + # VA API + intel-media-driver + intel-vaapi-driver + libvdpau-va-gl + ]; + }; + }) + ]); +} From 183f3b48c822ddd482bc2609c8053b966f4b1d7a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 4 Feb 2024 14:39:29 +0000 Subject: [PATCH 4/5] hosts: nixos: aramis: hardware: enable graphics --- hosts/nixos/aramis/hardware.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hosts/nixos/aramis/hardware.nix b/hosts/nixos/aramis/hardware.nix index c66b426..99bc77e 100644 --- a/hosts/nixos/aramis/hardware.nix +++ b/hosts/nixos/aramis/hardware.nix @@ -26,6 +26,12 @@ firmware = { cpuFlavor = "intel"; }; + + graphics = { + enable = true; + + gpuFlavor = "intel"; + }; }; hardware = { From 7948dc284b0dd7d2cd48932bc52ae64d90a9c01b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 6 Feb 2024 15:08:16 +0000 Subject: [PATCH 5/5] nixos: hardware: rename 'trackball' Since I do intend on configuring every trackball I own to use this scheme, not just the MX Ergo. --- modules/nixos/hardware/default.nix | 2 +- modules/nixos/hardware/{mx-ergo => trackball}/default.nix | 7 ++++--- modules/nixos/profiles/devices/default.nix | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) rename modules/nixos/hardware/{mx-ergo => trackball}/default.nix (79%) diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index 95e6a22..8e125ca 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -7,9 +7,9 @@ ./ergodox ./firmware ./graphics - ./mx-ergo ./networking ./sound + ./trackball ./upower ]; } diff --git a/modules/nixos/hardware/mx-ergo/default.nix b/modules/nixos/hardware/trackball/default.nix similarity index 79% rename from modules/nixos/hardware/mx-ergo/default.nix rename to modules/nixos/hardware/trackball/default.nix index e4e55a1..7a99247 100644 --- a/modules/nixos/hardware/mx-ergo/default.nix +++ b/modules/nixos/hardware/trackball/default.nix @@ -1,11 +1,11 @@ # Hold down the `next page` button to scroll using the ball { config, lib, ... }: let - cfg = config.my.hardware.mx-ergo; + cfg = config.my.hardware.trackball; in { - options.my.hardware.mx-ergo = with lib; { - enable = mkEnableOption "MX Ergo configuration"; + options.my.hardware.trackball = with lib; { + enable = mkEnableOption "trackball configuration"; }; config = lib.mkIf cfg.enable { @@ -13,6 +13,7 @@ in # This section must be *after* the one configured by `libinput` # for the `ScrollMethod` configuration to not be overriden inputClassSections = lib.mkAfter [ + # MX Ergo '' Identifier "MX Ergo scroll button configuration" MatchProduct "MX Ergo" diff --git a/modules/nixos/profiles/devices/default.nix b/modules/nixos/profiles/devices/default.nix index 7dbd299..7a84bd2 100644 --- a/modules/nixos/profiles/devices/default.nix +++ b/modules/nixos/profiles/devices/default.nix @@ -11,7 +11,7 @@ in my.hardware = { ergodox.enable = true; - mx-ergo.enable = true; + trackball.enable = true; }; # MTP devices auto-mount via file explorers