summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/nix/unwrapped.nix
blob: aac77ce155091949a3afdb4c11c0b7796942d34f (plain)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
{
  alsa-lib,
  atk,
  at-spi2-atk,
  cairo,
  fetchzip,
  lib,
  libcap,
  stdenv,
  cmake,
  apple-sdk_14,
  cups,
  dbus,
  expat,
  extra-cmake-modules,
  gamemode,
  glib,
  inih,
  jdk17,
  kdePackages,
  libxcb,
  libxkbcommon,
  ninja,
  nspr,
  nss,
  mesa,
  self,
  stripJavaArchivesHook,
  systemd,
  xorg,
  msaClientID ? null,
  gamemodeSupport ? stdenv.hostPlatform.isLinux,
  cefVersion ? "144.0.11+ge135be2+chromium-144.0.7559.97",
  cefDistribution ? "minimal",
  cefHash ?
    if stdenv.hostPlatform.system == "x86_64-linux" then
      "sha256-gdwTnWfOJ7O/9c5uPa2OWvzeD4O0COyzg2qMOy7JknU="
    else if stdenv.hostPlatform.system == "aarch64-linux" then
      "sha256-LTDF9k3184n1b6is+enqfx2Wlz6EC+32/F4s43qpXnA="
    else
      null,
}:
assert lib.assertMsg (
  gamemodeSupport -> stdenv.hostPlatform.isLinux
) "gamemodeSupport is only available on Linux.";

let
  date =
    let
      # YYYYMMDD
      date' = lib.substring 0 8 self.lastModifiedDate;
      year = lib.substring 0 4 date';
      month = lib.substring 4 2 date';
      date = lib.substring 6 2 date';
    in
    if (self ? "lastModifiedDate") then
      lib.concatStringsSep "-" [
        year
        month
        date
      ]
    else
      "unknown";

  cefBinaryPlatform =
    if stdenv.hostPlatform.system == "x86_64-linux" then
      "linux64"
    else if stdenv.hostPlatform.system == "aarch64-linux" then
      "linuxarm64"
    else
      null;

  cefRootDir =
    if cefBinaryPlatform != null then
      "cef_binary_${cefVersion}_${cefBinaryPlatform}_${cefDistribution}"
    else
      null;

  cefBinary =
    if stdenv.hostPlatform.isLinux then
      assert lib.assertMsg (cefBinaryPlatform != null) "No packaged Linux CEF binary platform is configured for ${stdenv.hostPlatform.system}.";
      assert lib.assertMsg (cefHash != null) "No Linux CEF hash is configured for ${stdenv.hostPlatform.system}. Pass `cefHash` when calling `projtlauncher-unwrapped`.";
      fetchzip {
        url = "https://cef-builds.spotifycdn.com/${cefRootDir}.tar.bz2";
        hash = cefHash;
        stripRoot = false;
      }
    else
      null;
in

stdenv.mkDerivation {
  pname = "projtlauncher-unwrapped";
  version = "0.0.5-1-unstable-${date}";

  src = lib.fileset.toSource {
    root = ../..;
    fileset = lib.fileset.unions [
      ../../projt-launcher/CMakeLists.txt
      ../../projt-launcher/CMakePresets.json
      ../../projt-launcher/COPYING.md
      ../../projt-launcher/bootstrap
      ../../projt-launcher/buildconfig
      ../../projt-launcher/ci
      ../../projt-launcher/cmake
      ../../projt-launcher/flatpak
      ../../projt-launcher/fuzz
      ../../projt-launcher/launcher
      ../../projt-launcher/nix
      ../../projt-launcher/program_info
      ../../projt-launcher/scripts
      ../../projt-launcher/tests
      ../../projt-launcher/tools
      ../../bzip2
      ../../cmark
      ../../extra-cmake-modules
      ../../gamemode
      ../../javacheck
      ../../javaloader
      ../../libnbtplusplus
      ../../libpng
      ../../libqrencode
      ../../LocalPeer
      ../../murmur2
      ../../ptlibzippy
      ../../qdcss
      ../../quazip
      ../../rainbow
      ../../systeminfo
      ../../tomlplusplus
    ];
  };

  nativeBuildInputs = [
    cmake
    ninja
    extra-cmake-modules
    jdk17
    stripJavaArchivesHook
  ];

  buildInputs = [
    inih
    kdePackages.qtbase
    kdePackages.qtnetworkauth
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    kdePackages.qtwebchannel
    kdePackages.qtwebengine
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    alsa-lib
    atk
    at-spi2-atk
    cairo
    cups
    dbus
    expat
    glib
    libcap
    libxcb
    libxkbcommon
    mesa
    nspr
    nss
    systemd
    xorg.libX11
    xorg.libXcomposite
    xorg.libXdamage
    xorg.libXext
    xorg.libXfixes
    xorg.libXrandr
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_14 ]
  ++ lib.optional gamemodeSupport gamemode;

  cmakeFlags = [
    # downstream branding
    (lib.cmakeBool "BUILD_TESTING" false)
    (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    (lib.cmakeBool "Launcher_CEF_AUTO_DOWNLOAD" false)
    (lib.cmakeFeature "Launcher_CEF_ROOT" "${cefBinary}/${cefRootDir}")
    (lib.cmakeFeature "GAMEMODE_WITH_SYSTEMD_USER_UNIT_DIR" "lib/systemd/user")
    (lib.cmakeFeature "GAMEMODE_WITH_SYSTEMD_GROUP_DIR" "lib/sysusers.d")
    (lib.cmakeFeature "GAMEMODE_WITH_PAM_LIMITS_DIR" "etc/security/limits.d")
  ]
  ++ lib.optionals (msaClientID != null) [
    (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID))
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # we wrap our binary manually
    (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
    # disable built-in updater
    (lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
    (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
  ];

  doCheck = true;
  preCheck = ''
    export CMAKE_PREFIX_PATH="$PWD/zlib/test/test_install:$CMAKE_PREFIX_PATH"
  '';

  dontWrapQtApps = true;

  sourceRoot = "source/projt-launcher";

  meta = {
    description = "Free, open source launcher for Minecraft";
    longDescription = ''

      Allows you to have multiple, separate instances of Minecraft (each with
      their own mods, texture packs, saves, etc) and helps you manage them and
      their associated options with a simple interface.
    '';
    homepage = "https://projecttick.org/p/projt-launcher/";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [
      yongdohyun
      grxtor
    ];
    mainProgram = "projtlauncher";
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}