aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--back/default.nix10
-rw-r--r--front/default.nix4
-rw-r--r--overlay.nix14
-rw-r--r--pusher/default.nix12
-rw-r--r--test.nix21
-rw-r--r--uploader/default.nix4
6 files changed, 43 insertions, 22 deletions
diff --git a/back/default.nix b/back/default.nix
index 5a5a973..a7e0858 100644
--- a/back/default.nix
+++ b/back/default.nix
@@ -4,8 +4,10 @@
, fetchzip
, makeWrapper
, nodejs-14_x
-, workadventure-messages
+, workadventure
, yarn2nix-moretea
+, lib
+, getconf
, ... }:
let
@@ -59,15 +61,19 @@ 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
+ rm -rf deps/${pname}/{src,node_modules}
'';
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/front/default.nix b/front/default.nix
index 5385de3..adfbab2 100644
--- a/front/default.nix
+++ b/front/default.nix
@@ -1,7 +1,7 @@
{ stdenv
, fetchFromGitLab
, makeWrapper
-, workadventure-messages
+, workadventure
, yarn2nix-moretea
, lib
, replace
@@ -91,7 +91,7 @@ in
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..1c41765 100644
--- a/pusher/default.nix
+++ b/pusher/default.nix
@@ -1,6 +1,8 @@
{ stdenv
, autoPatchelfHook
, makeWrapper
+, lib
+, getconf
, fetchzip
, fetchFromGitHub
@@ -8,7 +10,7 @@
, nodejs-14_x
, yarn2nix-moretea
-, workadventure-messages
+, workadventure
}:
let
@@ -60,17 +62,23 @@ 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
+ 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 = ''
# 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"
'';
}
diff --git a/test.nix b/test.nix
index 3df16d6..c4d2f56 100644
--- a/test.nix
+++ b/test.nix
@@ -1,16 +1,9 @@
-# NOTE: this file is only meant to be used for quickly building a
-# version of workadventure, not for actual use. Use callPackages on
-# the subdirectories directly for use e.g. in modules.
-with import <nixpkgs> {};
+{ system ? builtins.currentSystem, nixpkgs ? <nixpkgs> }:
-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 {};
-})
+let
+ pkgs = import nixpkgs { inherit system; overlays = [ (import ./overlay.nix) ]; };
+in {
+ inherit pkgs;
+ inherit (pkgs) workadventure;
+}
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
'';