summary refs log tree commit diff
path: root/pkgs/tools/X11/primus/default.nix
diff options
context:
space:
mode:
authorCorey O'Connor <coreyoconnor@gmail.com>2014-05-03 07:28:21 -0700
committerCorey O'Connor <coreyoconnor@gmail.com>2014-11-29 16:42:00 -0800
commitb2f3e10a35fe213e04f1fe88b64cc1069b376365 (patch)
tree9a9dd388fbac78b4739850a4087b2fcd6b9a1b97 /pkgs/tools/X11/primus/default.nix
parent20487919b2d349895798af6579b1097528f17ad2 (diff)
downloadnixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.tar
nixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.tar.gz
nixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.tar.bz2
nixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.tar.lz
nixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.tar.xz
nixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.tar.zst
nixlib-b2f3e10a35fe213e04f1fe88b64cc1069b376365.zip
Add primus and extend bumblebee to support 32bit/64bit multilib architectures.
Using primusrun will work as expected in a multilib environment. Even if the initial program
executes a antoehr program of the another architecture. Assuming the program does not modify
LD_LIBRARY_PATH inappropriately.

This does not update virtualgl for seemless multilib. I was unable to get a mixed 64/32 bit
environment to work with VirtualGL. The mechanism VirtualGL uses to inject the fake GL library would
fail if both 32bit and 64 bit libraries were in the environment. Instead the bumblebee package
creates a optirun32 executable that can be used to run a 32bit executable with optimus on a 64 bit
host. This is not created if the host is 32bit.

For my usage, gaming under wine, the primusrun executable works as expected regardless of
32bit/64bit.
Diffstat (limited to 'pkgs/tools/X11/primus/default.nix')
-rw-r--r--pkgs/tools/X11/primus/default.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/tools/X11/primus/default.nix b/pkgs/tools/X11/primus/default.nix
new file mode 100644
index 000000000000..f457d25fe1b9
--- /dev/null
+++ b/pkgs/tools/X11/primus/default.nix
@@ -0,0 +1,40 @@
+# For a 64bit + 32bit system the LD_LIBRARY_PATH must contain both the 32bit and 64bit primus
+# libraries. Providing a different primusrun for each architecture will not work as expected. EG:
+# Using steam under wine can involve both 32bit and 64bit process. All of which inherit the
+# same LD_LIBRARY_PATH.
+# Other distributions do the same.
+{ stdenv
+, primusLib
+, writeScript
+, primusLib_i686 ? null
+}:
+with stdenv.lib;
+let
+  version = "1.0.0748176";
+  ldPath = makeLibraryPath ([primusLib] ++ optional (primusLib_i686 != null) primusLib_i686);
+  primusrun = writeScript "primusrun"
+''
+  export LD_LIBRARY_PATH=${ldPath}:\$LD_LIBRARY_PATH
+  # see: https://github.com/amonakov/primus/issues/138
+  # On my system, as of 3.16.6, the intel driver dies when the pixel buffers try to read from the
+  # source memory directly. Setting PRIMUS_UPLOAD causes an indirection through textures which
+  # avoids this issue.
+  export PRIMUS_UPLOAD=1
+  exec "$@"
+'';
+in
+stdenv.mkDerivation {
+  name = "primus-${version}";
+  builder = writeScript "builder"
+  ''
+  source $stdenv/setup
+  mkdir -p $out/bin
+  cp ${primusrun} $out/bin/primusrun
+  '';
+
+  meta = {
+    homepage = https://github.com/amonakov/primus;
+    description = "Faster OpenGL offloading for Bumblebee";
+    maintainer = maintainers.coconnor;
+  };
+}