1 { lib, stdenv, fetchFromGitHub, fetchpatch, kernel, runtimeShell }:
5 version = "unstable-2021-11-29";
6 name = "${baseName}-${version}-${kernel.version}";
13 src = fetchFromGitHub {
14 owner = "Bumblebee-Project";
16 # https://github.com/Bumblebee-Project/bbswitch/tree/develop
17 rev = "23891174a80ea79c7720bcc7048a5c2bfcde5cd9";
18 hash = "sha256-50v1Jxem5kaI1dHOKmgBbPLxI82QeYxiaRHhrHpWRzU=";
23 url = "https://raw.githubusercontent.com/archlinux/svntogit-community/0bd986055ba52887b81048de5c61e618eec06eb0/trunk/0003-kernel-5.18.patch";
24 sha256 = "sha256-va62/bR1qyBBMPg0lUwCH7slGG0XijxVCsFa4FCoHEQ=";
28 nativeBuildInputs = kernel.moduleBuildDependencies;
30 hardeningDisable = [ "pic" ];
33 substituteInPlace Makefile \
34 --replace "/lib/modules" "${kernel.dev}/lib/modules"
37 makeFlags = kernel.makeFlags;
40 mkdir -p $out/lib/modules/${kernel.modDirVersion}/misc
41 cp bbswitch.ko $out/lib/modules/${kernel.modDirVersion}/misc
44 tee $out/bin/discrete_vga_poweroff << EOF
47 echo -n OFF > /proc/acpi/bbswitch
49 tee $out/bin/discrete_vga_poweron << EOF
52 echo -n ON > /proc/acpi/bbswitch
54 chmod +x $out/bin/discrete_vga_poweroff $out/bin/discrete_vga_poweron
58 description = "Module for powering off hybrid GPUs";
59 platforms = [ "x86_64-linux" "i686-linux" ];
60 homepage = "https://github.com/Bumblebee-Project/bbswitch";
61 maintainers = with maintainers; [ abbradar ];
62 license = licenses.gpl2Plus;