summary refs log tree commit diff
path: root/pkgs/games/steam/runtime-wrapped.nix
blob: c5e5e525f36553b3844deeaa59a60ad7b74737e4 (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
{ stdenv, steamArch, lib, perl, pkgs, steam-runtime
, nativeOnly ? false
, runtimeOnly ? false
}:

assert !(nativeOnly && runtimeOnly);

let
  runtimePkgs = with pkgs; [
    # Required
    glib
    gtk2
    bzip2
    zlib
    gdk_pixbuf

    # Without these it silently fails
    xlibs.libXinerama
    xlibs.libXdamage
    xlibs.libXcursor
    xlibs.libXrender
    xlibs.libXScrnSaver
    xlibs.libXxf86vm
    xlibs.libXi
    xlibs.libSM
    xlibs.libICE
    gnome2.GConf
    freetype
    (curl.override { gnutlsSupport = true; sslSupport = false; })
    nspr
    nss
    fontconfig
    cairo
    pango
    expat
    dbus
    cups
    libcap
    SDL2
    libusb1
    dbus_glib
    libav
    atk
    # Only libraries are needed from those two
    libudev0-shim
    networkmanager098

    # Verified games requirements
    xlibs.libXmu
    xlibs.libxcb
    mesa_glu
    libuuid
    libogg
    libvorbis
    SDL
    SDL2_image
    glew110
    openssl
    libidn
    tbb

    # Other things from runtime
    xlibs.libXinerama
    flac
    freeglut
    libjpeg
    libpng12
    libsamplerate
    libmikmod
    libtheora
    pixman
    speex
    SDL_image
    SDL_ttf
    SDL_mixer
    SDL2_net
    SDL2_ttf
    SDL2_mixer
    gstreamer
    gst-plugins-base
  ];

  overridePkgs = with pkgs; [
    libgpgerror
    libpulseaudio
    alsaLib
    openalSoft
    libva
    vulkan-loader
    gcc.cc
    nss
    nspr
  ];

  ourRuntime = if runtimeOnly then []
               else if nativeOnly then runtimePkgs ++ overridePkgs
               else overridePkgs;
  steamRuntime = lib.optional (!nativeOnly) steam-runtime;

  allPkgs = ourRuntime ++ steamRuntime;

  gnuArch = if steamArch == "amd64" then "x86_64-linux-gnu"
            else if steamArch == "i386" then "i386-linux-gnu"
            else abort "Unsupported architecture";

  libs = [ "lib/${gnuArch}" "lib" "usr/lib/${gnuArch}" "usr/lib" ];
  bins = [ "bin" "usr/bin" ];

in stdenv.mkDerivation rec {
  name = "steam-runtime-wrapped";

  nativeBuildInputs = [ perl ];

  builder = ./build-wrapped.sh;

  passthru = {
    inherit gnuArch libs bins;
    arch = steamArch;
  };

  installPhase = ''
    buildDir "${toString libs}" "${toString (map lib.getLib allPkgs)}"
    buildDir "${toString bins}" "${toString (map lib.getBin allPkgs)}"
  '';
}