2015-04-05 13:12:34 +00: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 13:12:34 +00:00
|
|
|
patches = [ (fetchpatch {
|
|
|
|
url = "https://github.com/Bumblebee-Project/bbswitch/pull/102.patch";
|
|
|
|
sha256 = "0agq7w28pdarq18qxc9917mamyb2sq8hxl3pzc0v210h60vmx2pm";
|
|
|
|
}) ];
|
|
|
|
|
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 12:56:10 +00: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 12:56:10 +00: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
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
description = "A module for powering off hybrid GPUs";
|
|
|
|
};
|
|
|
|
}
|