2012-01-26 02:02:22 +01:00
|
|
|
{ stdenv, fetchurl, kernel }:
|
|
|
|
|
|
|
|
let
|
2012-02-22 21:29:22 +01:00
|
|
|
baseName = "bbswitch-0.4.1";
|
|
|
|
name = "${baseName}-${kernel.version}";
|
2012-01-26 02:02:22 +01:00
|
|
|
|
2012-02-17 15:32:28 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2012-01-26 02:02:22 +01:00
|
|
|
inherit name;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2012-02-22 21:29:22 +01:00
|
|
|
url = "http://github.com/downloads/Bumblebee-Project/bbswitch/${baseName}.tar.gz";
|
2012-01-26 02:02:22 +01:00
|
|
|
sha256 = "d579c6efc5f6482f0cf0b2c1b1f1a127413218cdffdc8f2d5a946c11909bda23";
|
|
|
|
};
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
kernelVersion=$(cd ${kernel}/lib/modules && ls)
|
|
|
|
substituteInPlace Makefile \
|
2012-02-24 01:17:09 +01:00
|
|
|
--replace "\$(shell uname -r)" "${kernel.version}" \
|
2012-01-26 02:02:22 +01:00
|
|
|
--replace "/lib/modules" "${kernel}/lib/modules"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2012-02-24 01:17:09 +01:00
|
|
|
ensureDir $out/lib/modules/${kernel.version}/misc
|
|
|
|
cp bbswitch.ko $out/lib/modules/${kernel.version}/misc
|
2012-01-26 02:02:22 +01:00
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
}
|