diff --git a/ci/Jenkinsfile.nix-cache b/ci/Jenkinsfile.nix-cache index fc37b956f1..b287c7957e 100644 --- a/ci/Jenkinsfile.nix-cache +++ b/ci/Jenkinsfile.nix-cache @@ -32,6 +32,16 @@ pipeline { ''' } } + stage('Build status-go') { + steps { script { + ['android', 'desktop', 'ios'].each { os -> + sh """ + . ~/.nix-profile/etc/profile.d/nix.sh && \ + nix-build --argstr target-os all -A targets.status-go.${os}.buildInputs + """ + } + } } + } stage('Build prod-build-android') { steps { // Run a Nix build to build/fetch everything that is necessary to produce a prod-build for TARGET_OS=android (e.g. maven and node repos) @@ -53,7 +63,7 @@ pipeline { // Run a Nix build to build/fetch everything that is necessary to instantiate shell.nix for TARGET_OS=all sh ''' . ~/.nix-profile/etc/profile.d/nix.sh && \ - nix-shell --pure --show-trace shell.nix + nix-shell --argstr target-os all --pure --show-trace shell.nix ''' } } diff --git a/default.nix b/default.nix index 0fe0939725..4f2258cfef 100644 --- a/default.nix +++ b/default.nix @@ -9,7 +9,7 @@ let deriv = pkgs.callPackage ./nix/derivation.nix { inherit pkgs target-os; inhe in { targets = { - inherit (deriv) mobile leiningen watchman; + inherit (deriv) mobile leiningen watchman status-go; }; inherit (deriv) shell; diff --git a/nix/README.md b/nix/README.md index 003a174009..3c6cd285dd 100644 --- a/nix/README.md +++ b/nix/README.md @@ -6,7 +6,7 @@ This folder contains configuration for [Nix](https://nixos.org/), a purely funct The main config file is [`nix/nix.conf`](/nix/nix.conf) and its main purpose is defining the [binary caches](https://nixos.org/nix/manual/#ch-basic-package-mgmt) which allow download of packages to avoid having to compile them yourself locally. -__NOTE:__ If you are in Asia you might want to move the `nix-cache-cn` to be first in order of `extra-substituters`. Removing `cache.nixos.org` could also help. +__NOTE:__ If you are in Asia you might want to add the `https://nix-cache-cn.status.im/` to be first in order of `substituters`. Removing `cache.nixos.org` could also help. # Shell diff --git a/nix/derivation.nix b/nix/derivation.nix index aa27b6f48e..912476480d 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -44,7 +44,7 @@ let in { # CHILD DERIVATIONS - inherit mobile; + inherit mobile status-go; # TARGETS leiningen = { diff --git a/nix/nix.conf b/nix/nix.conf index 45d26229ae..f6820c0307 100644 --- a/nix/nix.conf +++ b/nix/nix.conf @@ -1,4 +1,4 @@ -# NOTE: If you are in Asia you might want to move the nix-cache-cn to be first in order. -substituters = https://nix-cache.status.im/ https://cache.nixos.org https://nix-cache-cn.status.im/ -trusted-public-keys = nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY= nix-cache-cn.status.im:WUiOoTQQurm+rEL/yuAuU/a3TViDtMM9DCMgMx/KkOw= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= +# NOTE: If you are in Asia you might want to add https://nix-cache-cn.status.im/ to substituters +substituters = https://nix-cache.status.im/ https://cache.nixos.org/ +trusted-public-keys = nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-cache-cn.status.im:WUiOoTQQurm+rEL/yuAuU/a3TViDtMM9DCMgMx/KkOw= connect-timeout = 10 diff --git a/nix/status-go/default.nix b/nix/status-go/default.nix index a5abb33f06..15e40da521 100644 --- a/nix/status-go/default.nix +++ b/nix/status-go/default.nix @@ -12,9 +12,9 @@ let extractStatusGoConfig = callPackage ./extract-status-go-config.nix { inherit (stdenv) lib; }; versionJSON = importJSON ../../status-go-version.json; # TODO: Simplify this path search with lib.locateDominatingFile owner = versionJSON.owner; + repo = versionJSON.repo; version = versionJSON.version; sha256 = versionJSON.src-sha256; - repo = "status-go"; rev = versionJSON.commit-sha1; goPackagePath = "github.com/${owner}/${repo}"; src = fetchFromGitHub { inherit rev owner repo sha256; name = "${repo}-${strings.substring 0 7 rev}-source"; }; diff --git a/scripts/update-status-go.sh b/scripts/update-status-go.sh index 8958c87565..1bf2596c26 100755 --- a/scripts/update-status-go.sh +++ b/scripts/update-status-go.sh @@ -6,7 +6,6 @@ GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) usage() { printf "%s is a tool for upgrading status-go to a given version.\n" "$(basename "$0")" - printf "The given version must be uploaded to Artifactory first.\n\n" printf "Usage:\n\n" printf " %s version\n\n" "$(basename "$0")" printf "Example:\n\n" @@ -23,15 +22,26 @@ if [ $# -eq 0 ]; then exit 1 fi -repoUrl="https://github.com/${STATUS_GO_OWNER:=status-im}/status-go" +STATUS_GO_REPO="${STATUS_GO_REPO:=status-go}" +STATUS_GO_OWNER="${STATUS_GO_OWNER:=status-im}" STATUS_GO_VERSION=$1 -STATUS_GO_SHA256=$(nix-prefetch-url --unpack ${repoUrl}/archive/${STATUS_GO_VERSION}.zip) + +repoUrl="https://github.com/${STATUS_GO_OWNER}/${STATUS_GO_REPO}" + STATUS_GO_COMMIT_SHA1=$(git ls-remote ${repoUrl} U ${STATUS_GO_VERSION} | cut -f1) +if [[ -z "${STATUS_GO_COMMIT_SHA1}" ]]; then + echo "Could not find SHA1 for rev ${STATUS_GO_VERSION}, assuming it's a commit." + STATUS_GO_COMMIT_SHA1="${STATUS_GO_VERSION}" +fi + +STATUS_GO_SHA256=$(nix-prefetch-url --unpack ${repoUrl}/archive/${STATUS_GO_VERSION}.zip) + cat << EOF > ${GIT_ROOT}/status-go-version.json { "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "${STATUS_GO_OWNER}", + "repo": "${STATUS_GO_REPO}", "version": "${STATUS_GO_VERSION}", "commit-sha1": "${STATUS_GO_COMMIT_SHA1}", "src-sha256": "${STATUS_GO_SHA256}" diff --git a/status-go-version.json b/status-go-version.json index c91396415c..3ae6aa70b3 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -1,6 +1,7 @@ { "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", + "repo": "status-go", "version": "v0.30.0-beta.3", "commit-sha1": "9a0502fa8ffe8cb63676212dd6868f3683b2c725", "src-sha256": "1w1x5ws8fr2cjx53y9p3w9kb4ssd2lfljfgv28rksz1jm4pk4dg1"