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