2012-01-26 01:02:22 +00:00
|
|
|
{ stdenv, fetchurl, kernel }:
|
|
|
|
|
|
|
|
let
|
2012-05-09 11:01:38 +01:00
|
|
|
baseName = "bbswitch-0.4.2";
|
2012-02-22 20:29:22 +00:00
|
|
|
name = "${baseName}-${kernel.version}";
|
2012-01-26 01:02:22 +00:00
|
|
|
|
2012-02-17 14:32:28 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2012-01-26 01:02:22 +00:00
|
|
|
inherit name;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2012-02-22 20:29:22 +00:00
|
|
|
url = "http://github.com/downloads/Bumblebee-Project/bbswitch/${baseName}.tar.gz";
|
2012-05-09 11:01:38 +01:00
|
|
|
sha256 = "06j3cm1rk3lcbv54k0magrijykrzmkrna8n5cc274iz59842lga3";
|
2012-01-26 01:02:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
substituteInPlace Makefile \
|
2012-03-18 23:13:41 +00:00
|
|
|
--replace "\$(shell uname -r)" "${kernel.modDirVersion}" \
|
2012-01-26 01:02:22 +00:00
|
|
|
--replace "/lib/modules" "${kernel}/lib/modules"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2012-03-18 23:13:41 +00:00
|
|
|
ensureDir $out/lib/modules/${kernel.modDirVersion}/misc
|
|
|
|
cp bbswitch.ko $out/lib/modules/${kernel.modDirVersion}/misc
|
2012-01-26 01:02:22 +00: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";
|
|
|
|
};
|
|
|
|
}
|