diff --git a/default-host/configuration.nix b/default-host/configuration.nix index 022215ed..612c8418 100644 --- a/default-host/configuration.nix +++ b/default-host/configuration.nix @@ -36,12 +36,7 @@ # just nix.settings.trusted-public-keys and nix.settings.trusted-substituters will be enough # for now: if `cachix use ` is used, manually copy to ./misc/cachix dir ../misc/cachix.nix # absolute location /etc/nixos/cachix.nix - ]; - - nixpkgs.overlays = [ - (final: prev: { - bcachefs-tools = inputs.bcachefs-tools.packages.${pkgs.system}.bcachefs-tools; - }) + ../modules-overlays ]; networking.hostName = systemSettings.hostname; # Define your hostname in flake.nix diff --git a/flake.nix b/flake.nix index a6aa683e..54863c38 100644 --- a/flake.nix +++ b/flake.nix @@ -33,9 +33,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; hyprland = { - url = "git+https://github.com/hyprwm/Hyprland?submodules=1&rev=4cdddcfe466cb21db81af0ac39e51cc15f574da9"; # Hyprland, a Wayland WM, use git submodules too + url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; # Hyprland, a Wayland WM, use git submodules too inputs.nixpkgs.follows = "nixpkgs"; inputs.xdph.follows = "xdph"; + inputs.hyprcursor.follows = "hyprcursor"; }; xdph = { url = "github:hyprwm/xdg-desktop-portal-hyprland"; @@ -80,6 +81,7 @@ url = "github:nix-community/nix-vscode-extensions"; # Grab latest VScode extensions as a package inputs.nixpkgs.follows = "nixpkgs"; }; + nur.url = "github:nix-community/NUR"; # Nix User Repository, for community packages }; outputs = inputs: inputs.flake-parts.lib.mkFlake {inherit inputs;} {imports = [./flake];}; } diff --git a/flake/hosts.nix b/flake/hosts.nix index 4331f80c..246d4f34 100644 --- a/flake/hosts.nix +++ b/flake/hosts.nix @@ -38,6 +38,7 @@ in { [ ../default-host/configuration.nix # main nix configuration inputs.chaotic.nixosModules.default # chaotic nix bleeding edge packages + inputs.nur.nixosModules.nur # make home-manager as a module of nixos # so that home-manager configuration will be deployed automatically when executing `nixos-rebuild switch` diff --git a/modules-overlays/amdvlk.nix b/modules-overlays/amdvlk.nix new file mode 100644 index 00000000..aeb1d338 --- /dev/null +++ b/modules-overlays/amdvlk.nix @@ -0,0 +1,65 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.hardware.amdgpu.amdvlk; +in { + options.hardware.amdgpu.amdvlk = { + enable = lib.mkEnableOption "AMDVLK Vulkan driver"; + + package = lib.mkPackageOption pkgs "amdvlk" { }; + + supportExperimental.enable = lib.mkEnableOption "Experimental features support"; + + support32Bit.enable = lib.mkEnableOption "32-bit driver support"; + support32Bit.package = lib.mkPackageOption pkgs.driversi686Linux "amdvlk" { }; + + settings = lib.mkOption { + type = lib.types.attrs; + default = { }; + example = { + AllowVkPipelineCachingToDisk = 1; + ShaderCacheMode = 1; + IFH = 0; + EnableVmAlwaysValid = 1; + IdleAfterSubmitGpuMask = 1; + }; + description = '' + Runtime settings for AMDVLK to be configured {file}`/etc/amd/amdVulkanSettings.cfg`. + See [AMDVLK GitHub page](https://github.com/GPUOpen-Drivers/AMDVLK?tab=readme-ov-file#runtime-settings). + ''; + }; + }; + + config = lib.mkIf cfg.enable { + hardware.opengl = lib.mkMerge [ + { + enable = lib.mkDefault true; + driSupport = lib.mkDefault true; + extraPackages = [ cfg.package ]; + } + (lib.mkIf cfg.support32Bit.enable { + driSupport32Bit = lib.mkDefault true; + extraPackages32 = [ cfg.support32Bit.package ]; + }) + ]; + + services.xserver.videoDrivers = [ "amdgpu" ]; + + environment.sessionVariables = lib.mkIf cfg.supportExperimental.enable { + AMDVLK_ENABLE_DEVELOPING_EXT = "all"; + }; + + environment.etc = lib.mkIf (cfg.settings != { }) { + "amd/amdVulkanSettings.cfg".text = lib.concatStrings + (lib.mapAttrsToList + (n: v: '' + ${n},${builtins.toString v} + '') + cfg.settings); + }; + }; + + meta = { + maintainers = with lib.maintainers; [ johnrtitor ]; + }; +} diff --git a/modules-overlays/default.nix b/modules-overlays/default.nix new file mode 100644 index 00000000..dc428d37 --- /dev/null +++ b/modules-overlays/default.nix @@ -0,0 +1,13 @@ +{ libs, pkgs, inputs, ... }: +{ + imports = [ + ./amdvlk.nix + ]; + + nixpkgs.overlays = [ + (final: prev: { + bcachefs-tools = inputs.bcachefs-tools.packages.${pkgs.system}.bcachefs-tools; + }) + ]; + +} \ No newline at end of file diff --git a/system/hardware/graphics.nix b/system/hardware/graphics.nix index 414a742a..e7157826 100644 --- a/system/hardware/graphics.nix +++ b/system/hardware/graphics.nix @@ -3,20 +3,33 @@ config, pkgs, ... -}: { +}: +let + nur-amdgpu = config.nur.repos.materus; +in { + + hardware.firmware = with nur-amdgpu; [ + amdgpu-pro-libs.firmware.vcn + amdgpu-pro-libs.firmware + ]; + # Enable OpenGL and Vulkan support hardware.opengl = { enable = true; driSupport = true; driSupport32Bit = true; # Extra drivers - extraPackages = with pkgs; [ + extraPackages = (with pkgs; [ rocmPackages.clr.icd amdvlk # AMD Vulkan driver vaapiVdpau libvdpau-va-gl libva - ]; + ]) ++ (with nur-amdgpu; [ + amdgpu-pro-libs.opengl + amdgpu-pro-libs.vulkan + amdgpu-pro-libs.amf + ]); # For 32 bit applications extraPackages32 = with pkgs.driversi686Linux; [ amdvlk @@ -31,6 +44,21 @@ vulkan-tools # vulkan graphics library tools ]; + + hardware.amdgpu.amdvlk = { + enable = true; + support32Bit.enable = true; + supportExperimental.enable = true; + settings = { + AllowVkPipelineCachingToDisk = 1; + ShaderCacheMode = 1; + IFH = 0; + EnableVmAlwaysValid = 1; + IdleAfterSubmitGpuMask = 0; + }; + }; + + # Also load amdgpu at stage 1 of boot, to get better resolution boot.initrd.kernelModules = ["amdgpu"];