aboutsummaryrefslogtreecommitdiff
path: root/messages/default.nix
diff options
context:
space:
mode:
authorstuebinm2021-02-26 21:25:38 +0100
committerstuebinm2021-02-26 21:27:40 +0100
commitc530245617f9e224b205f6f0efd9fb7f90c0183a (patch)
tree84bace679217d873ec076a1507be0371caf7b638 /messages/default.nix
parentfe9853c5f4e5b029e88c73ed76ea1aaea107cc55 (diff)
parent210a4860ef16f3f00cd5265d238c2a7372a0daa5 (diff)
Move nix files for workadventure into this repo instead of importing them
Since I change things frequently rn and often only very specific commits of both repositories will work together at all, it doesn't seem logical to have them in separate repos any more.
Diffstat (limited to 'messages/default.nix')
-rw-r--r--messages/default.nix70
1 files changed, 70 insertions, 0 deletions
diff --git a/messages/default.nix b/messages/default.nix
new file mode 100644
index 0000000..6deb9f7
--- /dev/null
+++ b/messages/default.nix
@@ -0,0 +1,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/
+ '';
+}