1{ stdenv, fetchurl, kernel, which }:
2
3assert stdenv.isLinux;
4# Don't bother with older versions, though some would probably work:
5assert stdenv.lib.versionAtLeast kernel.version "4.2";
6# Disable on grsecurity kernels, which break module building:
7assert !kernel.features ? grsecurity;
8
9let
10 release = "0.4.0";
11 revbump = "rev18"; # don't forget to change forum download id...
12 version = "${release}-${revbump}";
13in stdenv.mkDerivation {
14 name = "linux-phc-intel-${version}-${kernel.version}";
15
16 src = fetchurl {
17 sha256 = "1480y75yid4nw7dhzm97yb10dykinzjz34abvavsrqpq7qclhv27";
18 url = "http://www.linux-phc.org/forum/download/file.php?id=167";
19 name = "phc-intel-pack-${revbump}.tar.bz2";
20 };
21
22 buildInputs = [ which ];
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.version}/extra/
37 install -m 644 *.ko $out/lib/modules/${kernel.version}/extra/
38 '';
39
40 meta = with stdenv.lib; {
41 inherit version;
42 description = "Undervolting kernel driver for Intel processors";
43 longDescription = ''
44 PHC is a Linux kernel patch to undervolt processors. This can divide the
45 power consumption of the CPU by two or more, increasing battery life
46 while noticably reducing fan noise. This driver works only on supported
47 Intel architectures.
48 '';
49 homepage = http://www.linux-phc.org/;
50 downloadPage = "http://www.linux-phc.org/forum/viewtopic.php?f=7&t=267";
51 license = licenses.gpl2;
52 platforms = platforms.linux;
53 maintainers = with maintainers; [ nckx ];
54 };
55}