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
, nodejs, yarn2nix-moretea }:
{ lib, yarn2nix-moretea }:
let
version = lib.fileContents ../../VERSION;
yarnLock = ../../mobile/js_files/yarn.lock;
packageJSON = ../../mobile/js_files/package.json;
version = lib.fileContents ../../../VERSION;
yarnLock = ../../../mobile/js_files/yarn.lock;
packageJSON = ../../../mobile/js_files/package.json;
packageJSONContent = lib.importJSON packageJSON;
in
# Create a yarn package for our project that contains all the dependecies.

View File

@ -1,9 +1,9 @@
{ lib, pkgs, newScope, mkShell
, status-go, localMavenRepoBuilder, projectNodePackage
, status-go, localMavenRepoBuilder
, gradle, androidPkgs, androidShell }:
let
callPackage = newScope { inherit localMavenRepoBuilder projectNodePackage; };
callPackage = newScope { inherit localMavenRepoBuilder; };
# Import a jsbundle compiled out of clojure codebase
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
#
{ target ? "android",
stdenv, lib, deps, clojure, nodejs, bash, git, openjdk,
localMavenRepoBuilder, projectNodePackage }:
{ target ? "android"
, stdenv, lib, deps, pkgs
, localMavenRepoBuilder }:
stdenv.mkDerivation {
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" ];
# Patching shadow-cljs.edn so it uses the local maven repo of dependencies provided by Nix
@ -47,7 +47,7 @@ stdenv.mkDerivation {
'';
configurePhase = ''
# Symlink Node.js modules to build directory
ln -s ${projectNodePackage}/node_modules
ln -s ${deps.nodejs}/node_modules
# Symlink Node.JS dependency definitions
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
#
{ stdenv, lib, callPackage, mkShell,
gradle, bash, file, nodejs, zlib,
projectNodePackage, localMavenRepoBuilder }:
{ stdenv, lib, callPackage, deps, mkShell,
gradle, bash, file, nodejs, zlib, localMavenRepoBuilder }:
let
mavenLocalRepo = callPackage ./maven { inherit localMavenRepoBuilder stdenv; };
@ -20,7 +19,7 @@ let
'';
# fake build to pre-download deps into fixed-output derivation
deps =
drv =
let
# Place build target directories in NIX_BUILD_TOP (normally represents /build)
projectBuildDir = "$NIX_BUILD_TOP/project";
@ -48,7 +47,7 @@ let
};
};
phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ];
nativeBuildInputs = [ projectNodePackage ];
nativeBuildInputs = [ deps.nodejs ];
buildInputs = [ gradle nodejs bash file zlib mavenLocalRepo ];
propagatedBuildInputs = [ react-native-deps ];
unpackPhase = ''
@ -71,7 +70,7 @@ let
# Copy node_modules from Nix store
rm -rf ${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
[ -d ${projectBuildDir}/node_modules/jsc-android/dist ] || exit 1
@ -189,12 +188,12 @@ let
};
in {
drv = deps;
inherit drv;
shell = mkShell {
shellHook = ''
${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
inherit (lib) catAttrs concatStrings optional unique;
projectNodePackage = callPackage ./node-package.nix { };
localMavenRepoBuilder = callPackage ../tools/maven/maven-repo-builder.nix { };
fastlane = callPackage ./fastlane { };
android = callPackage ./android {
inherit localMavenRepoBuilder projectNodePackage;
inherit localMavenRepoBuilder;
status-go = status-go.mobile.android;
};
ios = callPackage ./ios {
inherit xcodeWrapper projectNodePackage fastlane;
inherit xcodeWrapper fastlane;
status-go = status-go.mobile.ios;
};

View File

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