Upgrade bumblebee and add nixos module
* Bump bumblebee to 3.2.1 * Remove config.patch - options it added can be passed to ./configure now * Remove the provided xorg.conf Provided xorg.conf was causing problems for some users, and Bumblebee provides its own default configuration anyway. * Make secondary X11 log to /var/log/X.bumblebee.log * Add a module for bumblebee
This commit is contained in:
parent
48851fa749
commit
fe38031168
41
nixos/modules/hardware/video/bumblebee.nix
Normal file
41
nixos/modules/hardware/video/bumblebee.nix
Normal file
@ -0,0 +1,41 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let kernel = config.boot.kernelPackages; in
|
||||
with pkgs.lib;
|
||||
|
||||
{
|
||||
|
||||
options = {
|
||||
hardware.bumblebee.enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Enable the bumblebee daemon to manage Optimus hybrid video cards.
|
||||
This should power off secondary GPU until its use is requested
|
||||
by running an application with optirun.
|
||||
|
||||
Only nvidia driver is supported so far.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.hardware.bumblebee.enable {
|
||||
boot.blacklistedKernelModules = [ "nouveau" "nvidia" ];
|
||||
boot.kernelModules = [ "bbswitch" ];
|
||||
boot.extraModulePackages = [ kernel.bbswitch kernel.nvidia_x11 ];
|
||||
|
||||
environment.systemPackages = [ pkgs.bumblebee ];
|
||||
|
||||
systemd.services.bumblebeed = {
|
||||
description = "Bumblebee Hybrid Graphics Switcher";
|
||||
wantedBy = [ "display-manager.service" ];
|
||||
script = "bumblebeed --use-syslog";
|
||||
path = [ kernel.bbswitch pkgs.bumblebee ];
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = 60;
|
||||
CPUSchedulingPolicy = "idle";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -31,6 +31,7 @@
|
||||
./hardware/network/rtl8192c.nix
|
||||
./hardware/opengl.nix
|
||||
./hardware/pcmcia.nix
|
||||
./hardware/video/bumblebee.nix
|
||||
./installer/tools/nixos-checkout.nix
|
||||
./installer/tools/tools.nix
|
||||
./misc/assertions.nix
|
||||
|
@ -1,30 +0,0 @@
|
||||
--- bumblebee-3.0/src/driver.c.orig 2012-02-03 14:51:10.282464426 +0100
|
||||
+++ bumblebee-3.0/src/driver.c 2012-02-04 22:26:02.715498536 +0100
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "module.h"
|
||||
#include "bblogger.h"
|
||||
#include "driver.h"
|
||||
+#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Check what drivers are available and autodetect if possible. Driver, module
|
||||
@@ -30,6 +31,7 @@
|
||||
*/
|
||||
void driver_detect(void) {
|
||||
/* determine driver to be used */
|
||||
+ set_string_value(&bb_config.driver, getenv("BUMBLEBEE_DRIVER"));
|
||||
if (*bb_config.driver) {
|
||||
bb_log(LOG_DEBUG, "Skipping auto-detection, using configured driver"
|
||||
" '%s'\n", bb_config.driver);
|
||||
@@ -65,8 +67,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (strcmp(bb_config.driver, "nvidia")) {
|
||||
- set_string_value(&bb_config.ld_path, CONF_LDPATH_NVIDIA);
|
||||
- set_string_value(&bb_config.mod_path, CONF_MODPATH_NVIDIA);
|
||||
+ if (!strcmp(bb_config.driver, "nvidia")) {
|
||||
+ set_string_value(&bb_config.ld_path, getenv("BUMBLEBEE_LDPATH_NVIDIA"));
|
||||
+ set_string_value(&bb_config.mod_path, getenv("BUMBLEBEE_MODPATH_NVIDIA"));
|
||||
}
|
||||
}
|
@ -8,19 +8,7 @@
|
||||
|
||||
# To test: make sure that the 'bbswitch' kernel module is installed,
|
||||
# then run 'bumblebeed' as root and 'optirun glxgears' as user.
|
||||
# To use at startup, add e.g. to configuration.nix:
|
||||
# jobs = {
|
||||
# bumblebeed = {
|
||||
# name = "bumblebeed";
|
||||
# description = "Manages the Optimus video card";
|
||||
# startOn = "started udev and started syslogd";
|
||||
# stopOn = "starting shutdown";
|
||||
# exec = "bumblebeed --use-syslog";
|
||||
# path = [ pkgs.bumblebee ];
|
||||
# environment = { MODULE_DIR = "${config.system.modulesTree}/lib/modules"; };
|
||||
# respawn = true;
|
||||
# };
|
||||
# };
|
||||
# To use at startup, see hardware.bumblebee options.
|
||||
|
||||
# This nix expression supports for now only the native nvidia driver.
|
||||
# It should not be hard to generalize this approach to support the
|
||||
@ -34,7 +22,7 @@
|
||||
}:
|
||||
|
||||
let
|
||||
version = "3.0";
|
||||
version = "3.2.1";
|
||||
name = "bumblebee-${version}";
|
||||
|
||||
# isolated X11 environment with the nvidia module
|
||||
@ -61,22 +49,15 @@ let
|
||||
ignoreCollisions = true;
|
||||
};
|
||||
|
||||
# Custom X11 configuration for the additional xserver instance.
|
||||
xorgConf = ./xorg.conf.nvidia;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
inherit name;
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://github.com/downloads/Bumblebee-Project/Bumblebee/${name}.tar.gz";
|
||||
sha256 = "a27ddb77b282ac8b972857fdb0dc5061cf0a0982b7ac3e1cfa698b4f786e49a1";
|
||||
url = "http://bumblebee-project.org/${name}.tar.gz";
|
||||
sha256 = "03p3gvx99lwlavznrpg9l7jnl1yfg2adcj8jcjj0gxp20wxp060h";
|
||||
};
|
||||
|
||||
# 'config.patch' makes bumblebee read the active module and the nvidia configuration
|
||||
# from the environment variables instead of the config file:
|
||||
# BUMBLEBEE_DRIVER, BUMBLEBEE_LDPATH_NVIDIA, BUMBLEBEE_MODPATH_NVIDIA
|
||||
# These variables must be set when bumblebeed and optirun are executed.
|
||||
patches = [ ./config.patch ./xopts.patch ];
|
||||
patches = [ ./xopts.patch ];
|
||||
|
||||
preConfigure = ''
|
||||
# Substitute the path to the actual modinfo program in module.c.
|
||||
@ -88,32 +69,25 @@ in stdenv.mkDerivation {
|
||||
# Don't use a special group, just reuse wheel.
|
||||
substituteInPlace configure \
|
||||
--replace 'CONF_GID="bumblebee"' 'CONF_GID="wheel"'
|
||||
|
||||
# Ensures that the config file ends up with a nonempty
|
||||
# name of the nvidia module. This is needed, because the
|
||||
# configuration handling code otherwise resets the
|
||||
# data that we obtained from the environment (see config.patch)
|
||||
export CONF_DRIVER_MODULE_NVIDIA=nvidia
|
||||
'';
|
||||
|
||||
# Build-time dependencies of bumblebeed and optirun.
|
||||
# Note that it has several runtime dependencies.
|
||||
buildInputs = [ stdenv makeWrapper pkgconfig help2man libX11 glib libbsd ];
|
||||
|
||||
configureFlags = [
|
||||
"--with-udev-rules=$out/lib/udev/rules.d"
|
||||
"CONF_DRIVER=nvidia"
|
||||
"CONF_DRIVER_MODULE_NVIDIA=nvidia"
|
||||
"CONF_LDPATH_NVIDIA=${commonEnv}/lib"
|
||||
"CONF_MODPATH_NVIDIA=${commonEnv}/lib/xorg/modules"
|
||||
];
|
||||
|
||||
# create a wrapper environment for bumblebeed and optirun
|
||||
postInstall = ''
|
||||
# remove some entries from the configuration file that would otherwise
|
||||
# cause our environment variables to be ignored.
|
||||
substituteInPlace "$out/etc/bumblebee/bumblebee.conf" \
|
||||
--replace "LibraryPath=" "" \
|
||||
--replace "XorgModulePath=" ""
|
||||
|
||||
wrapProgram "$out/sbin/bumblebeed" \
|
||||
--prefix PATH : "${commonEnv}/sbin:${commonEnv}/bin:\$PATH" \
|
||||
--prefix LD_LIBRARY_PATH : "${commonEnv}/lib:\$LD_LIBRARY_PATH" \
|
||||
--set BUMBLEBEE_DRIVER "nvidia" \
|
||||
--set BUMBLEBEE_LDPATH_NVIDIA "${commonEnv}/lib" \
|
||||
--set BUMBLEBEE_MODPATH_NVIDIA "${commonEnv}/lib/xorg/modules" \
|
||||
--set FONTCONFIG_FILE "/etc/fonts/fonts.conf" \
|
||||
--set XKB_BINDIR "${xorg.xkbcomp}/bin" \
|
||||
--set XKB_DIR "${xkeyboard_config}/etc/X11/xkb"
|
||||
@ -121,16 +95,11 @@ in stdenv.mkDerivation {
|
||||
wrapProgram "$out/bin/optirun" \
|
||||
--prefix PATH : "${commonEnv}/sbin:${commonEnv}/bin" \
|
||||
--prefix LD_LIBRARY_PATH : "${commonEnv}/lib" \
|
||||
--set BUMBLEBEE_DRIVER "nvidia" \
|
||||
--set BUMBLEBEE_LDPATH_NVIDIA "${commonEnv}/lib" \
|
||||
--set BUMBLEBEE_MODPATH_NVIDIA "${commonEnv}/lib/xorg/modules"
|
||||
|
||||
cp ${xorgConf} "$out/etc/bumblebee/xorg.conf.nvidia"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = http://github.com/Bumblebee-Project/Bumblebee;
|
||||
description = "Daemon for managing Optimus videocards (power-on/off, spawns xservers)";
|
||||
license = "free";
|
||||
license = stdenv.lib.licenses.gpl3;
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
"-nolisten", "tcp",
|
||||
"-noreset",
|
||||
+ "-xkbdir", getenv("XKB_DIR"),
|
||||
+ "-logfile", "/dev/null",
|
||||
+ "-logfile", "/var/log/X.bumblebee.log",
|
||||
"-verbose", "3",
|
||||
"-isolateDevice", pci_id,
|
||||
"-modulepath",
|
||||
|
@ -1,49 +0,0 @@
|
||||
Section "DRI"
|
||||
Mode 0666
|
||||
EndSection
|
||||
|
||||
Section "ServerLayout"
|
||||
Identifier "Layout0"
|
||||
Screen "Screen1"
|
||||
Option "AutoAddDevices" "false"
|
||||
EndSection
|
||||
|
||||
Section "Module"
|
||||
Load "dbe"
|
||||
Load "extmod"
|
||||
Load "glx"
|
||||
Load "record"
|
||||
Load "freetype"
|
||||
Load "type1"
|
||||
EndSection
|
||||
|
||||
Section "Files"
|
||||
EndSection
|
||||
|
||||
Section "Device"
|
||||
Identifier "Device1"
|
||||
Driver "nvidia"
|
||||
VendorName "NVIDIA Corporation"
|
||||
Option "NoLogo" "true"
|
||||
Option "UseEDID" "false"
|
||||
Option "ConnectedMonitor" "CRT-0"
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "Screen1"
|
||||
Device "Device1"
|
||||
Monitor "Monitor0"
|
||||
DefaultDepth 24
|
||||
SubSection "Display"
|
||||
Depth 24
|
||||
EndSubSection
|
||||
EndSection
|
||||
|
||||
Section "Extensions"
|
||||
Option "Composite" "Enable"
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
Identifier "Monitor0"
|
||||
Option "DPMS"
|
||||
EndSection
|
Loading…
Reference in New Issue
Block a user