aboutsummaryrefslogtreecommitdiff
path: root/uploader/default.nix
blob: fa42f121af237685ecad4ee7f2014e13175215b9 (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
{ stdenv
, fetchFromGitHub
, makeWrapper
, mkYarnPackage
, nodejs-14_x
, workadventure
, yarn2nix-moretea
, ... }:

yarn2nix-moretea.mkYarnPackage rec {
  pname = "workadventureuploader";
  version = "unstable";

  src = fetchFromGitHub
    {
      owner = "thecodingmachine";
      repo = "workadventure";
      rev = "6e9c71598004dc9cbab9418efb3c0ac892da7ca2";
      sha256 = "0rvra0dy631al4aylacyqldkyd6biawz2shsikgcy30nv5lzc78c";
    } + "/uploader";

  # NOTE: this is optional and generated dynamically if omitted
  yarnNix = ./yarn.nix;

  nativeBuildInputs = [ makeWrapper ];

  dontStrip = true;

  buildPhase = ''
    mkdir -p $out
    # ln -s ${workadventure.messages.outPath}/generated deps/workadventureback/src/Messages/generated
    HOME=$TMPDIR yarn --offline run tsc
    cp -r deps/workadventureback/dist $out/dist
  '';

  postInstall = ''
    # node-abi needs to the abi of the node here
    makeWrapper '${nodejs-14_x}/bin/node' "$out/bin/${pname}" \
      --set NODE_PATH $out/libexec/workadventureback/node_modules \
      --add-flags "$out/dist/server.js"
  '';
}