btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / ru / runescape / package.nix
blob700003f640b09ddecb5ae708a12fad17c66bd21b
1 { stdenv
2 , lib
3 , autoPatchelfHook
4 , buildFHSEnv
5 , cairo
6 , dpkg
7 , fetchurl
8 , gcc-unwrapped
9 , glib
10 , glibc
11 , gtk2-x11
12 , libGL
13 , libpulseaudio
14 , libSM
15 , libXxf86vm
16 , libX11
17 , openssl_1_1
18 , pango
19 , SDL2
20 , wrapGAppsHook3
21 , xdg-utils
22 , xorg
23 , xorg_sys_opengl
24 , zlib
26 let
28   runescape = stdenv.mkDerivation rec {
29     pname = "runescape-launcher";
30     version = "2.2.10";
32     # Packages: https://content.runescape.com/downloads/ubuntu/dists/trusty/non-free/binary-amd64/Packages
33     # upstream is https://content.runescape.com/downloads/ubuntu/pool/non-free/r/${pname}/${pname}_${version}_amd64.deb
34     src = fetchurl {
35       url = "https://archive.org/download/${pname}_${version}_amd64/${pname}_${version}_amd64.deb";
36       sha256 = "1v96vjiblphhbqhpp3m7wbvdvcnp76ncdlf4pdcr2z1dz8nh6shg";
37     };
39     nativeBuildInputs = [
40       autoPatchelfHook
41       dpkg
42       wrapGAppsHook3
43     ];
45     buildInputs = [
46       cairo
47       gcc-unwrapped
48       glib
49       glibc
50       gtk2-x11
51       libSM
52       libXxf86vm
53       libX11
54       openssl_1_1
55       pango
56       zlib
57     ];
59     runtimeDependencies = [
60       libGL
61       libpulseaudio
62       SDL2
63       openssl_1_1
64       xdg-utils # The launcher uses `xdg-open` to open HTTP URLs in the user's browser
65       xorg_sys_opengl
66       zlib
67     ];
69     dontUnpack = true;
71     preBuild = ''
72       export DH_VERBOSE=1
73     '';
75     envVarsWithXmodifiers = ''
76       export MESA_GLSL_CACHE_DIR=~/Jagex
77       export GDK_SCALE=2
78       unset XMODIFIERS
79     '';
81     installPhase = ''
82       mkdir -p $out/bin $out/share
83       dpkg -x $src $out
85       patchShebangs $out/usr/bin/runescape-launcher
86       substituteInPlace $out/usr/bin/runescape-launcher \
87         --replace "unset XMODIFIERS" "$envVarsWithXmodifiers" \
88         --replace "/usr/share/games/runescape-launcher/runescape" "$out/share/games/runescape-launcher/runescape"
90       cp -r $out/usr/bin $out/
91       cp -r $out/usr/share $out/
93       rm -r $out/usr
94     '';
97     meta = with lib; {
98       description = "Launcher for RuneScape 3, the current main RuneScape";
99       homepage = "https://www.runescape.com/";
100       sourceProvenance = with sourceTypes; [ binaryNativeCode ];
101       license = licenses.unfree;
102       maintainers = with maintainers; [ grburst ];
103       platforms = [ "x86_64-linux" ];
104     };
105   };
109   /*
110   * We can patch the runescape launcher, but it downloads a client at runtime and checks it for changes.
111   * For that we need use a buildFHSEnv.
112   * FHS simulates a classic linux shell
113   */
114   buildFHSEnv {
115     name = "RuneScape";
116     targetPkgs = pkgs: [
117       runescape
118       cairo
119       dpkg
120       gcc-unwrapped
121       glib
122       glibc
123       gtk2-x11
124       libGL
125       libpulseaudio
126       libSM
127       libXxf86vm
128       libX11
129       openssl_1_1
130       pango
131       SDL2
132       xdg-utils
133       xorg.libX11
134       xorg_sys_opengl
135       zlib
136     ];
137     multiPkgs = pkgs: [ libGL ];
138     runScript = "runescape-launcher";
139     extraInstallCommands = ''
140       mkdir -p "$out/share/applications"
141       cp ${runescape}/share/applications/runescape-launcher.desktop "$out/share/applications"
142       cp -r ${runescape}/share/icons "$out/share/icons"
143       substituteInPlace "$out/share/applications/runescape-launcher.desktop" \
144         --replace "/usr/bin/runescape-launcher" "RuneScape"
145     '';
147     meta = with lib; {
148       description = "RuneScape Game Client (NXT) - Launcher for RuneScape 3";
149       homepage = "https://www.runescape.com/";
150       license = licenses.unfree;
151       maintainers = with maintainers; [ grburst ];
152       platforms = [ "x86_64-linux" ];
153     };
154   }