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 <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 {};
-})
+{ system ? builtins.currentSystem, nixpkgs ? <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