Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 46 lines 1.4 kB view raw
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{ 7 stdenv, 8 pkgsi686Linux, 9 lib, 10 primusLib, 11 writeScriptBin, 12 runtimeShell, 13 primusLib_i686 ? 14 if stdenv.hostPlatform.system == "x86_64-linux" then pkgsi686Linux.primusLib else null, 15 useNvidia ? true, 16}: 17 18let 19 # We override stdenv in case we need different ABI for libGL 20 primusLib_ = primusLib.override { inherit stdenv; }; 21 primusLib_i686_ = primusLib_i686.override { stdenv = pkgsi686Linux.stdenv; }; 22 23 primus = if useNvidia then primusLib_ else primusLib_.override { nvidia_x11 = null; }; 24 primus_i686 = 25 if useNvidia then primusLib_i686_ else primusLib_i686_.override { nvidia_x11 = null; }; 26 ldPath = lib.makeLibraryPath ( 27 lib.filter (x: x != null) ( 28 [ 29 primus 30 primus.glvnd 31 ] 32 ++ lib.optionals (primusLib_i686 != null) [ 33 primus_i686 34 primus_i686.glvnd 35 ] 36 ) 37 ); 38 39in 40writeScriptBin "primusrun" '' 41 #!${runtimeShell} 42 export LD_LIBRARY_PATH=${ldPath}''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH 43 # https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1758243 44 export __GLVND_DISALLOW_PATCHING=1 45 exec "$@" 46''