aboutsummaryrefslogtreecommitdiff
path: root/messages/default.nix
blob: 6deb9f75b4a5a1aa0a0bc78bb5cb3090eabab076 (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
{ stdenv
, autoPatchelfHook
, fetchFromGitHub
, fetchzip
, gcc-unwrapped
, yarn2nix-moretea
, ... }:

let
  node-protoc-precompiled = fetchzip {
    name = "node-protoc-precompiled";
    url = "https://node-precompiled-binaries.grpc.io/grpc-tools/v1.10.0/linux-x64.tar.gz";
    sha256 = "0dl1anpw3610q58mxf7r9dcp768krwvpa4053cjxn5r8b5xfbh4l";
  };

  node-protoc-patched = stdenv.mkDerivation {
    name = "node-protoc";
    buildInputs = [ gcc-unwrapped.lib ];
    nativeBuildInputs = [ autoPatchelfHook ];
    dontAutoPatchelf = true;
    dontUnpack = true;
    # protoc: symbol lookup error: /nix/store/...-node-protoc/bin/protoc: undefined symbol: , version
    dontStrip = true;
    installPhase = ''
      install -D -m755 ${node-protoc-precompiled}/grpc_node_plugin $out/bin/grpc_node_plugin
      install -D -m755 ${node-protoc-precompiled}/protoc $out/bin/protoc

      autoPatchelf $out/bin/{grpc_node_plugin,protoc}
      :
    '';
  };

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

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

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

  pkgConfig = {
    grpc-tools = {
      postInstall = ''
        install -D -m755 ${node-protoc-patched}/bin/grpc_node_plugin bin/grpc_node_plugin
        install -D -m755 ${node-protoc-patched}/bin/protoc bin/protoc
      '';
    };
  };

  dontStrip = true;

  buildPhase = ''
    mkdir -p $out
    HOME=$TMPDIR yarn --offline run proto
  '';

  distPhase = ":";

  installPhase = ''
    cp -r deps/workadventure-messages/generated $out/
    cp -r node_modules $out/
  '';
}