From 24abe2b2b3f301e3a0185138b87e7a7052828248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Bernardo=20Galkin?= Date: Sat, 20 Dec 2014 02:51:24 -0800 Subject: [PATCH] Bumblebee config to enable multiple monitors Added configurations to `bumblebee` package to easy multiple monitors on Optimus machines. The behaviour of the default `bumblebee` package hasn't change, so this change is backwards compatible. Users who want to connect a monitor to their discrete card should use the package `bumblebee_display` instead. Also added new configuration option to nixos bumblebee module: ``` hardware.bumblebee.connectDisplay = true ``` will enable the new configuration, but the default is still false. --- nixos/modules/hardware/video/bumblebee.nix | 23 +++++++++++++++++++--- pkgs/tools/X11/bumblebee/default.nix | 21 ++++++++++++++++++-- pkgs/tools/X11/bumblebee/nvidia-conf.patch | 11 +++++++++++ pkgs/tools/X11/bumblebee/xopts.patch | 4 ++-- pkgs/top-level/all-packages.nix | 5 +++++ 5 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 pkgs/tools/X11/bumblebee/nvidia-conf.patch diff --git a/nixos/modules/hardware/video/bumblebee.nix b/nixos/modules/hardware/video/bumblebee.nix index 7b48d9d1fcf..e20ebc3041e 100644 --- a/nixos/modules/hardware/video/bumblebee.nix +++ b/nixos/modules/hardware/video/bumblebee.nix @@ -1,7 +1,13 @@ { config, lib, pkgs, ... }: -let kernel = config.boot.kernelPackages; in with lib; +let + kernel = config.boot.kernelPackages; + bumblebee = if config.hardware.bumblebee.connectDisplay + then pkgs.bumblebee_display + else pkgs.bumblebee; + +in { @@ -23,6 +29,17 @@ with lib; type = types.uniq types.str; description = ''Group for bumblebee socket''; }; + hardware.bumblebee.connectDisplay = mkOption { + default = false; + type = types.bool; + description = '' + Set to true if you intend to connect your discrete card to a + monitor. This option will set up your Nvidia card for EDID + discovery and to turn on the monitor signal. + + Only nvidia driver is supported so far. + ''; + }; }; config = mkIf config.hardware.bumblebee.enable { @@ -30,13 +47,13 @@ with lib; boot.kernelModules = [ "bbswitch" ]; boot.extraModulePackages = [ kernel.bbswitch kernel.nvidia_x11 ]; - environment.systemPackages = [ pkgs.bumblebee pkgs.primus ]; + environment.systemPackages = [ bumblebee pkgs.primus ]; systemd.services.bumblebeed = { description = "Bumblebee Hybrid Graphics Switcher"; wantedBy = [ "display-manager.service" ]; script = "bumblebeed --use-syslog -g ${config.hardware.bumblebee.group}"; - path = [ kernel.bbswitch pkgs.bumblebee ]; + path = [ kernel.bbswitch bumblebee ]; serviceConfig = { Restart = "always"; RestartSec = 60; diff --git a/pkgs/tools/X11/bumblebee/default.nix b/pkgs/tools/X11/bumblebee/default.nix index 1d5c2a129c0..d314c7857ea 100644 --- a/pkgs/tools/X11/bumblebee/default.nix +++ b/pkgs/tools/X11/bumblebee/default.nix @@ -31,6 +31,8 @@ # TODO: Confusing. Perhaps use "SubArch" instead of i686? , nvidia_x11_i686 ? null , virtualgl_i686 ? null +, useDisplayDevice ? false +, extraDeviceOptions ? "" }: with stdenv.lib; let @@ -77,15 +79,26 @@ let allEnvs = [hostEnv] ++ optional (i686Env != null) i686Env; ldPathString = makeLibraryPath allEnvs; + # By default we don't want to use a display device + deviceOptions = if useDisplayDevice + then "" + else '' + + # Disable display device + Option "UseEDID" "false" + Option "UseDisplayDevice" "none" + '' + + extraDeviceOptions; + in stdenv.mkDerivation { - inherit name; + inherit name deviceOptions; src = fetchurl { url = "http://bumblebee-project.org/${name}.tar.gz"; sha256 = "03p3gvx99lwlavznrpg9l7jnl1yfg2adcj8jcjj0gxp20wxp060h"; }; - patches = [ ./xopts.patch ]; + patches = [ ./xopts.patch ./nvidia-conf.patch]; preConfigure = '' # Substitute the path to the actual modinfo program in module.c. @@ -98,6 +111,10 @@ in stdenv.mkDerivation { # Don't use a special group, just reuse wheel. substituteInPlace configure \ --replace 'CONF_GID="bumblebee"' 'CONF_GID="wheel"' + + # Apply configuration options + substituteInPlace conf/xorg.conf.nvidia \ + --subst-var deviceOptions ''; # Build-time dependencies of bumblebeed and optirun. diff --git a/pkgs/tools/X11/bumblebee/nvidia-conf.patch b/pkgs/tools/X11/bumblebee/nvidia-conf.patch new file mode 100644 index 00000000000..f5535c417cf --- /dev/null +++ b/pkgs/tools/X11/bumblebee/nvidia-conf.patch @@ -0,0 +1,11 @@ +--- bumblebee-3.2.1/conf/xorg.conf.nvidia ++++ bumblebee-3.2.1/conf/xorg.conf.nvidia +@@ -29,6 +29,5 @@ Section "Device" + Option "ProbeAllGpus" "false" + + Option "NoLogo" "true" +- Option "UseEDID" "false" +- Option "UseDisplayDevice" "none" ++@deviceOptions@ + EndSection + diff --git a/pkgs/tools/X11/bumblebee/xopts.patch b/pkgs/tools/X11/bumblebee/xopts.patch index f24b2a20562..6fd3a6a0483 100644 --- a/pkgs/tools/X11/bumblebee/xopts.patch +++ b/pkgs/tools/X11/bumblebee/xopts.patch @@ -1,5 +1,5 @@ ---- bumblebee-3.0/src/bbsecondary.c.orig 2012-02-05 00:03:06.003439638 +0100 -+++ bumblebee-3.0/src/bbsecondary.c 2012-02-05 00:46:38.017382619 +0100 +--- bumblebee-3.2.1/src/bbsecondary.c 2012-02-05 00:03:06.003439638 +0100 ++++ bumblebee-3.2.1/src/bbsecondary.c 2012-02-05 00:46:38.017382619 +0100 @@ -149,6 +149,8 @@ "-sharevts", "-nolisten", "tcp", diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index aef3dc31166..89a078c04df 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11156,6 +11156,11 @@ let else null; }; + # use if you intend to connect the nvidia card to a monitor + bumblebee_display = bumblebee.override { + useDisplayDevice = true; + }; + vkeybd = callPackage ../applications/audio/vkeybd { inherit (xlibs) libX11; };