about summary refs log tree commit diff
path: root/pkgs/games/runescape-launcher/default.nix
blob: 6bed4908f471f33113693f8d6a069f9c01983ddc (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
148
149
150
151
152
153
154
155
{ stdenv
, lib
, autoPatchelfHook
, buildFHSEnv
, cairo
, dpkg
, fetchurl
, gcc-unwrapped
, glib
, glibc
, gnome2
, gtk2-x11
, libGL
, libpulseaudio
, libSM
, libXxf86vm
, libX11
, openssl_1_1
, pango
, SDL2
, wrapGAppsHook3
, xdg-utils
, xorg
, xorg_sys_opengl
, zlib
}:
let

  runescape = stdenv.mkDerivation rec {
    pname = "runescape-launcher";
    version = "2.2.10";

    # Packages: https://content.runescape.com/downloads/ubuntu/dists/trusty/non-free/binary-amd64/Packages
    # upstream is https://content.runescape.com/downloads/ubuntu/pool/non-free/r/${pname}/${pname}_${version}_amd64.deb
    src = fetchurl {
      url = "https://archive.org/download/${pname}_${version}_amd64/${pname}_${version}_amd64.deb";
      sha256 = "1v96vjiblphhbqhpp3m7wbvdvcnp76ncdlf4pdcr2z1dz8nh6shg";
    };

    nativeBuildInputs = [
      autoPatchelfHook
      dpkg
      wrapGAppsHook3
    ];

    buildInputs = [
      cairo
      gcc-unwrapped
      glib
      glibc
      gtk2-x11
      libSM
      libXxf86vm
      libX11
      openssl_1_1
      pango
      zlib
    ];

    runtimeDependencies = [
      libGL
      libpulseaudio
      SDL2
      openssl_1_1
      xdg-utils # The launcher uses `xdg-open` to open HTTP URLs in the user's browser
      xorg_sys_opengl
      zlib
    ];

    dontUnpack = true;

    preBuild = ''
      export DH_VERBOSE=1
    '';

    envVarsWithXmodifiers = ''
      export MESA_GLSL_CACHE_DIR=~/Jagex
      export GDK_SCALE=2
      unset XMODIFIERS
    '';

    installPhase = ''
      mkdir -p $out/bin $out/share
      dpkg -x $src $out

      patchShebangs $out/usr/bin/runescape-launcher
      substituteInPlace $out/usr/bin/runescape-launcher \
        --replace "unset XMODIFIERS" "$envVarsWithXmodifiers" \
        --replace "/usr/share/games/runescape-launcher/runescape" "$out/share/games/runescape-launcher/runescape"

      cp -r $out/usr/bin $out/
      cp -r $out/usr/share $out/

      rm -r $out/usr
    '';


    meta = with lib; {
      description = "Launcher for RuneScape 3, the current main RuneScape";
      homepage = "https://www.runescape.com/";
      sourceProvenance = with sourceTypes; [ binaryNativeCode ];
      license = licenses.unfree;
      maintainers = with maintainers; [ grburst ];
      platforms = [ "x86_64-linux" ];
    };
  };

in

  /*
  * We can patch the runescape launcher, but it downloads a client at runtime and checks it for changes.
  * For that we need use a buildFHSEnv.
  * FHS simulates a classic linux shell
  */
  buildFHSEnv {
    name = "RuneScape";
    targetPkgs = pkgs: [
      runescape
      cairo
      dpkg
      gcc-unwrapped
      glib
      glibc
      gtk2-x11
      libGL
      libpulseaudio
      libSM
      libXxf86vm
      libX11
      openssl_1_1
      pango
      SDL2
      xdg-utils
      xorg.libX11
      xorg_sys_opengl
      zlib
    ];
    multiPkgs = pkgs: [ libGL ];
    runScript = "runescape-launcher";
    extraInstallCommands = ''
      mkdir -p "$out/share/applications"
      cp ${runescape}/share/applications/runescape-launcher.desktop "$out/share/applications"
      cp -r ${runescape}/share/icons "$out/share/icons"
      substituteInPlace "$out/share/applications/runescape-launcher.desktop" \
        --replace "/usr/bin/runescape-launcher" "RuneScape"
    '';

    meta = with lib; {
      description = "RuneScape Game Client (NXT) - Launcher for RuneScape 3";
      homepage = "https://www.runescape.com/";
      license = licenses.unfree;
      maintainers = with maintainers; [ grburst ];
      platforms = [ "x86_64-linux" ];
    };
  }