2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, fetchurl, fetchpatch, kernel, runtimeShell }:
|
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
|
|
|
};
|
|
|
|
|
2020-04-19 15:25:48 +01:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/Bumblebee-Project/bbswitch/pull/102.patch";
|
|
|
|
sha256 = "1lbr6pyyby4k9rn2ry5qc38kc738d0442jhhq57vmdjb6hxjya7m";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/Bumblebee-Project/bbswitch/pull/196.patch";
|
|
|
|
sha256 = "02ihy3piws7783qbm9q0mb9s18ipn5ckdy1iar74xn31qjrsn99n";
|
|
|
|
})
|
|
|
|
];
|
2015-04-05 14:12:34 +01:00
|
|
|
|
2017-12-29 21:34:54 +00:00
|
|
|
nativeBuildInputs = kernel.moduleBuildDependencies;
|
2017-12-28 12:16:52 +00:00
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "pic" ];
|
2016-02-12 02:14:52 +00: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
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
2012-01-26 01:02:22 +00:00
|
|
|
|
|
|
|
echo -n OFF > /proc/acpi/bbswitch
|
|
|
|
EOF
|
|
|
|
tee $out/bin/discrete_vga_poweron << EOF
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
2012-01-26 01:02:22 +00:00
|
|
|
|
|
|
|
echo -n ON > /proc/acpi/bbswitch
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/discrete_vga_poweroff $out/bin/discrete_vga_poweron
|
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2012-01-26 01:02:22 +00:00
|
|
|
description = "A module for powering off hybrid GPUs";
|
2018-03-09 13:28:47 +00:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" ];
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/Bumblebee-Project/bbswitch";
|
2015-04-06 00:56:53 +01:00
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2012-01-26 01:02:22 +00:00
|
|
|
};
|
|
|
|
}
|