From df25f09159727ccc57b721cd0c6580b8005326b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 6 May 2020 12:39:49 +0200 Subject: [PATCH] nix: move yarn2nix setup to nix/deps/nodejs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- .../node-package.nix => deps/nodejs/default.nix} | 9 ++++----- nix/mobile/android/default.nix | 4 ++-- nix/mobile/android/jsbundle/default.nix | 12 ++++++------ nix/mobile/android/maven-and-npm-deps/default.nix | 15 +++++++-------- nix/mobile/default.nix | 6 ++---- nix/overlay.nix | 1 + 6 files changed, 22 insertions(+), 25 deletions(-) rename nix/{mobile/node-package.nix => deps/nodejs/default.nix} (60%) diff --git a/nix/mobile/node-package.nix b/nix/deps/nodejs/default.nix similarity index 60% rename from nix/mobile/node-package.nix rename to nix/deps/nodejs/default.nix index bc933fdba8..026c3a2b27 100644 --- a/nix/mobile/node-package.nix +++ b/nix/deps/nodejs/default.nix @@ -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. diff --git a/nix/mobile/android/default.nix b/nix/mobile/android/default.nix index bf85f0a0ab..bb656f2881 100644 --- a/nix/mobile/android/default.nix +++ b/nix/mobile/android/default.nix @@ -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 { }; diff --git a/nix/mobile/android/jsbundle/default.nix b/nix/mobile/android/jsbundle/default.nix index ac121f50f1..256de8a106 100644 --- a/nix/mobile/android/jsbundle/default.nix +++ b/nix/mobile/android/jsbundle/default.nix @@ -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 ./ diff --git a/nix/mobile/android/maven-and-npm-deps/default.nix b/nix/mobile/android/maven-and-npm-deps/default.nix index 647d51b34d..29f7fe6cf6 100644 --- a/nix/mobile/android/maven-and-npm-deps/default.nix +++ b/nix/mobile/android/maven-and-npm-deps/default.nix @@ -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" ''; }; } diff --git a/nix/mobile/default.nix b/nix/mobile/default.nix index 1760f5d3a7..9e356d16d2 100644 --- a/nix/mobile/default.nix +++ b/nix/mobile/default.nix @@ -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; }; diff --git a/nix/overlay.nix b/nix/overlay.nix index 1551e85d9c..a33c980c3c 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -23,6 +23,7 @@ in { # Project dependencies deps = { clojure = callPackage ./deps/clojure { }; + nodejs = callPackage ./deps/nodejs { }; }; # Android environement