summary refs log tree commit diff
path: root/pkgs/os-specific/linux/bbswitch
diff options
context:
space:
mode:
authorArie Middelkoop <amiddelk@gmail.com>2012-01-26 01:02:22 +0000
committerArie Middelkoop <amiddelk@gmail.com>2012-01-26 01:02:22 +0000
commit62e9429908605b5f2a1449cf413f8a890d23de82 (patch)
tree73d79634cf520b09dd8b87e416754dd840f37b54 /pkgs/os-specific/linux/bbswitch
parent06548b79e96a32866b186110ea15531d5c04b4aa (diff)
downloadnixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.tar
nixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.tar.gz
nixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.tar.bz2
nixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.tar.lz
nixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.tar.xz
nixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.tar.zst
nixpkgs-62e9429908605b5f2a1449cf413f8a890d23de82.zip
Added the 'bbswitch' module, which is a more conventient module for powering off/on nvidia graphics cards than possible via the acpi_call module.
svn path=/nixpkgs/trunk/; revision=31840
Diffstat (limited to 'pkgs/os-specific/linux/bbswitch')
-rw-r--r--pkgs/os-specific/linux/bbswitch/default.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/bbswitch/default.nix b/pkgs/os-specific/linux/bbswitch/default.nix
new file mode 100644
index 00000000000..d64701a1d07
--- /dev/null
+++ b/pkgs/os-specific/linux/bbswitch/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchurl, kernel }:
+
+let
+
+  version = "0.4.1";
+  name = "bbswitch-${version}";
+
+in stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "http://github.com/downloads/Bumblebee-Project/bbswitch/${name}.tar.gz";
+    sha256 = "d579c6efc5f6482f0cf0b2c1b1f1a127413218cdffdc8f2d5a946c11909bda23";
+  };
+
+  preBuild = ''
+    kernelVersion=$(cd ${kernel}/lib/modules && ls)
+    substituteInPlace Makefile \
+      --replace "\$(shell uname -r)" "$kernelVersion" \
+      --replace "/lib/modules" "${kernel}/lib/modules"
+  '';
+ 
+  installPhase = ''
+    kernelVersion=$(cd ${kernel}/lib/modules && ls)
+    ensureDir $out/lib/modules/$kernelVersion/misc
+    cp bbswitch.ko $out/lib/modules/$kernelVersion/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";
+  };
+}