2015-04-05 14:12:34 +01:00
|
|
|
{ stdenv, fetchurl, fetchpatch, kernel }:
|
2012-01-26 01:02:22 +00:00
|
|
|
|
|
|
|
let
|
2013-03-21 14:46:30 +00:00
|
|
|
baseName = "bbswitch";
|
2014-02-23 04:56:05 +00:00
|
|
|
version = "0.8";
|
2014-01-05 01:57:21 +00:00
|
|
|
name = "${baseName}-${version}-${kernel.version}";
|
2013-03-03 15:48:39 +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 {
|
2013-03-21 14:46:30 +00:00
|
|
|
url = "https://github.com/Bumblebee-Project/${baseName}/archive/v${version}.tar.gz";
|
2014-02-23 04:56:05 +00:00
|
|
|
sha256 = "0xql1nv8dafnrcg54f3jsi3ny3cd2ca9iv73pxpgxd2gfczvvjkn";
|
2012-01-26 01:02:22 +00:00
|
|
|
};
|
|
|
|
|
2015-04-05 14:12:34 +01:00
|
|
|
patches = [ (fetchpatch {
|
|
|
|
url = "https://github.com/Bumblebee-Project/bbswitch/pull/102.patch";
|
2015-04-06 00:56:53 +01:00
|
|
|
sha256 = "1lbr6pyyby4k9rn2ry5qc38kc738d0442jhhq57vmdjb6hxjya7m";
|
2015-04-05 14:12:34 +01:00
|
|
|
}) ];
|
|
|
|
|
2012-01-26 01:02:22 +00:00
|
|
|
preBuild = ''
|
|
|
|
substituteInPlace Makefile \
|
2014-01-05 01:57:21 +00:00
|
|
|
--replace "\$(shell uname -r)" "${kernel.modDirVersion}" \
|
|
|
|
--replace "/lib/modules" "${kernel.dev}/lib/modules"
|
2012-01-26 01:02:22 +00:00
|
|
|
'';
|
2013-03-03 15:48:39 +00:00
|
|
|
|
2012-01-26 01:02:22 +00:00
|
|
|
installPhase = ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/lib/modules/${kernel.modDirVersion}/misc
|
2014-01-05 01:57:21 +00:00
|
|
|
cp bbswitch.ko $out/lib/modules/${kernel.modDirVersion}/misc
|
2012-01-26 01:02:22 +00:00
|
|
|
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/bin
|
2012-01-26 01:02:22 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2015-04-06 00:56:53 +01:00
|
|
|
meta = with stdenv.lib; {
|
2012-01-26 01:02:22 +00:00
|
|
|
description = "A module for powering off hybrid GPUs";
|
2015-04-06 00:56:53 +01:00
|
|
|
platforms = platforms.linux;
|
|
|
|
homepage = https://github.com/Bumblebee-Project/bbswitch;
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2012-01-26 01:02:22 +00:00
|
|
|
};
|
|
|
|
}
|