2021-09-19 15:06:19 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, 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;
|
|
|
|
|
2021-09-19 15:06:19 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Bumblebee-Project";
|
|
|
|
repo = "bbswitch";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-FHC8myKnouNDERVds2QCJj1ZstjHrOzFpb+FDiSBjL4=";
|
2012-01-26 01:02:22 +00:00
|
|
|
};
|
|
|
|
|
2020-04-19 14:25:48 +00: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 13:12:34 +00: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
|
|
|
|
2021-09-10 21:42:17 +00:00
|
|
|
makeFlags = kernel.makeFlags;
|
|
|
|
|
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
|
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 01:11:51 +00:00
|
|
|
homepage = "https://github.com/Bumblebee-Project/bbswitch";
|
2015-04-05 23:56:53 +00:00
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2021-08-30 12:57:59 +00:00
|
|
|
license = licenses.gpl2Plus;
|
2022-05-23 12:00:53 +00:00
|
|
|
broken = kernel.kernelAtLeast "5.18";
|
2012-01-26 01:02:22 +00:00
|
|
|
};
|
|
|
|
}
|