lol
1# For a 64bit + 32bit system the LD_LIBRARY_PATH must contain both the 32bit and 64bit primus
2# libraries. Providing a different primusrun for each architecture will not work as expected. EG:
3# Using steam under wine can involve both 32bit and 64bit process. All of which inherit the
4# same LD_LIBRARY_PATH.
5# Other distributions do the same.
6{ stdenv
7, stdenv_i686
8, lib
9, primusLib
10, writeScriptBin
11, runtimeShell
12, primusLib_i686 ? null
13, useNvidia ? true
14}:
15
16let
17 # We override stdenv in case we need different ABI for libGL
18 primusLib_ = primusLib.override { inherit stdenv; };
19 primusLib_i686_ = primusLib_i686.override { stdenv = stdenv_i686; };
20
21 primus = if useNvidia then primusLib_ else primusLib_.override { nvidia_x11 = null; };
22 primus_i686 = if useNvidia then primusLib_i686_ else primusLib_i686_.override { nvidia_x11 = null; };
23 ldPath = lib.makeLibraryPath (lib.filter (x: x != null) (
24 [ primus primus.glvnd ]
25 ++ lib.optionals (primusLib_i686 != null) [ primus_i686 primus_i686.glvnd ]
26 ));
27
28in writeScriptBin "primusrun" ''
29 #!${runtimeShell}
30 export LD_LIBRARY_PATH=${ldPath}''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
31 # https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1758243
32 export __GLVND_DISALLOW_PATCHING=1
33 exec "$@"
34''