about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/phc-intel/default.nix
blob: 4eed41254f9161ba39bba49454e8a4b27e1297c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ stdenv, fetchurl, kernel, which }:

assert stdenv.isLinux;
# Don't bother with older versions, though some would probably work:
assert stdenv.lib.versionAtLeast kernel.version "4.3";
# Disable on grsecurity kernels, which break module building:
assert !kernel.features ? grsecurity;

let
  release = "0.4.0";
  revbump = "rev19"; # don't forget to change forum download id...
  version = "${release}-${revbump}";
in stdenv.mkDerivation {
  name = "linux-phc-intel-${version}-${kernel.version}";

  src = fetchurl {
    sha256 = "1apvjp2rpaf3acjvsxgk6xiwrx4n9p565gxvra05pvicwikfiqa8";
    url = "http://www.linux-phc.org/forum/download/file.php?id=168";
    name = "phc-intel-pack-${revbump}.tar.bz2";
  };

  buildInputs = [ which ];

  makeFlags = with kernel; [
    "DESTDIR=$(out)"
    "KERNELSRC=${dev}/lib/modules/${modDirVersion}/build"
  ];

  configurePhase = ''
    make $makeFlags brave
  '';

  enableParallelBuilding = false;

  installPhase = ''
    install -m 755   -d $out/lib/modules/${kernel.modDirVersion}/extra/
    install -m 644 *.ko $out/lib/modules/${kernel.modDirVersion}/extra/
  '';

  meta = with stdenv.lib; {
    inherit version;
    description = "Undervolting kernel driver for Intel processors";
    longDescription = ''
      PHC is a Linux kernel patch to undervolt processors. This can divide the
      power consumption of the CPU by two or more, increasing battery life
      while noticably reducing fan noise. This driver works only on supported
      Intel architectures.
    '';
    homepage = http://www.linux-phc.org/;
    downloadPage = "http://www.linux-phc.org/forum/viewtopic.php?f=7&t=267";
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ nckx ];
  };
}