Skip to content

Commit

Permalink
add amdgpu module
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRTitor committed Jun 21, 2024
1 parent 965dcad commit 5521adb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 24 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion home-manager/cli-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ And scripts may not work the high customised setup
programs.zoxide = {
enable = true;
options = [
"--cmd cd" # Replace cd with zoxide
# don't enable cd alias, as conflicts may occur sometimes
# you might be redirected to a directory you didn't intend to
# "--cmd cd" # Replace cd with zoxide
];
enableBashIntegration = false;
};
Expand Down
42 changes: 42 additions & 0 deletions modules-overlays/amdgpu.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ config, lib, pkgs, ... }:

let
cfg = config.hardware.amdgpu;
in {
options.hardware.amdgpu = {
legacySupport.enable = lib.mkEnableOption ''support for old AMD graphics cards,
this uses `amdgpu` instead of `radeonsi` driver for Southern Islands (Radeon HD 7000)
series and Sea Islands (Radeon HD 7000) series cards.
Note: this does NOT add support for analog video output graphics cards.
'';
initrd.enable = lib.mkEnableOption ''loading `amdgpu` kernelModule in stage 1.
Enable this to fix lower resolution in boot screen during initramfs phase.
'';
rocm.enable = lib.mkEnableOption ''ROCm/OpenCL support'';
# cfg.amdvlk option is defined in ./amdvlk.nix module
};

config = {
boot.kernelParams = lib.optionals cfg.legacySupport.enable [
"amdgpu.si_support=1"
"amdgpu.cik_support=1"
"radeon.si_support=0"
"radeon.cik_support=0"
];

boot.initrd.kernelModules = lib.optionals cfg.initrd.enable [ "amdgpu" ];

hardware.opengl = lib.mkIf cfg.rocm.enable {
enable = lib.mkDefault true;
driSupport = lib.mkDefault true;
extraPackages = [
pkgs.rocmPackages.clr
pkgs.rocmPackages.clr.icd
];
};
};

meta = {
maintainers = with lib.maintainers; [ johnrtitor ];
};
}
2 changes: 1 addition & 1 deletion modules-overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
...
}: {
imports = [
# ./amdvlk.nix - import modules here to test
./amdgpu.nix # import modules here to test
];

nixpkgs.overlays = [
Expand Down
23 changes: 7 additions & 16 deletions system/hardware/graphics.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ in {
# Extra drivers
extraPackages =
(with pkgs; [
rocmPackages.clr.icd
amdvlk # AMD Vulkan driver
vaapiVdpau
libvdpau-va-gl
libva
Expand All @@ -32,7 +30,6 @@ in {
]);
# For 32 bit applications
extraPackages32 = with pkgs.driversi686Linux; [
amdvlk
vaapiVdpau
libvdpau-va-gl
];
Expand All @@ -44,6 +41,10 @@ in {
vulkan-tools # vulkan graphics library tools
];

hardware.amdgpu.initrd.enable = true;
hardware.amdgpu.legacySupport.enable = true;
hardware.amdgpu.rocm.enable = true;

hardware.amdgpu.amdvlk = {
enable = true;
support32Bit.enable = true;
Expand All @@ -57,19 +58,9 @@ in {
};
};

# Also load amdgpu at stage 1 of boot, to get better resolution
boot.initrd.kernelModules = ["amdgpu"];

# AMDGPU graphics driver for Xorg
services.xserver.videoDrivers = ["amdgpu"];

# Enable AMDGPU and disable Radeonsi
boot.kernelParams = [
"amdgpu.si_support=1"
"amdgpu.cik_support=1"
"radeon.si_support=0"
"radeon.cik_support=0"
];
# Use modesetting driver for Xorg, its better and updated
# AMDGPU graphics driver for Xorg is deprecated
services.xserver.videoDrivers = ["modesetting"];

# Graphics environment variables
environment.sessionVariables = {
Expand Down

0 comments on commit 5521adb

Please sign in to comment.