From b4bfd52e7c27141890a16f913c7a5873fc5a06ef Mon Sep 17 00:00:00 2001 From: Finn Behrens Date: Thu, 21 Jan 2021 12:03:24 +0100 Subject: create overlay and move everything into workadventure.* --- back/default.nix | 4 ++-- default.nix | 19 ++++++++----------- front/default.nix | 4 ++-- overlay.nix | 14 ++++++++++++++ pusher/default.nix | 4 ++-- uploader/default.nix | 4 ++-- 6 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 overlay.nix diff --git a/back/default.nix b/back/default.nix index 5a5a973..5f92960 100644 --- a/back/default.nix +++ b/back/default.nix @@ -4,7 +4,7 @@ , fetchzip , makeWrapper , nodejs-14_x -, workadventure-messages +, workadventure , yarn2nix-moretea , ... }: @@ -59,7 +59,7 @@ yarn2nix-moretea.mkYarnPackage rec { buildPhase = '' mkdir -p $out - ln -s ${workadventure-messages.outPath}/generated deps/${pname}/src/Messages/generated + ln -s ${workadventure.messages.outPath}/generated deps/${pname}/src/Messages/generated HOME=$TMPDIR yarn --offline run tsc cp -r deps/${pname}/dist $out/dist ''; diff --git a/default.nix b/default.nix index c77e02c..47254a6 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,8 @@ -with import {}; -lib.fix (self: let - callPackage = lib.callPackageWith self; -in pkgs // { - workadventure-back = callPackage ./back {}; - workadventure-pusher = callPackage ./pusher {}; - workadventure-messages = callPackage ./messages {}; - workadventure-front = callPackage ./front {}; - workadventure-uploader = callPackage ./uploader {}; - workadventure-maps = callPackage ./maps {}; -}) +{ system ? builtins.currentSystem, nixpkgs ? }: + +let + pkgs = import nixpkgs { inherit system; overlays = [ (import ./overlay.nix) ]; }; +in { + inherit pkgs; + inherit (pkgs) workadventure; +} diff --git a/front/default.nix b/front/default.nix index 43eb919..e4192aa 100644 --- a/front/default.nix +++ b/front/default.nix @@ -1,7 +1,7 @@ { stdenv , fetchFromGitLab , makeWrapper -, workadventure-messages +, workadventure , yarn2nix-moretea , lib , environment ? {} @@ -49,7 +49,7 @@ in yarn2nix-moretea.mkYarnPackage (rec { buildPhase = '' mkdir -p $out - ln -s ${workadventure-messages.outPath}/generated deps/${pname}/src/Messages/generated + ln -s ${workadventure.messages.outPath}/generated deps/${pname}/src/Messages/generated HOME=$TMPDIR yarn --offline run build cp -r deps/${pname}/dist/ $out/ ''; diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000..0a01748 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,14 @@ +self: super: + +let + inherit (self) callPackage; +in { + workadventure = { + back = callPackage ./back {}; + pusher = callPackage ./pusher {}; + messages = callPackage ./messages {}; + front = callPackage ./front {}; + uploader = callPackage ./uploader {}; + maps = callPackage ./maps {}; + }; +} diff --git a/pusher/default.nix b/pusher/default.nix index a5b84d5..bdace68 100644 --- a/pusher/default.nix +++ b/pusher/default.nix @@ -8,7 +8,7 @@ , nodejs-14_x , yarn2nix-moretea -, workadventure-messages +, workadventure }: let @@ -62,7 +62,7 @@ yarn2nix-moretea.mkYarnPackage rec { buildPhase = '' mkdir -p $out - ln -s ${workadventure-messages.outPath}/generated deps/workadventureback/src/Messages/generated + ln -s ${workadventure.messages.outPath}/generated deps/workadventureback/src/Messages/generated HOME=$TMPDIR yarn --offline run tsc cp -r deps/workadventureback/dist $out/dist ''; diff --git a/uploader/default.nix b/uploader/default.nix index a50683b..25e5f69 100644 --- a/uploader/default.nix +++ b/uploader/default.nix @@ -3,7 +3,7 @@ , makeWrapper , mkYarnPackage , nodejs-14_x -, workadventure-messages +, workadventure , yarn2nix-moretea , ... }: @@ -28,7 +28,7 @@ yarn2nix-moretea.mkYarnPackage rec { buildPhase = '' mkdir -p $out - # ln -s ${workadventure-messages.outPath}/generated deps/workadventureback/src/Messages/generated + # ln -s ${workadventure.messages.outPath}/generated deps/workadventureback/src/Messages/generated HOME=$TMPDIR yarn --offline run tsc cp -r deps/workadventureback/dist $out/dist ''; -- cgit v1.2.3 From e5859bb3258351c19540eedd6a8d1dff14af1295 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Sun, 24 Jan 2021 17:34:30 +0100 Subject: back,pusher: reduce final derivation size While this still is a major hack, this reduces unused node_modules (about 200MB each) being pulled in from workadventure*-modules-* and workadventure-messages. --- back/default.nix | 1 + pusher/default.nix | 3 +++ 2 files changed, 4 insertions(+) diff --git a/back/default.nix b/back/default.nix index 5f92960..06325c7 100644 --- a/back/default.nix +++ b/back/default.nix @@ -62,6 +62,7 @@ yarn2nix-moretea.mkYarnPackage rec { ln -s ${workadventure.messages.outPath}/generated deps/${pname}/src/Messages/generated HOME=$TMPDIR yarn --offline run tsc cp -r deps/${pname}/dist $out/dist + rm -rf deps/${pname}/{src,node_modules} ''; postInstall = '' diff --git a/pusher/default.nix b/pusher/default.nix index bdace68..44c4c68 100644 --- a/pusher/default.nix +++ b/pusher/default.nix @@ -60,11 +60,14 @@ yarn2nix-moretea.mkYarnPackage rec { dontStrip = true; + # workadventureback below is a package name extracted from package.json, + # intended until upstream fixes that up. 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 + rm -rf deps/workadventureback/{src,node_modules} ''; postInstall = '' -- cgit v1.2.3 From 2d7380043979b6bc8e05cecda9d6277e1553777f Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Sun, 24 Jan 2021 17:37:03 +0100 Subject: back,pusher: fix node-pre-gyp libc detection This should fix libc detection carried out in https://github.com/lovell/detect-libc/blob/5173db0bc47608f89986d9125c2d868c08d5f429/lib/detect-libc.js#L44 when loading grpc bindings. --- back/default.nix | 5 +++++ pusher/default.nix | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/back/default.nix b/back/default.nix index 06325c7..a7e0858 100644 --- a/back/default.nix +++ b/back/default.nix @@ -6,6 +6,8 @@ , nodejs-14_x , workadventure , yarn2nix-moretea +, lib +, getconf , ... }: let @@ -67,8 +69,11 @@ yarn2nix-moretea.mkYarnPackage rec { postInstall = '' # node-abi needs to the abi of the node here + # getconf is required for detect-libc (used by node-pre-gyp) to properly + # detect current libc makeWrapper '${nodejs-14_x}/bin/node' "$out/bin/${pname}" \ --set NODE_PATH $out/libexec/${pname}/node_modules \ + --prefix PATH : ${lib.makeBinPath [ getconf ]} \ --add-flags "$out/dist/server.js" ''; } diff --git a/pusher/default.nix b/pusher/default.nix index 44c4c68..1c41765 100644 --- a/pusher/default.nix +++ b/pusher/default.nix @@ -1,6 +1,8 @@ { stdenv , autoPatchelfHook , makeWrapper +, lib +, getconf , fetchzip , fetchFromGitHub @@ -72,8 +74,11 @@ yarn2nix-moretea.mkYarnPackage rec { postInstall = '' # node-abi needs to the abi of the node here + # getconf is required for detect-libc (used by node-pre-gyp) to properly + # detect current libc makeWrapper '${nodejs-14_x}/bin/node' "$out/bin/${pname}" \ --set NODE_PATH $out/libexec/workadventureback/node_modules \ + --prefix PATH : ${lib.makeBinPath [ getconf ]} \ --add-flags "$out/dist/server.js" ''; } -- cgit v1.2.3