about summary refs log tree commit diff
path: root/pkgs/tools/X11/primus/default.nix
blob: 684713bebb1abc44c28215ec12929b1436e03b54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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";
    maintainers = maintainers.coconnor;
  };
}