1{ lib, stdenv, fetchurl, kernel, which }:
2
3# Don't bother with older versions, though some might even work:
4assert lib.versionAtLeast kernel.version "4.10";
5
6let
7 release = "0.4.0";
8 revbump = "rev25"; # don't forget to change forum download id...
9in stdenv.mkDerivation rec {
10 name = "linux-phc-intel-${version}-${kernel.version}";
11 version = "${release}-${revbump}";
12
13 src = fetchurl {
14 sha256 = "1w91hpphd8i0br7g5qra26jdydqar45zqwq6jq8yyz6l0vb10zlz";
15 url = "http://www.linux-phc.org/forum/download/file.php?id=194";
16 name = "phc-intel-pack-${revbump}.tar.bz2";
17 };
18
19 nativeBuildInputs = [ which ] ++ kernel.moduleBuildDependencies;
20
21 hardeningDisable = [ "pic" ];
22
23 makeFlags = with kernel; [
24 "DESTDIR=$(out)"
25 "KERNELSRC=${dev}/lib/modules/${modDirVersion}/build"
26 ];
27
28 configurePhase = ''
29 make $makeFlags brave
30 '';
31
32 enableParallelBuilding = false;
33
34 installPhase = ''
35 install -m 755 -d $out/lib/modules/${kernel.modDirVersion}/extra/
36 install -m 644 *.ko $out/lib/modules/${kernel.modDirVersion}/extra/
37 '';
38
39 meta = with lib; {
40 description = "Undervolting kernel driver for Intel processors";
41 longDescription = ''
42 PHC is a Linux kernel patch to undervolt processors. This can divide the
43 power consumption of the CPU by two or more, increasing battery life
44 while noticably reducing fan noise. This driver works only on supported
45 Intel architectures.
46 '';
47 homepage = "https://github.com/danielw86dev/phc-intel-dkms";
48 license = licenses.gpl2Plus;
49 platforms = [ "x86_64-linux" "i686-linux" ];
50 broken = lib.versionAtLeast kernel.version "4.18";
51 };
52}