mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-06 01:38:06 +00:00
[Hardware/AMD] Add kernelDriver option and split config between amdgpu and radeon
This commit is contained in:
parent
233f95153e
commit
81860dbe21
3 changed files with 97 additions and 48 deletions
63
hardware/amd/amdgpu.nix
Normal file
63
hardware/amd/amdgpu.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.aviallon.hardware.amd;
|
||||||
|
devCfg = config.aviallon.developer;
|
||||||
|
generalCfg = config.aviallon.general;
|
||||||
|
myMesa = if generalCfg.unsafeOptimizations then pkgs.mesaOptimized else pkgs.mesa;
|
||||||
|
in {
|
||||||
|
config = mkIf (cfg.enable && cfg.kernelDriver == "amdgpu") {
|
||||||
|
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||||
|
|
||||||
|
aviallon.boot.cmdline = {
|
||||||
|
# for Southern Islands (SI ie. GCN 1) cards
|
||||||
|
"radeon.si_support" = 0;
|
||||||
|
"amdgpu.si_support" = 1;
|
||||||
|
# for Sea Islands (CIK ie. GCN 2) cards
|
||||||
|
"radeon.cik_support" = 0;
|
||||||
|
"amdgpu.cik_support" = 1;
|
||||||
|
|
||||||
|
"amdgpu.ppfeaturemask" = mkIf generalCfg.unsafeOptimizations "0xfff7ffff";
|
||||||
|
"amdgpu.freesync_video" = 1;
|
||||||
|
#"amdgpu.mes" = mkIf generalCfg.unsafeOptimizations 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; []
|
||||||
|
++ [ rocm-smi ]
|
||||||
|
++ optionals devCfg.enable [
|
||||||
|
rocminfo
|
||||||
|
]
|
||||||
|
;
|
||||||
|
|
||||||
|
services.xserver.videoDrivers = []
|
||||||
|
++ optional cfg.useProprietary "amdgpu-pro"
|
||||||
|
++ [
|
||||||
|
"amdgpu"
|
||||||
|
];
|
||||||
|
|
||||||
|
hardware.opengl = {
|
||||||
|
enable = true;
|
||||||
|
extraPackages = with pkgs; mkIf (!cfg.useProprietary) (
|
||||||
|
[
|
||||||
|
rocm-opencl-icd
|
||||||
|
rocm-opencl-runtime
|
||||||
|
]
|
||||||
|
++ optional (cfg.defaultVulkanImplementation == "amdvlk") amdvlk
|
||||||
|
);
|
||||||
|
extraPackages32 = with pkgs.driversi686Linux; mkIf (!cfg.useProprietary) ([]
|
||||||
|
++ optional (cfg.defaultVulkanImplementation == "amdvlk") amdvlk
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.variables = {
|
||||||
|
"AMD_VULKAN_ICD" = strings.toUpper cfg.defaultVulkanImplementation;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Make rocblas and rocfft work
|
||||||
|
nix.settings.extra-sandbox-paths = [
|
||||||
|
"/dev/kfd?"
|
||||||
|
"/sys/devices/virtual/kfd?"
|
||||||
|
"/dev/dri/renderD128?"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -14,70 +14,31 @@ in {
|
||||||
type = with types; enum [ "amdvlk" "radv" ];
|
type = with types; enum [ "amdvlk" "radv" ];
|
||||||
default = "radv";
|
default = "radv";
|
||||||
};
|
};
|
||||||
|
kernelDriver = mkOption {
|
||||||
|
description = "wether to use radeon or amdgpu kernel driver";
|
||||||
|
type = with types; enum [ "radeon" "amdgpu" ];
|
||||||
|
default = "amdgpu";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
./cpu.nix
|
./cpu.nix
|
||||||
|
./amdgpu.nix
|
||||||
|
./radeon.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config = mkIf (cfg.enable) {
|
config = mkIf cfg.enable {
|
||||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
|
||||||
|
|
||||||
aviallon.boot.cmdline = {
|
|
||||||
# for Southern Islands (SI ie. GCN 1) cards
|
|
||||||
"radeon.si_support" = 0;
|
|
||||||
"amdgpu.si_support" = 1;
|
|
||||||
# for Sea Islands (CIK ie. GCN 2) cards
|
|
||||||
"radeon.cik_support" = 0;
|
|
||||||
"amdgpu.cik_support" = 1;
|
|
||||||
|
|
||||||
"amdgpu.ppfeaturemask" = mkIf generalCfg.unsafeOptimizations "0xfff7ffff";
|
|
||||||
"amdgpu.freesync_video" = 1;
|
|
||||||
#"amdgpu.mes" = mkIf generalCfg.unsafeOptimizations 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; []
|
|
||||||
++ [
|
|
||||||
rocm-smi
|
|
||||||
]
|
|
||||||
++ optionals devCfg.enable ([]
|
|
||||||
++ [ rocminfo ]
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
services.xserver.videoDrivers = []
|
|
||||||
++ optional cfg.useProprietary "amdgpu-pro"
|
|
||||||
++ [
|
|
||||||
"amdgpu"
|
|
||||||
"radeon"
|
|
||||||
];
|
|
||||||
|
|
||||||
programs.corectrl.enable = mkIf generalCfg.unsafeOptimizations true;
|
programs.corectrl.enable = mkIf generalCfg.unsafeOptimizations true;
|
||||||
|
|
||||||
hardware.opengl = {
|
hardware.opengl = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = with pkgs; myMesa.drivers;
|
package = with pkgs; myMesa.drivers;
|
||||||
extraPackages = with pkgs; mkIf (!cfg.useProprietary) (mkAfter [
|
extraPackages = with pkgs; mkIf (!cfg.useProprietary) (mkAfter [
|
||||||
rocm-opencl-icd
|
|
||||||
rocm-opencl-runtime
|
|
||||||
(hiPrio myMesa)
|
(hiPrio myMesa)
|
||||||
amdvlk
|
|
||||||
]);
|
]);
|
||||||
extraPackages32 = with pkgs.driversi686Linux; mkIf (!cfg.useProprietary) [
|
extraPackages32 = with pkgs.driversi686Linux; mkIf (!cfg.useProprietary) [
|
||||||
mesa
|
(hiPrio myMesa)
|
||||||
amdvlk
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.variables = {
|
|
||||||
"AMD_VULKAN_ICD" = strings.toUpper cfg.defaultVulkanImplementation;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Make rocblas and rocfft work
|
|
||||||
nix.settings.extra-sandbox-paths = [
|
|
||||||
"/dev/kfd?"
|
|
||||||
"/sys/devices/virtual/kfd?"
|
|
||||||
"/dev/dri/renderD128?"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
hardware/amd/radeon.nix
Normal file
25
hardware/amd/radeon.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.aviallon.hardware.amd;
|
||||||
|
devCfg = config.aviallon.developer;
|
||||||
|
generalCfg = config.aviallon.general;
|
||||||
|
myMesa = if generalCfg.unsafeOptimizations then pkgs.mesaOptimized else pkgs.mesa;
|
||||||
|
in {
|
||||||
|
config = mkIf (cfg.enable && cfg.kernelDriver == "radeon") {
|
||||||
|
boot.initrd.kernelModules = [ "radeon" ];
|
||||||
|
|
||||||
|
aviallon.boot.cmdline = {
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
services.xserver.videoDrivers = [
|
||||||
|
"radeon"
|
||||||
|
];
|
||||||
|
|
||||||
|
environment.variables = {};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue