summaryrefslogtreecommitdiff
path: root/pkgs/theseus.nix
blob: 3b1585b998582909169349aa3545ecb924e10dbe (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
{
  lib,
  dbus,
  freetype,
  fetchFromGitHub,
  fetchYarnDeps,
  flite,
  glfw,
  glib-networking,
  gtk3,
  jdk8,
  jdk17,
  jdks ? [jdk8 jdk17],
  libappindicator-gtk3,
  libGL,
  libpulseaudio,
  librsvg,
  libsoup,
  mkYarnPackage,
  openal,
  openssl,
  pkg-config,
  rustPlatform,
  stdenv,
  webkitgtk,
  wrapGAppsHook,
  xorg,
  ...
}: let
  inherit (lib) licenses maintainers makeBinPath makeLibraryPath platforms;
  pname = "theseus";

  rev = "9ea548cfe332c56179c9ef4fad58ac7274bcbd13";
  src = fetchFromGitHub {
    owner = "modrinth";
    repo = "theseus";
    inherit rev;
    sha256 = "sha256-OBczvGVCvrkZjZS1HIYQ41gxqznSC0dOb1nYK0RU8JQ=";
  };

  theseus-frontend = let
    source = src + "/theseus_gui";
  in
    mkYarnPackage {
      pname = "${pname}-frontend";

      src = source;

      offlineCache = fetchYarnDeps {
        yarnLock = source + "/yarn.lock";
        sha256 = "sha256-UFPILd1f4kp0VTPlBccp36kTpsHUrcsxkfHMCtaDX3Y=";
      };

      packageJson = source + "/package.json";

      buildPhase = ''
        export HOME=$(mktemp -d)
        yarn --offline run build
        cp -r deps/theseus_gui/dist $out
      '';

      distPhase = "true";
      dontInstall = true;
    };
in
  rustPlatform.buildRustPackage {
    inherit pname src;
    version = builtins.substring 0 7 rev;

    postPatch = ''
      substituteInPlace theseus_gui/src-tauri/tauri.conf.json \
        --replace '"distDir": "../dist",' '"distDir": "${theseus-frontend}",'
    '';

    cargoSha256 = "sha256-xleTO3AEW3yfkfJY2XjJt8g1WotdaB3tW6u/naxDszE=";

    buildInputs = [
      dbus
      freetype
      gtk3
      libappindicator-gtk3
      librsvg
      libsoup
      openssl
      webkitgtk
      wrapGAppsHook
    ];

    nativeBuildInputs = [pkg-config];

    preFixup = let
      libPath = makeLibraryPath ([
          flite
          glfw
          libGL
          libpulseaudio
          openal
          stdenv.cc.cc.lib
        ]
        ++ (with xorg; [
          libX11
          libXcursor
          libXext
          libXxf86vm
          libXrandr
        ]));
      binPath = makeBinPath ([xorg.xrandr] ++ jdks);
    in ''
      gappsWrapperArgs+=(
        --set LD_LIBRARY_PATH /run/opengl-driver/lib:${libPath}
       	--prefix GIO_MODULE_DIR : ${glib-networking}/lib/gio/modules/
        --prefix PATH : ${binPath}
      )

      runHook postInstall
    '';

    meta = {
      description = "Modrinth's future game launcher";
      longDescription = ''
        Modrinth's future game launcher which can be used as a CLI, GUI, and a library for creating and playing Modrinth projects.
      '';
      homepage = "https://modrinth.com";
      license = licenses.gpl3Plus;
      maintainers = [maintainers.getchoo];
      platforms = with platforms; linux ++ darwin;
    };
  }