nixpkgs/pkgs/os-specific/linux/bbswitch/default.nix
Mathijs Kwik d329b66b73 bbswitch: use the modDirVersion instead of version
svn path=/nixpkgs/trunk/; revision=33244
2012-03-18 23:13:41 +00:00

46 lines
1.1 KiB
Nix

{ stdenv, fetchurl, kernel }:
let
baseName = "bbswitch-0.4.1";
name = "${baseName}-${kernel.version}";
in
stdenv.mkDerivation {
inherit name;
src = fetchurl {
url = "http://github.com/downloads/Bumblebee-Project/bbswitch/${baseName}.tar.gz";
sha256 = "d579c6efc5f6482f0cf0b2c1b1f1a127413218cdffdc8f2d5a946c11909bda23";
};
preBuild = ''
substituteInPlace Makefile \
--replace "\$(shell uname -r)" "${kernel.modDirVersion}" \
--replace "/lib/modules" "${kernel}/lib/modules"
'';
installPhase = ''
ensureDir $out/lib/modules/${kernel.modDirVersion}/misc
cp bbswitch.ko $out/lib/modules/${kernel.modDirVersion}/misc
ensureDir $out/bin
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
'';
meta = {
platforms = stdenv.lib.platforms.linux;
description = "A module for powering off hybrid GPUs";
};
}