nix: move yarn2nix setup to nix/deps/nodejs

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-05-06 12:39:49 +02:00
parent 381b2462a4
commit df25f09159
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
6 changed files with 22 additions and 25 deletions

View File

@ -1,10 +1,9 @@
{ lib, fetchFromGitHub { lib, yarn2nix-moretea }:
, nodejs, yarn2nix-moretea }:
let let
version = lib.fileContents ../../VERSION; version = lib.fileContents ../../../VERSION;
yarnLock = ../../mobile/js_files/yarn.lock; yarnLock = ../../../mobile/js_files/yarn.lock;
packageJSON = ../../mobile/js_files/package.json; packageJSON = ../../../mobile/js_files/package.json;
packageJSONContent = lib.importJSON packageJSON; packageJSONContent = lib.importJSON packageJSON;
in in
# Create a yarn package for our project that contains all the dependecies. # Create a yarn package for our project that contains all the dependecies.

View File

@ -1,9 +1,9 @@
{ lib, pkgs, newScope, mkShell { lib, pkgs, newScope, mkShell
, status-go, localMavenRepoBuilder, projectNodePackage , status-go, localMavenRepoBuilder
, gradle, androidPkgs, androidShell }: , gradle, androidPkgs, androidShell }:
let let
callPackage = newScope { inherit localMavenRepoBuilder projectNodePackage; }; callPackage = newScope { inherit localMavenRepoBuilder; };
# Import a jsbundle compiled out of clojure codebase # Import a jsbundle compiled out of clojure codebase
jsbundle = callPackage ./jsbundle { }; jsbundle = callPackage ./jsbundle { };

View File

@ -1,10 +1,10 @@
#
# This Nix expression builds the js files for the current repository given a node modules Nix expression # This Nix expression builds the js files for the current repository given a node modules Nix expression
# #
{ target ? "android", { target ? "android"
stdenv, lib, deps, clojure, nodejs, bash, git, openjdk, , stdenv, lib, deps, pkgs
localMavenRepoBuilder, projectNodePackage }: , localMavenRepoBuilder }:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "status-react-build-jsbundle-${target}"; name = "status-react-build-jsbundle-${target}";
@ -33,7 +33,7 @@ stdenv.mkDerivation {
]; ];
}; };
}; };
buildInputs = [ clojure nodejs bash git openjdk]; buildInputs = with pkgs; [ clojure nodejs bash git openjdk];
phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ]; phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ];
# Patching shadow-cljs.edn so it uses the local maven repo of dependencies provided by Nix # Patching shadow-cljs.edn so it uses the local maven repo of dependencies provided by Nix
@ -47,7 +47,7 @@ stdenv.mkDerivation {
''; '';
configurePhase = '' configurePhase = ''
# Symlink Node.js modules to build directory # Symlink Node.js modules to build directory
ln -s ${projectNodePackage}/node_modules ln -s ${deps.nodejs}/node_modules
# Symlink Node.JS dependency definitions # Symlink Node.JS dependency definitions
ln -sf mobile/js_files/package.json ./ ln -sf mobile/js_files/package.json ./

View File

@ -3,9 +3,8 @@
# as well as a local version of the Maven repository required by Gradle scripts # as well as a local version of the Maven repository required by Gradle scripts
# #
{ stdenv, lib, callPackage, mkShell, { stdenv, lib, callPackage, deps, mkShell,
gradle, bash, file, nodejs, zlib, gradle, bash, file, nodejs, zlib, localMavenRepoBuilder }:
projectNodePackage, localMavenRepoBuilder }:
let let
mavenLocalRepo = callPackage ./maven { inherit localMavenRepoBuilder stdenv; }; mavenLocalRepo = callPackage ./maven { inherit localMavenRepoBuilder stdenv; };
@ -20,7 +19,7 @@ let
''; '';
# fake build to pre-download deps into fixed-output derivation # fake build to pre-download deps into fixed-output derivation
deps = drv =
let let
# Place build target directories in NIX_BUILD_TOP (normally represents /build) # Place build target directories in NIX_BUILD_TOP (normally represents /build)
projectBuildDir = "$NIX_BUILD_TOP/project"; projectBuildDir = "$NIX_BUILD_TOP/project";
@ -48,7 +47,7 @@ let
}; };
}; };
phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ]; phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ];
nativeBuildInputs = [ projectNodePackage ]; nativeBuildInputs = [ deps.nodejs ];
buildInputs = [ gradle nodejs bash file zlib mavenLocalRepo ]; buildInputs = [ gradle nodejs bash file zlib mavenLocalRepo ];
propagatedBuildInputs = [ react-native-deps ]; propagatedBuildInputs = [ react-native-deps ];
unpackPhase = '' unpackPhase = ''
@ -71,7 +70,7 @@ let
# Copy node_modules from Nix store # Copy node_modules from Nix store
rm -rf ${projectBuildDir}/node_modules rm -rf ${projectBuildDir}/node_modules
mkdir -p ${projectBuildDir}/node_modules mkdir -p ${projectBuildDir}/node_modules
cp -a ${projectNodePackage}/node_modules/. ${projectBuildDir}/node_modules/ cp -a ${deps.nodejs}/node_modules/. ${projectBuildDir}/node_modules/
# Ensure that module was correctly installed # Ensure that module was correctly installed
[ -d ${projectBuildDir}/node_modules/jsc-android/dist ] || exit 1 [ -d ${projectBuildDir}/node_modules/jsc-android/dist ] || exit 1
@ -189,12 +188,12 @@ let
}; };
in { in {
drv = deps; inherit drv;
shell = mkShell { shell = mkShell {
shellHook = '' shellHook = ''
${createMobileFilesSymlinks "$STATUS_REACT_HOME"} ${createMobileFilesSymlinks "$STATUS_REACT_HOME"}
export STATUSREACT_NIX_MAVEN_REPO="${deps}/.m2/repository" export STATUSREACT_NIX_MAVEN_REPO="${drv}/.m2/repository"
''; '';
}; };
} }

View File

@ -4,19 +4,17 @@
let let
inherit (lib) catAttrs concatStrings optional unique; inherit (lib) catAttrs concatStrings optional unique;
projectNodePackage = callPackage ./node-package.nix { };
localMavenRepoBuilder = callPackage ../tools/maven/maven-repo-builder.nix { }; localMavenRepoBuilder = callPackage ../tools/maven/maven-repo-builder.nix { };
fastlane = callPackage ./fastlane { }; fastlane = callPackage ./fastlane { };
android = callPackage ./android { android = callPackage ./android {
inherit localMavenRepoBuilder projectNodePackage; inherit localMavenRepoBuilder;
status-go = status-go.mobile.android; status-go = status-go.mobile.android;
}; };
ios = callPackage ./ios { ios = callPackage ./ios {
inherit xcodeWrapper projectNodePackage fastlane; inherit xcodeWrapper fastlane;
status-go = status-go.mobile.ios; status-go = status-go.mobile.ios;
}; };

View File

@ -23,6 +23,7 @@ in {
# Project dependencies # Project dependencies
deps = { deps = {
clojure = callPackage ./deps/clojure { }; clojure = callPackage ./deps/clojure { };
nodejs = callPackage ./deps/nodejs { };
}; };
# Android environement # Android environement