kernel: add standalone amdgpu kernel module package

This commit is contained in:
Leonardo Eugênio 2023-02-21 00:29:28 -03:00
parent 2006674aee
commit 80d814c9bf
6 changed files with 46 additions and 12 deletions

View file

@ -115,7 +115,6 @@
./hosts/monolith.nix
./system/monolith-gitlab-runner.nix
./system/nix-serve.nix
./system/amdgpu-kernel-patches.nix
] ++ common_modules;
};
rainbow = lib.nixosSystem {

View file

@ -29,7 +29,13 @@ in
# hardware.opengl.extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ];
# environment.variables = { AMD_VULKAN_ICD = "RADV"; };
boot.extraModulePackages = [ ];
boot.extraModulePackages = [
((pkgs.amdgpu-kernel-module.override {
kernel = config.boot.kernelPackages.kernel;
}).overrideAttrs (_: {
patches = [ ../patches/kernel/amdgpu-disable-shutdown-on-overheating.diff ];
}))
];
fileSystems."/" = {
device = "/dev/disk/by-label/BTRFS_ROOT";
fsType = "btrfs";

View file

@ -0,0 +1,38 @@
{ pkgs
, lib
, kernel ? pkgs.linuxPackages_latest.kernel
}:
pkgs.stdenv.mkDerivation {
pname = "amdgpu-kernel-module";
inherit (kernel) src version postPatch nativeBuildInputs;
kernel_dev = kernel.dev;
kernelVersion = kernel.modDirVersion;
modulePath = "drivers/gpu/drm/amd/amdgpu";
buildPhase = ''
BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build
cp $BUILT_KERNEL/Module.symvers .
cp $BUILT_KERNEL/.config .
cp $kernel_dev/vmlinux .
make "-j$NIX_BUILD_CORES" modules_prepare
make "-j$NIX_BUILD_CORES" M=$modulePath modules
'';
installPhase = ''
make \
INSTALL_MOD_PATH="$out" \
XZ="xz -T$NIX_BUILD_CORES" \
M="$modulePath" \
modules_install
'';
meta = {
description = "AMD GPU kernel module";
license = lib.licenses.gpl3;
};
}

View file

@ -5,4 +5,5 @@
plymouth-theme-red = pkgs.callPackage ./plymouth-theme-red.nix { inherit inputs; };
cargo-checkmate = pkgs.callPackage ./cargo-checkmate.nix { };
lipsum = pkgs.callPackage ./lipsum.nix { inherit inputs; };
amdgpu-kernel-module = pkgs.callPackage ./amdgpu-kernel-module.nix { };
}

View file

@ -1,10 +0,0 @@
{ config, pkgs, lib, inputs, ... }: {
# boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
boot.kernelPatches = [
{
name = "amdgpu-disable-shutdown-on-overtheating";
patch =
../patches/kernel/amdgpu-disable-shutdown-on-overtheating.diff;
}
];
}