2021-09-19 17:06:19 +02:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, kernel, runtimeShell }:
|
2012-01-26 02:02:22 +01:00
|
|
|
|
|
|
|
let
|
2013-03-21 15:46:30 +01:00
|
|
|
baseName = "bbswitch";
|
2022-08-05 15:24:37 +02:00
|
|
|
version = "unstable-2021-11-29";
|
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;
|
|
|
|
|
2021-09-19 17:06:19 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Bumblebee-Project";
|
|
|
|
repo = "bbswitch";
|
2022-08-05 15:24:37 +02:00
|
|
|
# https://github.com/Bumblebee-Project/bbswitch/tree/develop
|
|
|
|
rev = "23891174a80ea79c7720bcc7048a5c2bfcde5cd9";
|
|
|
|
hash = "sha256-50v1Jxem5kaI1dHOKmgBbPLxI82QeYxiaRHhrHpWRzU=";
|
2012-01-26 02:02:22 +01:00
|
|
|
};
|
|
|
|
|
2020-04-19 16:25:48 +02:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
2022-08-05 15:24:37 +02:00
|
|
|
url = "https://raw.githubusercontent.com/archlinux/svntogit-community/0bd986055ba52887b81048de5c61e618eec06eb0/trunk/0003-kernel-5.18.patch";
|
|
|
|
sha256 = "sha256-va62/bR1qyBBMPg0lUwCH7slGG0XijxVCsFa4FCoHEQ=";
|
2020-04-19 16:25:48 +02:00
|
|
|
})
|
|
|
|
];
|
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
|
|
|
|
2021-09-10 23:42:17 +02:00
|
|
|
makeFlags = kernel.makeFlags;
|
|
|
|
|
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
|
2019-02-26 12:45:54 +01:00
|
|
|
#!${runtimeShell}
|
2012-01-26 02:02:22 +01:00
|
|
|
|
|
|
|
echo -n OFF > /proc/acpi/bbswitch
|
|
|
|
EOF
|
|
|
|
tee $out/bin/discrete_vga_poweron << EOF
|
2019-02-26 12:45:54 +01:00
|
|
|
#!${runtimeShell}
|
2012-01-26 02:02:22 +01:00
|
|
|
|
|
|
|
echo -n ON > /proc/acpi/bbswitch
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/discrete_vga_poweroff $out/bin/discrete_vga_poweron
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with 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" ];
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://github.com/Bumblebee-Project/bbswitch";
|
2015-04-06 01:56:53 +02:00
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2021-08-30 14:57:59 +02:00
|
|
|
license = licenses.gpl2Plus;
|
2012-01-26 02:02:22 +01:00
|
|
|
};
|
|
|
|
}
|