summaryrefslogtreecommitdiff
path: root/pkgs/theseus/default.nix
blob: f3ec0acb057ae1cddcb6e33623cab74b246057e8 (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
{
  lib,
  dbus,
  freetype,
  fetchFromGitHub,
  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
  pname = "theseus";

  src = fetchFromGitHub {
    owner = "modrinth";
    repo = "theseus";
    rev = "70aaf6eef983e58f5ac58b3d2f6fe946ea3a3730";
    sha256 = "sha256-6zRhmCtdDT2fQ23alFPQ4xMCsD9pKJ8yF+ww4sAwFAw=";
  };

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

      src = source;

      packageJson = source + "/package.json";
      yarnLock = ./yarn.lock;

      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 = "2023-07-22";

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

    cargoLock = {
      lockFile = "${src}/Cargo.lock";
      outputHashes = {
        "tauri-plugin-single-instance-0.0.0" = "sha256-GkWRIVhiPGds5ocht1K0eetfeDCvyX4wRr1JheO7aik=";
      };
    };

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

    nativeBuildInputs = [
      pkg-config
      wrapGAppsHook
    ];

    preFixup = let
      libPath = lib.makeLibraryPath ([
          flite
          glfw
          libGL
          libpulseaudio
          openal
          stdenv.cc.cc.lib
        ]
        ++ (with xorg; [
          libX11
          libXcursor
          libXext
          libXxf86vm
          libXrandr
        ]));
      binPath = lib.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}
      )
    '';

    meta = with lib; {
      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;
    };
  }