nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchpatch,
5 kernel,
6 rr,
7}:
8
9/*
10 The python script shouldn't be needed for users of this kernel module.
11 https://github.com/rr-debugger/rr/blob/master/scripts/zen_workaround.py
12 The module itself is called "zen_workaround" (a bit generic unfortunately).
13*/
14stdenv.mkDerivation {
15 pname = "rr-zen_workaround";
16
17 inherit (rr) src version;
18 sourceRoot = "${rr.src.name}/third-party/zen-pmu-workaround";
19 patches = [
20 (fetchpatch {
21 name = "kernel-6.16.patch";
22 url = "https://github.com/rr-debugger/rr/commit/86aa1ebe03c6a7f60eb65249233f866fd3da8316.diff";
23 stripLen = 2;
24 hash = "sha256-zj5MNwlZmWnagu0tE5Jl5a48wEF0lqNTh4KcbhmOkOo=";
25 })
26 ];
27
28 hardeningDisable = [ "pic" ];
29 nativeBuildInputs = kernel.moduleBuildDependencies;
30
31 makeFlags = [
32 "-C${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
33 ];
34 postConfigure = ''
35 appendToVar makeFlags "M=$(pwd)"
36 '';
37 buildFlags = [ "modules" ];
38
39 installPhase =
40 let
41 modDestDir = "$out/lib/modules/${kernel.modDirVersion}/kernel"; # TODO: longer path?
42 in
43 ''
44 runHook preInstall
45 mkdir -p "${modDestDir}"
46 cp *.ko "${modDestDir}/"
47 find ${modDestDir} -name '*.ko' -exec xz -f '{}' \;
48 runHook postInstall
49 '';
50
51 meta = {
52 description = "Kernel module supporting the rr debugger on (some) AMD Zen-based CPUs";
53 homepage = "https://github.com/rr-debugger/rr/wiki/Zen#kernel-module";
54 license = lib.licenses.gpl2;
55 maintainers = [ lib.maintainers.vcunat ];
56 platforms = [ "x86_64-linux" ];
57 broken = lib.versionOlder kernel.version "4.19"; # 4.14 breaks and 4.19 works
58 };
59}