Skip to content

Commit

Permalink
build bumblebee with references to both 32 and 64bit libs
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyoconnor committed May 3, 2014
1 parent 3fb1049 commit a16e076
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
42 changes: 28 additions & 14 deletions pkgs/tools/X11/bumblebee/default.nix
Expand Up @@ -18,7 +18,9 @@
{ stdenv, fetchurl, pkgconfig, help2man
, libX11, glibc, glib, libbsd
, makeWrapper, buildEnv, module_init_tools
, linuxPackages, virtualgl, xorg, xkeyboard_config
, xorg, xkeyboard_config
, nvidia_x11_x64, nvidia_x11_i686
, virtualgl_x64, virtualgl_i686
}:

let
Expand All @@ -28,25 +30,34 @@ let
# isolated X11 environment with the nvidia module
# it should include all components needed for bumblebeed and
# optirun to spawn the second X server and to connect to it.
commonEnv = buildEnv {
x11Env = buildEnv {
name = "bumblebee-env";
paths = [
module_init_tools

linuxPackages.nvidia_x11
xorg.xorgserver
xorg.xrandr
xorg.xrdb
xorg.setxkbmap
xorg.libX11
xorg.libXext
xorg.xf86inputevdev
];
};

virtualgl
x64Env = buildEnv {
name = "bumblebee-x64-env";
paths = [
nvidia_x11_x64
virtualgl_x64
];
};

# the nvidia GLX module overwrites the one of xorgserver,
# thus nvidia_x11 must be before xorgserver in the paths.
ignoreCollisions = true;
i686Env = buildEnv {
name = "bumblebee-i686-env";
paths = [
nvidia_x11_i686
virtualgl_i686
];
};

in stdenv.mkDerivation {
Expand All @@ -63,6 +74,7 @@ in stdenv.mkDerivation {
# Substitute the path to the actual modinfo program in module.c.
# Note: module.c also calls rmmod and modprobe, but those just have to
# be in PATH, and thus no action for them is required.
substituteInPlace src/module.c \
--replace "/sbin/modinfo" "${module_init_tools}/sbin/modinfo"
Expand All @@ -79,22 +91,24 @@ in stdenv.mkDerivation {
"--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"
"CONF_LDPATH_NVIDIA=${x11Env}/lib:${x64Env}/lib:${i686Env}/lib"
"CONF_MODPATH_NVIDIA=${x64Env}/lib/xorg/modules,${x11Env}/lib/xorg/modules"
];

# create a wrapper environment for bumblebeed and optirun
postInstall = ''
wrapProgram "$out/sbin/bumblebeed" \
--prefix PATH : "${commonEnv}/sbin:${commonEnv}/bin:\$PATH" \
--prefix LD_LIBRARY_PATH : "${commonEnv}/lib:\$LD_LIBRARY_PATH" \
--prefix PATH : "${x11Env}/sbin:${x11Env}/bin:${x64Env}/bin" \
--prefix LD_LIBRARY_PATH : "${x11Env}/lib:${x64Env}/lib" \
--set FONTCONFIG_FILE "/etc/fonts/fonts.conf" \
--set XKB_BINDIR "${xorg.xkbcomp}/bin" \
--set XKB_DIR "${xkeyboard_config}/etc/X11/xkb"
wrapProgram "$out/bin/optirun" \
--prefix PATH : "${commonEnv}/sbin:${commonEnv}/bin" \
--prefix LD_LIBRARY_PATH : "${commonEnv}/lib" \
--prefix PATH : "${x64Env}/bin"
makeWrapper "$out/bin/.optirun-wrapped" "$out/bin/optirun32" \
--prefix PATH : "${i686Env}/bin"
'';

meta = {
Expand Down
7 changes: 6 additions & 1 deletion pkgs/top-level/all-packages.nix
Expand Up @@ -9326,7 +9326,12 @@ let

virtualgl = callPackage ../tools/X11/virtualgl { };

bumblebee = callPackage ../tools/X11/bumblebee { };
bumblebee = callPackage ../tools/X11/bumblebee {
nvidia_x11_x64 = linuxPackages.nvidia_x11;
nvidia_x11_i686 = callPackage_i686 ../os-specific/linux/nvidia-x11 { libsOnly = true; };
virtualgl_x64 = virtualgl;
virtualgl_i686 = pkgsi686Linux.virtualgl;
};

vkeybd = callPackage ../applications/audio/vkeybd {
inherit (xlibs) libX11;
Expand Down

0 comments on commit a16e076

Please sign in to comment.