summary refs log tree commit diff
path: root/pkgs/applications/graphics/unigine-superposition/default.nix
blob: b1261bb52f23f3daf56c5d83dbde496919ad3253 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{ lib
, glib
, stdenv
, dbus
, freetype
, fontconfig
, zlib
, qtquickcontrols2
, libXinerama
, libxcb
, libSM
, libXi
, libglvnd
, libXext
, libXrandr
, mailspring
, libX11
, libICE
, libXrender
, autoPatchelfHook
, makeWrapper
, mkDerivation
, xkeyboard_config
, fetchurl
, buildFHSUserEnv
, openal
, makeDesktopItem
}:

let

  superposition = stdenv.mkDerivation rec{
    pname = "unigine-superposition";
    version = "1.1";

    src = fetchurl {
      url = "https://assets.unigine.com/d/Unigine_Superposition-${version}.run";
      sha256 = "12hzlz792pf8pvxf13fww3qhahqzwzkxq9q3mq20hbhvaphbg7nd";
    };

    nativeBuildInputs = [
      autoPatchelfHook
      makeWrapper
    ];

    buildInputs = [
      glib
      stdenv.cc.cc
      dbus
      freetype
      fontconfig
      zlib
      qtquickcontrols2
      libXinerama
      libxcb
      libSM
      libXi
      libglvnd
      libXext
      libXrandr
      mailspring
      libX11
      libICE
      libXrender
    ];

    installPhase = ''
      bash $src --target $name --noexec
      mkdir -p $out/bin $out/lib/unigine/superposition/
      cp -r $name/* $out/lib/unigine/superposition/
      echo "exec $out/lib/unigine/superposition/Superposition" >> $out/bin/superposition
      chmod +x $out/bin/superposition
       wrapProgram $out/lib/unigine/superposition/Superposition \
        --set QT_XKB_CONFIG_ROOT ${xkeyboard_config} \
        --run "cd $out/lib/unigine/superposition/"
    '';

    dontUnpack = true;
    dontWrapQtApps = true;

    postPatchMkspecs = ''
      cp -f $name/bin/superposition $out/lib/unigine/superposition/bin/superposition
    '';
  };

  desktopItem = makeDesktopItem {
    name = "Superposition";
    exec = "Superposition";
    genericName = "A GPU Stress test tool from the UNIGINE";
    icon = "Superposition";
    desktopName = "Superposition Benchmark";
  };

in

# We can patch the "/bin/superposition", but "/bin/launcher" checks it for changes.
# For that we need use a buildFHSUserEnv.

buildFHSUserEnv {
  name = "Superposition";

  targetPkgs = pkgs: [
    superposition
    glib
    stdenv.cc.cc
    dbus
    freetype
    fontconfig
    zlib
    qtquickcontrols2
    libXinerama
    libxcb
    libSM
    libXi
    libglvnd
    libXext
    libXrandr
    mailspring
    libX11
    libICE
    libXrender
    openal
  ];
  runScript = "superposition";

  extraInstallCommands = ''
    # create directories
    mkdir -p $out/share/icons/hicolor $out/share/applications
    # create .desktop file
    ln -s ${desktopItem}/share/applications/* $out/share/applications
    # install Superposition.desktop and icon
    cp ${superposition}/lib/unigine/superposition/Superposition.png $out/share/icons/
    for RES in 16 24 32 48 64 128 256; do
      mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
      cp ${superposition}/lib/unigine/superposition/icons/superposition_icon_$RES.png $out/share/icons/hicolor/"$RES"x"$RES"/apps/Superposition.png
    done
  '';

  meta = {
    description = "The Unigine Superposition GPU benchmarking tool";
    homepage = "https://benchmark.unigine.com/superposition";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.unfree;
    maintainers = [ lib.maintainers.BarinovMaxim ];
    platforms = [ "x86_64-linux" ];
  };
}