2012-01-26 02:02:22 +01:00
|
|
|
{ stdenv, fetchurl, kernel }:
|
|
|
|
|
|
|
|
let
|
2012-05-09 12:01:38 +02:00
|
|
|
baseName = "bbswitch-0.4.2";
|
2012-02-22 21:29:22 +01:00
|
|
|
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-05-09 12:01:38 +02:00
|
|
|
sha256 = "06j3cm1rk3lcbv54k0magrijykrzmkrna8n5cc274iz59842lga3";
|
2012-01-26 02:02:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
substituteInPlace Makefile \
|
2012-03-19 00:13:41 +01:00
|
|
|
--replace "\$(shell uname -r)" "${kernel.modDirVersion}" \
|
2012-01-26 02:02:22 +01:00
|
|
|
--replace "/lib/modules" "${kernel}/lib/modules"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2012-03-19 00:13:41 +01:00
|
|
|
ensureDir $out/lib/modules/${kernel.modDirVersion}/misc
|
|
|
|
cp bbswitch.ko $out/lib/modules/${kernel.modDirVersion}/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";
|
|
|
|
};
|
|
|
|
}
|