From 4dbc4a60f38e1d1c9b3137c4a09579c7e804b085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 26 Jul 2019 10:51:06 -0400 Subject: [PATCH] use nix shell for nix-update-* targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- Makefile | 4 ---- ci/Jenkinsfile.nix-cache | 12 +++++------- nix/desktop/realm-node/generate-nix.sh | 10 ++++++++++ nix/mobile/android/maven-and-npm-deps/default.nix | 2 +- .../android/maven-and-npm-deps/maven/generate-nix.sh | 7 +++++-- nix/tools/lein/generate-nix.sh | 7 +++++-- scripts/add-nix-gcroots.sh | 7 +++++-- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 5dd409c616ab..0bdb3789b0de 100644 --- a/Makefile +++ b/Makefile @@ -60,19 +60,15 @@ nix-purge: SHELL := /bin/sh nix-purge: ##@nix Completely remove the complete Nix setup sudo rm -rf /nix ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots -nix-add-gcroots: SHELL := /bin/sh nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected scripts/add-nix-gcroots.sh -nix-update-npm: SHELL := /bin/sh nix-update-npm: ##@nix Update node2nix expressions based on current package.json nix/desktop/realm-node/generate-nix.sh -nix-update-gradle: SHELL := /bin/sh nix-update-gradle: ##@nix Update maven nix expressions based on current gradle setup nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh -nix-update-lein: SHELL := /bin/sh nix-update-lein: ##@nix Update maven nix expressions based on current lein setup nix/tools/lein/generate-nix.sh nix/lein diff --git a/ci/Jenkinsfile.nix-cache b/ci/Jenkinsfile.nix-cache index 2e9e4996b291..42d7d92cc608 100644 --- a/ci/Jenkinsfile.nix-cache +++ b/ci/Jenkinsfile.nix-cache @@ -8,6 +8,8 @@ pipeline { NIX_CACHE_USER = 'nix-cache' NIX_CACHE_HOST = 'master-01.do-ams3.ci.misc.statusim.net' NIX_CONF_DIR = "${env.WORKSPACE}/nix" + /* build cache for all platforms */ + TARGET_OS ='all' } options { @@ -39,13 +41,12 @@ pipeline { ['android', 'desktop', 'ios'].each { os -> nix.build( attr: "targets.status-go.${os}.buildInputs", - args: ['target-os': 'all'], link: false ) } } } } - stage('Build jsbundle') { + stage('Build android jsbundle') { steps { script { /* build/fetch things required to produce a js-bundle for android * (e.g. maven and node repos) */ @@ -71,10 +72,8 @@ pipeline { stage('Build nix shell deps') { steps { script { /* build/fetch things required to instantiate shell.nix for TARGET_OS=all */ - nix.shell("nix-build ${args.join(' ')}", pure: false) nix.build( attr: 'shell', - args: ['target-os': 'all'], link: false ) } } @@ -83,9 +82,8 @@ pipeline { steps { script { sshagent(credentials: ['nix-cache-ssh']) { nix.shell(""" - find /nix/store/ -mindepth 1 -maxdepth 1 \ - -not -name '.links' -and -not -name '*.lock' \ - -and -not -name '*-status-react-*' \ + find /nix/store/ -mindepth 1 -maxdepth 1 -type d \ + -not -name '*.links' -and -not -name '*-status-react-*' \ | xargs nix-copy-closure -v --to ${NIX_CACHE_USER}@${NIX_CACHE_HOST} """, pure: false diff --git a/nix/desktop/realm-node/generate-nix.sh b/nix/desktop/realm-node/generate-nix.sh index 13c84021e1a1..ca5282cb5f6e 100755 --- a/nix/desktop/realm-node/generate-nix.sh +++ b/nix/desktop/realm-node/generate-nix.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [[ -z "${IN_NIX_SHELL}" ]]; then + echo "Remember to call 'make shell'!" + exit 1 +fi + # # Run this file to regenerate the Nix files in ./output. # Prerequisites: Node, npm, and node2nix (installed with npm i -g https://github.com/svanderburg/node2nix) @@ -38,6 +43,11 @@ EOF node_required_version=$($toolversion node) node_major_version=$(echo $node_required_version | cut -d. -f1,1) +if ! which node2nix > /dev/null; then + echo "Installing node2nix..." + nix-env -f '' -iA nodePackages.node2nix +fi + node2nix --nodejs-${node_major_version} --bypass-cache \ --input $input \ --output $output_dir/node-packages.nix \ diff --git a/nix/mobile/android/maven-and-npm-deps/default.nix b/nix/mobile/android/maven-and-npm-deps/default.nix index 96af58ad6a33..f1c6f922a654 100644 --- a/nix/mobile/android/maven-and-npm-deps/default.nix +++ b/nix/mobile/android/maven-and-npm-deps/default.nix @@ -31,7 +31,7 @@ let reactNativeDepsDir = "$NIX_BUILD_TOP/deps"; # Use local writable deps, otherwise (probably due to some interaction between Nix sandboxing and Java) gradle will fail copying directly from the nix store in stdenv.mkDerivation { - name = "gradle-install-android-archives-and-patched-npm-modules"; + name = "android-gradle-and-npm-modules"; src = let path = ./../../../..; # Import the root /android and /mobile_files folders clean of any build artifacts in builtins.path { # We use builtins.path so that we can name the resulting derivation, otherwise the name would be taken from the checkout directory, which is outside of our control diff --git a/nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh b/nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh index ada9df974126..ab4cfd56ef0c 100755 --- a/nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh +++ b/nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [[ -z "${IN_NIX_SHELL}" ]]; then + echo "Remember to call 'make shell'!" + exit 1 +fi + # # This script takes care of generating/updating the maven-sources.nix file # representing the offline Maven repo containing the dependencies @@ -8,8 +13,6 @@ set -Eeu -. ~/.nix-profile/etc/profile.d/nix.sh - GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) current_dir=$(cd "${BASH_SOURCE%/*}" && pwd) inputs_file_path="${current_dir}/maven-inputs.txt" diff --git a/nix/tools/lein/generate-nix.sh b/nix/tools/lein/generate-nix.sh index 12355592d362..594738565e3c 100755 --- a/nix/tools/lein/generate-nix.sh +++ b/nix/tools/lein/generate-nix.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [[ -z "${IN_NIX_SHELL}" ]]; then + echo "Remember to call 'make shell'!" + exit 1 +fi + # This script takes care of generating/updating the nix files in the directory passed as a single argument. # For this, we start with a clean cache (in ./.m2~/repository/) and call cljsbuild # to cause it to download all the artifacts. At the same time, we note them @@ -8,8 +13,6 @@ set -Eeuo pipefail -. ~/.nix-profile/etc/profile.d/nix.sh - output_dir=$1 mkdir -p $output_dir diff --git a/scripts/add-nix-gcroots.sh b/scripts/add-nix-gcroots.sh index 0a551f617031..a0840a9a3d48 100755 --- a/scripts/add-nix-gcroots.sh +++ b/scripts/add-nix-gcroots.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash -set -Eeu +if [[ -z "${IN_NIX_SHELL}" ]]; then + echo "Remember to call 'make shell'!" + exit 1 +fi -. ~/.nix-profile/etc/profile.d/nix.sh +set -Eeu GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)