2012-01-26 02:02:22 +01:00
|
|
|
{ stdenv, fetchurl, kernel }:
|
|
|
|
|
|
|
|
let
|
2013-03-03 16:48:39 +01:00
|
|
|
baseName = "bbswitch-0.5";
|
2012-02-22 21:29:22 +01:00
|
|
|
name = "${baseName}-${kernel.version}";
|
2012-01-26 02:02:22 +01:00
|
|
|
|
2013-03-03 16:48:39 +01:00
|
|
|
linux38Compatibility = fetchurl {
|
|
|
|
url = "http://github.com/Bumblebee-Project/bbswitch/commit/5593d95.patch";
|
|
|
|
sha256 = "0m6y5sdagf4brhk1lsp86rx94xf628sixzf6j71bn7jnqs4jslr6";
|
|
|
|
};
|
|
|
|
|
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";
|
2013-03-03 16:48:39 +01:00
|
|
|
sha256 = "19775r3bsf5l3ssbayr30fij09gavj2qjrr438hdcmzswvlj2dpv";
|
2012-01-26 02:02:22 +01:00
|
|
|
};
|
|
|
|
|
2013-03-03 16:48:39 +01:00
|
|
|
patches = [ linux38Compatibility ];
|
|
|
|
|
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"
|
|
|
|
'';
|
2013-03-03 16:48:39 +01:00
|
|
|
|
2012-01-26 02:02:22 +01:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
}
|