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