blob: dccfeeb8a692e5dce6c307b65e48b300af97f4fb (
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
|
{ stdenv, fetchurl, kernel }:
let
baseName = "bbswitch-0.5";
name = "${baseName}-${kernel.version}";
linux38Compatibility = fetchurl {
url = "http://github.com/Bumblebee-Project/bbswitch/commit/5593d95.patch";
sha256 = "0m6y5sdagf4brhk1lsp86rx94xf628sixzf6j71bn7jnqs4jslr6";
};
in
stdenv.mkDerivation {
inherit name;
src = fetchurl {
url = "http://github.com/downloads/Bumblebee-Project/bbswitch/${baseName}.tar.gz";
sha256 = "19775r3bsf5l3ssbayr30fij09gavj2qjrr438hdcmzswvlj2dpv";
};
patches = [ linux38Compatibility ];
preBuild = ''
substituteInPlace Makefile \
--replace "\$(shell uname -r)" "${kernel.modDirVersion}" \
--replace "/lib/modules" "${kernel}/lib/modules"
'';
installPhase = ''
ensureDir $out/lib/modules/${kernel.modDirVersion}/misc
cp bbswitch.ko $out/lib/modules/${kernel.modDirVersion}/misc
ensureDir $out/bin
tee $out/bin/discrete_vga_poweroff << EOF
#!/bin/sh
echo -n OFF > /proc/acpi/bbswitch
EOF
tee $out/bin/discrete_vga_poweron << EOF
#!/bin/sh
echo -n ON > /proc/acpi/bbswitch
EOF
chmod +x $out/bin/discrete_vga_poweroff $out/bin/discrete_vga_poweron
'';
meta = {
platforms = stdenv.lib.platforms.linux;
description = "A module for powering off hybrid GPUs";
};
}
|