2012-02-05 00:51:35 +00:00
|
|
|
# The bumblebee package allows a program to be rendered on an
|
2014-05-03 14:28:21 +00:00
|
|
|
# dedicated video card by spawning an additional X11 server and
|
|
|
|
# streaming the results via VirtualGL or primus to the primary server.
|
2012-02-05 00:51:35 +00:00
|
|
|
|
|
|
|
# The package is rather chaotic; it's also quite recent.
|
|
|
|
# As it may change a lot, some of the hacks in this nix expression
|
|
|
|
# will hopefully not be needed in the future anymore.
|
|
|
|
|
2014-05-03 14:28:21 +00:00
|
|
|
# To test:
|
|
|
|
# 1. make sure that the 'bbswitch' kernel module is installed,
|
|
|
|
# 2. then run 'bumblebeed' as root
|
|
|
|
# 3. Then either 'optirun glxinfo' or 'primusrun glxinfo' as user.
|
|
|
|
#
|
|
|
|
# The glxinfo output should indicate the NVidia driver is being used
|
|
|
|
# and all expected extensions are supported.
|
|
|
|
#
|
2014-02-08 18:47:51 +00:00
|
|
|
# To use at startup, see hardware.bumblebee options.
|
2012-02-05 00:51:35 +00:00
|
|
|
|
2016-11-07 08:02:37 +00:00
|
|
|
{ stdenv, lib, fetchurl, fetchpatch, pkgconfig, help2man, makeWrapper
|
2015-12-04 21:35:37 +00:00
|
|
|
, glib, libbsd
|
2018-07-21 00:44:44 +00:00
|
|
|
, libX11, xorgserver, kmod, xf86videonouveau
|
|
|
|
, nvidia_x11, virtualgl, libglvnd
|
2016-10-30 17:47:13 +00:00
|
|
|
, automake111x, autoconf
|
2014-05-03 14:28:21 +00:00
|
|
|
# The below should only be non-null in a x86_64 system. On a i686
|
|
|
|
# system the above nvidia_x11 and virtualgl will be the i686 packages.
|
|
|
|
# TODO: Confusing. Perhaps use "SubArch" instead of i686?
|
|
|
|
, nvidia_x11_i686 ? null
|
2017-01-29 21:29:39 +00:00
|
|
|
, libglvnd_i686 ? null
|
2014-12-20 10:51:24 +00:00
|
|
|
, useDisplayDevice ? false
|
2015-12-04 21:35:37 +00:00
|
|
|
, extraNvidiaDeviceOptions ? ""
|
|
|
|
, extraNouveauDeviceOptions ? ""
|
|
|
|
, useNvidia ? true
|
2012-02-05 00:51:35 +00:00
|
|
|
}:
|
2015-12-04 21:35:37 +00:00
|
|
|
|
2012-02-05 00:51:35 +00:00
|
|
|
let
|
2014-02-08 18:47:51 +00:00
|
|
|
version = "3.2.1";
|
2012-02-05 00:51:35 +00:00
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
nvidia_x11s = [ nvidia_x11 ]
|
|
|
|
++ lib.optional nvidia_x11.useGLVND libglvnd
|
|
|
|
++ lib.optionals (nvidia_x11_i686 != null)
|
|
|
|
([ nvidia_x11_i686 ] ++ lib.optional nvidia_x11_i686.useGLVND libglvnd_i686);
|
2014-05-03 14:28:21 +00:00
|
|
|
|
2015-12-04 21:35:37 +00:00
|
|
|
nvidiaLibs = lib.makeLibraryPath nvidia_x11s;
|
2014-05-03 14:28:21 +00:00
|
|
|
|
2016-04-22 07:40:57 +00:00
|
|
|
bbdPath = lib.makeBinPath [ kmod xorgserver ];
|
2014-12-20 10:51:24 +00:00
|
|
|
|
2016-04-30 23:10:24 +00:00
|
|
|
xmodules = lib.concatStringsSep "," (map (x: "${x.out or x}/lib/xorg/modules") ([ xorgserver ] ++ lib.optional (!useNvidia) xf86videonouveau));
|
2014-12-20 10:51:24 +00:00
|
|
|
|
2016-11-07 08:02:37 +00:00
|
|
|
modprobePatch = fetchpatch {
|
2016-10-30 17:47:13 +00:00
|
|
|
url = "https://github.com/Bumblebee-Project/Bumblebee/commit/1ada79fe5916961fc4e4917f8c63bb184908d986.patch";
|
2016-11-07 08:02:37 +00:00
|
|
|
sha256 = "02vq3vba6nx7gglpjdfchws9vjhs1x02a543yvqrxqpvvdfim2x2";
|
2016-10-30 17:47:13 +00:00
|
|
|
};
|
2016-11-07 08:02:37 +00:00
|
|
|
libkmodPatch = fetchpatch {
|
2016-10-30 17:47:13 +00:00
|
|
|
url = "https://github.com/Bumblebee-Project/Bumblebee/commit/deceb14cdf2c90ff64ebd1010a674305464587da.patch";
|
2016-11-07 08:02:37 +00:00
|
|
|
sha256 = "00c05i5lxz7vdbv445ncxac490vbl5g9w3vy3gd71qw1f0si8vwh";
|
2016-10-30 17:47:13 +00:00
|
|
|
};
|
|
|
|
|
2015-12-04 21:35:37 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2019-08-13 21:52:01 +00:00
|
|
|
pname = "bumblebee";
|
|
|
|
inherit version;
|
2012-02-05 00:51:35 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-08-13 21:52:01 +00:00
|
|
|
url = "https://bumblebee-project.org/${pname}-${version}.tar.gz";
|
2014-02-08 18:47:51 +00:00
|
|
|
sha256 = "03p3gvx99lwlavznrpg9l7jnl1yfg2adcj8jcjj0gxp20wxp060h";
|
2012-02-05 00:51:35 +00:00
|
|
|
};
|
|
|
|
|
2016-10-30 17:47:13 +00:00
|
|
|
patches = [
|
|
|
|
./nixos.patch
|
|
|
|
|
|
|
|
modprobePatch
|
|
|
|
libkmodPatch
|
|
|
|
];
|
2015-12-04 21:35:37 +00:00
|
|
|
|
|
|
|
# By default we don't want to use a display device
|
|
|
|
nvidiaDeviceOptions = lib.optionalString (!useDisplayDevice) ''
|
|
|
|
# Disable display device
|
|
|
|
Option "UseEDID" "false"
|
|
|
|
Option "UseDisplayDevice" "none"
|
|
|
|
'' + extraNvidiaDeviceOptions;
|
|
|
|
|
|
|
|
nouveauDeviceOptions = extraNouveauDeviceOptions;
|
2012-02-05 00:51:35 +00:00
|
|
|
|
2015-11-25 15:30:07 +00:00
|
|
|
# the have() function is deprecated and not available to bash completions the
|
|
|
|
# way they are currently loaded in NixOS, so use _have. See #10936
|
2015-12-09 18:02:54 +00:00
|
|
|
postPatch = ''
|
2015-11-25 15:30:07 +00:00
|
|
|
substituteInPlace scripts/bash_completion/bumblebee \
|
|
|
|
--replace "have optirun" "_have optirun"
|
|
|
|
'';
|
|
|
|
|
2012-02-05 00:51:35 +00:00
|
|
|
preConfigure = ''
|
|
|
|
# Don't use a special group, just reuse wheel.
|
|
|
|
substituteInPlace configure \
|
|
|
|
--replace 'CONF_GID="bumblebee"' 'CONF_GID="wheel"'
|
2014-12-20 10:51:24 +00:00
|
|
|
|
|
|
|
# Apply configuration options
|
|
|
|
substituteInPlace conf/xorg.conf.nvidia \
|
2015-12-04 21:35:37 +00:00
|
|
|
--subst-var nvidiaDeviceOptions
|
|
|
|
|
|
|
|
substituteInPlace conf/xorg.conf.nouveau \
|
|
|
|
--subst-var nouveauDeviceOptions
|
2012-02-05 00:51:35 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Build-time dependencies of bumblebeed and optirun.
|
|
|
|
# Note that it has several runtime dependencies.
|
2016-11-07 08:02:37 +00:00
|
|
|
buildInputs = [ libX11 glib libbsd kmod ];
|
|
|
|
nativeBuildInputs = [ makeWrapper pkgconfig help2man automake111x autoconf ];
|
2012-02-05 00:51:35 +00:00
|
|
|
|
2014-05-03 14:28:21 +00:00
|
|
|
# The order of LDPATH is very specific: First X11 then the host
|
|
|
|
# environment then the optional sub architecture paths.
|
|
|
|
#
|
|
|
|
# The order for MODPATH is the opposite: First the environment that
|
|
|
|
# includes the acceleration driver. As this is used for the X11
|
|
|
|
# server, which runs under the host architecture, this does not
|
|
|
|
# include the sub architecture components.
|
2014-02-08 18:47:51 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--with-udev-rules=$out/lib/udev/rules.d"
|
2015-12-04 21:35:37 +00:00
|
|
|
# see #10282
|
|
|
|
#"CONF_PRIMUS_LD_PATH=${primusLibs}"
|
|
|
|
] ++ lib.optionals useNvidia [
|
|
|
|
"CONF_LDPATH_NVIDIA=${nvidiaLibs}"
|
2017-01-29 21:29:39 +00:00
|
|
|
"CONF_MODPATH_NVIDIA=${nvidia_x11.bin}/lib/xorg/modules"
|
2015-12-04 21:35:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
CFLAGS = [
|
|
|
|
"-DX_MODULE_APPENDS=\\\"${xmodules}\\\""
|
2014-02-08 18:47:51 +00:00
|
|
|
];
|
|
|
|
|
2012-02-05 00:51:35 +00:00
|
|
|
postInstall = ''
|
|
|
|
wrapProgram "$out/sbin/bumblebeed" \
|
2018-03-19 09:43:36 +00:00
|
|
|
--prefix PATH : "${bbdPath}"
|
2012-02-05 00:51:35 +00:00
|
|
|
|
|
|
|
wrapProgram "$out/bin/optirun" \
|
2015-12-04 21:35:37 +00:00
|
|
|
--prefix PATH : "${virtualgl}/bin"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2017-08-02 21:50:51 +00:00
|
|
|
homepage = https://github.com/Bumblebee-Project/Bumblebee;
|
2012-02-05 00:51:35 +00:00
|
|
|
description = "Daemon for managing Optimus videocards (power-on/off, spawns xservers)";
|
2015-12-04 21:35:37 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.gpl3;
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
2012-02-05 00:51:35 +00:00
|
|
|
};
|
|
|
|
}
|