Skip to content

Commit

Permalink
FIXME: add amdvlk module
Browse files Browse the repository at this point in the history
Remove when nixpkgs#318175 is merged and available in nixpkgs
++ Add AMDGPU NUR
++ remove hyprland pin
  • Loading branch information
JohnRTitor committed Jun 8, 2024
1 parent 2b329a7 commit 1e08aa7
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 10 deletions.
7 changes: 1 addition & 6 deletions default-host/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@
# just nix.settings.trusted-public-keys and nix.settings.trusted-substituters will be enough
# for now: if `cachix use <repo>` 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
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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];};
}
1 change: 1 addition & 0 deletions flake/hosts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
65 changes: 65 additions & 0 deletions modules-overlays/amdvlk.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
13 changes: 13 additions & 0 deletions modules-overlays/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ libs, pkgs, inputs, ... }:
{
imports = [
./amdvlk.nix
];

nixpkgs.overlays = [
(final: prev: {
bcachefs-tools = inputs.bcachefs-tools.packages.${pkgs.system}.bcachefs-tools;
})
];

}
34 changes: 31 additions & 3 deletions system/hardware/graphics.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"];

Expand Down

0 comments on commit 1e08aa7

Please sign in to comment.