···16#
17# To use at startup, see hardware.bumblebee options.
1819-# This nix expression supports for now only the native nvidia driver.
20-# It should not be hard to generalize this approach to support the
21-# nouveau driver as well (parameterize hostEnv, i686Env over the
22-# module package, and parameterize the two wrappers as well)
23-24-{ stdenv, fetchurl, pkgconfig, help2man
25-, libX11, glibc, glib, libbsd
26-, makeWrapper, buildEnv, module_init_tools
27-, xorg, xkeyboard_config
28-, nvidia_x11, virtualgl
29# The below should only be non-null in a x86_64 system. On a i686
30# system the above nvidia_x11 and virtualgl will be the i686 packages.
31# TODO: Confusing. Perhaps use "SubArch" instead of i686?
32, nvidia_x11_i686 ? null
33-, virtualgl_i686 ? null
34, useDisplayDevice ? false
35-, extraDeviceOptions ? ""
0036}:
37-with stdenv.lib;
38let
39 version = "3.2.1";
40- name = "bumblebee-${version}";
4142- # Isolated X11 environment without the acceleration driver module.
43- # Includes the rest of the components needed for bumblebeed and
44- # optirun to spawn the second X server and to connect to it.
45- x11Env = buildEnv {
46- name = "bumblebee-env";
47- paths = [
48- module_init_tools
49- xorg.xorgserver
50- xorg.xrandr
51- xorg.xrdb
52- xorg.setxkbmap
53- xorg.libX11
54- xorg.libXext
55- xorg.xf86inputevdev
56- ];
57- };
5859- # The environment for the host architecture.
60- hostEnv = buildEnv {
61- name = "bumblebee-x64-env";
62- paths = [
63- nvidia_x11
64- virtualgl
65- ];
66- };
6768- # The environment for the sub architecture, i686, if there is one
69- i686Env = if virtualgl_i686 != null
70- then buildEnv {
71- name = "bumblebee-i686-env";
72- paths = [
73- nvidia_x11_i686
74- virtualgl_i686
75- ];
76- }
77- else null;
7879- allEnvs = [hostEnv] ++ optional (i686Env != null) i686Env;
80- ldPathString = makeLibraryPath allEnvs;
8182- # By default we don't want to use a display device
83- deviceOptions = if useDisplayDevice
84- then ""
85- else ''
8687- # Disable display device
88- Option "UseEDID" "false"
89- Option "UseDisplayDevice" "none"
90- ''
91- + extraDeviceOptions;
9293-in stdenv.mkDerivation {
94- inherit name deviceOptions;
9596 src = fetchurl {
97 url = "http://bumblebee-project.org/${name}.tar.gz";
98 sha256 = "03p3gvx99lwlavznrpg9l7jnl1yfg2adcj8jcjj0gxp20wxp060h";
99 };
100101- patches = [ ./xopts.patch ./nvidia-conf.patch];
000000000102103 preConfigure = ''
104 # Substitute the path to the actual modinfo program in module.c.
···114115 # Apply configuration options
116 substituteInPlace conf/xorg.conf.nvidia \
117- --subst-var deviceOptions
000118 '';
119120 # Build-time dependencies of bumblebeed and optirun.
121 # Note that it has several runtime dependencies.
122- buildInputs = [ stdenv makeWrapper pkgconfig help2man libX11 glib libbsd ];
0123124 # The order of LDPATH is very specific: First X11 then the host
125 # environment then the optional sub architecture paths.
···130 # include the sub architecture components.
131 configureFlags = [
132 "--with-udev-rules=$out/lib/udev/rules.d"
133- "CONF_DRIVER=nvidia"
134- "CONF_DRIVER_MODULE_NVIDIA=nvidia"
135- "CONF_LDPATH_NVIDIA=${x11Env}/lib:${ldPathString}"
136- "CONF_MODPATH_NVIDIA=${hostEnv}/lib/xorg/modules,${x11Env}/lib/xorg/modules"
0137 ];
138139- # create a wrapper environment for bumblebeed and optirun
0000140 postInstall = ''
141 wrapProgram "$out/sbin/bumblebeed" \
142- --prefix PATH : "${x11Env}/sbin:${x11Env}/bin:${hostEnv}/bin:\$PATH" \
143- --prefix LD_LIBRARY_PATH : "${x11Env}/lib:${hostEnv}/lib:\$LD_LIBRARY_PATH" \
144- --set FONTCONFIG_FILE "/etc/fonts/fonts.conf" \
145- --set XKB_BINDIR "${xorg.xkbcomp}/bin" \
146- --set XKB_DIR "${xkeyboard_config}/etc/X11/xkb"
147148 wrapProgram "$out/bin/optirun" \
149- --prefix PATH : "${hostEnv}/bin"
150- '' + (if i686Env == null
151- then ""
152- else ''
153- makeWrapper "$out/bin/.optirun-wrapped" "$out/bin/optirun32" \
154- --prefix PATH : "${i686Env}/bin"
155- '');
156157- meta = {
158 homepage = http://github.com/Bumblebee-Project/Bumblebee;
159 description = "Daemon for managing Optimus videocards (power-on/off, spawns xservers)";
160- license = stdenv.lib.licenses.gpl3;
00161 };
162}
···16#
17# To use at startup, see hardware.bumblebee options.
1819+{ stdenv, lib, fetchurl, pkgconfig, help2man, makeWrapper
20+, glib, libbsd
21+, libX11, libXext, xorgserver, xkbcomp, module_init_tools, xkeyboard_config, xf86videonouveau
22+, nvidia_x11, virtualgl, primusLib
00000023# The below should only be non-null in a x86_64 system. On a i686
24# system the above nvidia_x11 and virtualgl will be the i686 packages.
25# TODO: Confusing. Perhaps use "SubArch" instead of i686?
26, nvidia_x11_i686 ? null
27+, primusLib_i686 ? null
28, useDisplayDevice ? false
29+, extraNvidiaDeviceOptions ? ""
30+, extraNouveauDeviceOptions ? ""
31+, useNvidia ? true
32}:
33+34let
35 version = "3.2.1";
03637+ primus = if useNvidia then primusLib else primusLib.override { nvidia_x11 = null; };
38+ primus_i686 = if useNvidia then primusLib_i686 else primusLib_i686.override { nvidia_x11 = null; };
000000000000003940+ primusLibs = lib.makeLibraryPath ([primus] ++ lib.optional (primusLib_i686 != null) primus_i686);
00000004142+ nvidia_x11s = [nvidia_x11] ++ lib.optional (nvidia_x11_i686 != null) nvidia_x11_i686;
0000000004344+ nvidiaLibs = lib.makeLibraryPath nvidia_x11s;
04546+ bbdPath = lib.makeSearchPath "bin" [ module_init_tools xorgserver ];
47+ bbdLibs = lib.makeLibraryPath [ libX11 libXext ];
004849+ xmodules = lib.concatStringsSep "," (map (x: "${x}/lib/xorg/modules") ([ xorgserver ] ++ lib.optional (!useNvidia) xf86videonouveau));
00005051+in stdenv.mkDerivation rec {
52+ name = "bumblebee-${version}";
5354 src = fetchurl {
55 url = "http://bumblebee-project.org/${name}.tar.gz";
56 sha256 = "03p3gvx99lwlavznrpg9l7jnl1yfg2adcj8jcjj0gxp20wxp060h";
57 };
5859+ patches = [ ./nixos.patch ];
60+61+ # By default we don't want to use a display device
62+ nvidiaDeviceOptions = lib.optionalString (!useDisplayDevice) ''
63+ # Disable display device
64+ Option "UseEDID" "false"
65+ Option "UseDisplayDevice" "none"
66+ '' + extraNvidiaDeviceOptions;
67+68+ nouveauDeviceOptions = extraNouveauDeviceOptions;
6970 preConfigure = ''
71 # Substitute the path to the actual modinfo program in module.c.
···8182 # Apply configuration options
83 substituteInPlace conf/xorg.conf.nvidia \
84+ --subst-var nvidiaDeviceOptions
85+86+ substituteInPlace conf/xorg.conf.nouveau \
87+ --subst-var nouveauDeviceOptions
88 '';
8990 # Build-time dependencies of bumblebeed and optirun.
91 # Note that it has several runtime dependencies.
92+ buildInputs = [ libX11 glib libbsd ];
93+ nativeBuildInputs = [ makeWrapper pkgconfig help2man ];
9495 # The order of LDPATH is very specific: First X11 then the host
96 # environment then the optional sub architecture paths.
···101 # include the sub architecture components.
102 configureFlags = [
103 "--with-udev-rules=$out/lib/udev/rules.d"
104+ # see #10282
105+ #"CONF_PRIMUS_LD_PATH=${primusLibs}"
106+ ] ++ lib.optionals useNvidia [
107+ "CONF_LDPATH_NVIDIA=${nvidiaLibs}"
108+ "CONF_MODPATH_NVIDIA=${nvidia_x11}/lib/xorg/modules"
109 ];
110111+ CFLAGS = [
112+ "-DX_MODULE_APPENDS=\\\"${xmodules}\\\""
113+ "-DX_XKB_DIR=\\\"${xkeyboard_config}/etc/X11/xkb\\\""
114+ ];
115+116 postInstall = ''
117 wrapProgram "$out/sbin/bumblebeed" \
118+ --set XKB_BINDIR "${xkbcomp}/bin" \
119+ --prefix PATH : "${bbdPath}" \
120+ --prefix LD_LIBRARY_PATH : "${bbdLibs}"
00121122 wrapProgram "$out/bin/optirun" \
123+ --prefix PATH : "${virtualgl}/bin"
124+ '';
00000125126+ meta = with stdenv.lib; {
127 homepage = http://github.com/Bumblebee-Project/Bumblebee;
128 description = "Daemon for managing Optimus videocards (power-on/off, spawns xservers)";
129+ platforms = platforms.linux;
130+ license = licenses.gpl3;
131+ maintainers = with maintainers; [ abbradar ];
132 };
133}