diff --git a/STATUS_GO_OWNER b/STATUS_GO_OWNER deleted file mode 100644 index 345973aeee8e..000000000000 --- a/STATUS_GO_OWNER +++ /dev/null @@ -1 +0,0 @@ -status-im diff --git a/STATUS_GO_SHA256 b/STATUS_GO_SHA256 deleted file mode 100644 index ba47287ee374..000000000000 --- a/STATUS_GO_SHA256 +++ /dev/null @@ -1,3 +0,0 @@ -## DO NOT EDIT THIS FILE BY HAND. USE `scripts/update-status-go.sh ` instead - -1nm0b1nbz4ly2fx6n2pybrfa1m9x0zzj7kkkqf7fwjxg6hjnp6y5 diff --git a/STATUS_GO_VERSION b/STATUS_GO_VERSION index 628318871c7a..67386edb4ae6 100644 --- a/STATUS_GO_VERSION +++ b/STATUS_GO_VERSION @@ -1,3 +1,6 @@ ## DO NOT EDIT THIS FILE BY HAND. USE `scripts/update-status-go.sh ` instead -v0.30.0-beta.0 +owner=status-im +version=v0.30.0-beta.0 +commit-sha1=f2139105bfa9a82ff4f8cb2ec6b98c2149964a71 +src-sha256=1nm0b1nbz4ly2fx6n2pybrfa1m9x0zzj7kkkqf7fwjxg6hjnp6y5 diff --git a/ci/Jenkinsfile.nix-cache b/ci/Jenkinsfile.nix-cache index b4c39fe8a471..fc37b956f1e5 100644 --- a/ci/Jenkinsfile.nix-cache +++ b/ci/Jenkinsfile.nix-cache @@ -53,7 +53,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-build --pure --no-out-link --show-trace -A shell default.nix + nix-shell --pure --show-trace shell.nix ''' } } diff --git a/modules/react-native-status/android/build.gradle b/modules/react-native-status/android/build.gradle index 8289d6fe325a..f842e6cdf14d 100644 --- a/modules/react-native-status/android/build.gradle +++ b/modules/react-native-status/android/build.gradle @@ -1,8 +1,9 @@ apply plugin: 'com.android.library' def getStatusGoVersion = { -> - version = new File('../STATUS_GO_VERSION').text - return version.tokenize('\n').last().replaceAll("\\s","") + def lines = new File('../STATUS_GO_VERSION').text.tokenize('\n') + def versionLine = lines.find { line -> line.startsWith("version=") } + return versionLine.tokenize('=').last() } android { diff --git a/modules/react-native-status/desktop/CMakeLists.txt b/modules/react-native-status/desktop/CMakeLists.txt index 40a4cd6370c9..5ef8e8a103ba 100755 --- a/modules/react-native-status/desktop/CMakeLists.txt +++ b/modules/react-native-status/desktop/CMakeLists.txt @@ -16,16 +16,30 @@ if (WIN32) find_package(Go REQUIRED) - file(STRINGS "../../../STATUS_GO_OWNER" STATUS_GO_OWNER) file(STRINGS "../../../STATUS_GO_VERSION" STATUS_GO_VERSION) - list(GET STATUS_GO_VERSION -1 STATUS_GO_VERSION) + if(STATUS_GO_VERSION MATCHES ";owner=([^;]+).*") + set(owner ${CMAKE_MATCH_1}) + else() + set(owner "status-im") + message(WARNING "Repository owner name missing from STATUS_GO_VERSION, defaulting to ${owner}") + endif() + if(STATUS_GO_VERSION MATCHES ";version=([^;]+).*") + set(version ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Version name missing from STATUS_GO_VERSION") + endif() + if(STATUS_GO_VERSION MATCHES ";commit-sha1=([^;]+).*") + set(commit ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Commit SHA1 missing from STATUS_GO_VERSION") + endif() if (CUSTOM_STATUSGO_BUILD_DIR_PATH) set(StatusGo_ROOT ${CUSTOM_STATUSGO_BUILD_DIR_PATH}) else() set(StatusGo_ROOT "${CMAKE_CURRENT_BINARY_DIR}/StatusGo") endif() - set(StatusGo_PREFIX "${StatusGo_ROOT}/src/github.com/${STATUS_GO_OWNER}") + set(StatusGo_PREFIX "${StatusGo_ROOT}/src/github.com/${owner}") set(StatusGo_SOURCE_DIR "${StatusGo_PREFIX}/status-go") set(StatusGo_INCLUDE_DIR "${StatusGo_SOURCE_DIR}/build/bin") set(StatusGo_STATIC_LIB @@ -38,8 +52,8 @@ if (WIN32) ExternalProject_Add(StatusGo_ep PREFIX ${StatusGo_PREFIX} SOURCE_DIR ${StatusGo_SOURCE_DIR} - URL https://status-go.ams3.digitaloceanspaces.com/status-go-desktop-${STATUS_GO_VERSION}.zip - https://github.com/${STATUS_GO_OWNER}/status-go/archive/${STATUS_GO_VERSION}.zip + URL https://status-go.ams3.digitaloceanspaces.com/status-go-desktop-${version}.zip + https://github.com/${owner}/status-go/archive/${commit}.zip BUILD_BYPRODUCTS ${StatusGo_STATIC_LIB} CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIGURE_SCRIPT} ${CMAKE_SYSTEM_NAME} ${GO_ROOT_PATH} ${StatusGo_ROOT} ${StatusGo_SOURCE_DIR} ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER} BUILD_COMMAND "" diff --git a/nix/bootstrapped-shell.nix b/nix/bootstrapped-shell.nix index 217bda1348da..cc6cd8db7495 100644 --- a/nix/bootstrapped-shell.nix +++ b/nix/bootstrapped-shell.nix @@ -3,12 +3,13 @@ # as well as define STATUS_REACT_HOME # -{ stdenv, mkShell, git }: +{ stdenv, mkShell, target-os, git }: let shell' = shellAttr: shellAttr // { nativeBuildInputs = (shellAttr.nativeBuildInputs or []) ++ [ git ]; + TARGET_OS = target-os; shellHook = '' set -e diff --git a/nix/derivation.nix b/nix/derivation.nix index b838bcee3a84..aa27b6f48eff 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -10,14 +10,14 @@ let platform = pkgs.callPackage ./platform.nix { inherit target-os; }; # Declare a specialized mkShell function which adds some bootstrapping # so that e.g. STATUS_REACT_HOME is automatically available in the shell - mkShell = (import ./bootstrapped-shell.nix { inherit stdenv; inherit (pkgs) mkShell git; }); + mkShell = (import ./bootstrapped-shell.nix { inherit stdenv target-os; inherit (pkgs) mkShell git; }); # TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib) stdenv = pkgs.stdenvNoCC; maven = pkgs.maven; baseGo = pkgs.go_1_11; go = pkgs.callPackage ./patched-go { inherit baseGo; }; buildGoPackage = pkgs.buildGoPackage.override { inherit go; }; - desktop = pkgs.callPackage ./desktop { inherit target-os stdenv status-go pkgs nodejs; inherit (pkgs) darwin; go = baseGo; }; + desktop = pkgs.callPackage ./desktop { inherit target-os stdenv status-go pkgs go nodejs; inherit (pkgs) darwin; }; mobile = pkgs.callPackage ./mobile { inherit target-os config stdenv pkgs mkShell nodejs yarn status-go maven localMavenRepoBuilder mkFilter prod-build-fn; inherit (pkgs.xcodeenv) composeXcodeWrapper; }; status-go = pkgs.callPackage ./status-go { inherit target-os go buildGoPackage; inherit (mobile.ios) xcodeWrapper; androidPkgs = mobile.android.androidComposition; }; # mkFilter is a function that allows filtering a directory structure (used for filtering source files being captured in a closure) diff --git a/nix/desktop/linux/appimagekit/default.nix b/nix/desktop/linux/appimagekit/default.nix index c5f3843868fd..2ef49e5b231d 100644 --- a/nix/desktop/linux/appimagekit/default.nix +++ b/nix/desktop/linux/appimagekit/default.nix @@ -7,18 +7,19 @@ }: let + owner = "AppImage"; + repo = "AppImageKit"; + rev = "b0859501df61cde198b54a317c03b41dbafc98b1"; + sha256 = "0qqg79jw9w9rs8c2w3lla4kz62ihafrf7jm370pp1dl8y2i81jzg"; appimagekit_src = fetchFromGitHub { - name = "AppImageKit-source"; - owner = "AppImage"; - repo = "AppImageKit"; - rev = "b0859501df61cde198b54a317c03b41dbafc98b1"; - sha256 = "0qqg79jw9w9rs8c2w3lla4kz62ihafrf7jm370pp1dl8y2i81jzg"; + name = "${repo}-${stdenv.lib.strings.substring 0 7 rev}-source"; + inherit owner repo rev sha256; }; # squashfuse adapted to nix from cmake experession in "${appimagekit_src}/cmake/dependencies.cmake" appimagekit_squashfuse = squashfuse.overrideAttrs (attrs: rec { - name = "squashfuse-${version}"; + pname = "squashfuse"; version = "20161009"; src = fetchFromGitHub { @@ -60,7 +61,8 @@ let }); in stdenv.mkDerivation rec { - name = "appimagekit-20180727"; + pname = "appimagekit"; + version = "20180727"; src = appimagekit_src; diff --git a/nix/desktop/linux/linuxdeployqt/default.nix b/nix/desktop/linux/linuxdeployqt/default.nix index 52b96bf58436..ea7caead361a 100644 --- a/nix/desktop/linux/linuxdeployqt/default.nix +++ b/nix/desktop/linux/linuxdeployqt/default.nix @@ -3,17 +3,18 @@ with pkgs; stdenv.mkDerivation rec { - name = "linuxdeployqt"; + pname = "linuxdeployqt"; version = "20181215"; + owner = "probonopd"; + repo = "linuxdeployqt"; + rev = "600fc20ea73ee937a402a2bb6b3663d93fcc1d4b"; + sha256 = "05kvkfbhsyadlcggl63rhrw5s36d8qxs8gyihrjn2cjk42xx8r7j"; src = if stdenv.hostPlatform.system == "x86_64-linux" then fetchFromGitHub { - name = "${name}-source"; - owner = "probonopd"; - repo = "linuxdeployqt"; - rev = "600fc20ea73ee937a402a2bb6b3663d93fcc1d4b"; - sha256 = "05kvkfbhsyadlcggl63rhrw5s36d8qxs8gyihrjn2cjk42xx8r7j"; + name = "${repo}-${stdenv.lib.strings.substring 0 7 rev}-source"; + inherit owner repo rev sha256; } else throw "${name} is not supported on ${stdenv.hostPlatform.system}"; diff --git a/nix/desktop/macos/base-image/default.nix b/nix/desktop/macos/base-image/default.nix index 0ad280029b38..02fca6385abd 100644 --- a/nix/desktop/macos/base-image/default.nix +++ b/nix/desktop/macos/base-image/default.nix @@ -2,7 +2,7 @@ let package = stdenv.mkDerivation rec { - name = "StatusImAppBundle"; + pname = "StatusImAppBundle"; version = "20190515"; src = @@ -11,7 +11,7 @@ let url = "https://desktop-app-files.ams3.digitaloceanspaces.com/Status_${version}.app.zip"; sha256 = "1255jgdp0apqh7qfp752nww91iq39x5mm7rf0wazq2vjahfr4pc5"; } - else throw "${name} is not supported on ${stdenv.hostPlatform.system}"; + else throw "${pname} is not supported on ${stdenv.hostPlatform.system}"; nativeBuildInputs = [ unzip ]; diff --git a/nix/status-go/build-status-go.nix b/nix/status-go/build-status-go.nix index 8ef106f1ffb8..505bd23c81a5 100644 --- a/nix/status-go/build-status-go.nix +++ b/nix/status-go/build-status-go.nix @@ -11,12 +11,15 @@ with stdenv; let + inherit (stdenv.lib) strings; + removeReferences = [ go ]; removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; args = removeAttrs args' [ "buildMessage" ]; # Remove our arguments from args before passing them on to buildGoPackage buildStatusGo = buildGoPackage (args // { - name = "${repo}-${version}-${host}"; + pname = repo; + version = "${version}-${strings.substring 0 7 rev}-${host}"; nativeBuildInputs = nativeBuildInputs ++ @@ -75,6 +78,10 @@ let return ''; + passthru = { + inherit owner version rev; + }; + meta = { # Add default meta information inherit (meta) platforms; diff --git a/nix/status-go/default.nix b/nix/status-go/default.nix index dca0067e8902..38e4ee1653ea 100644 --- a/nix/status-go/default.nix +++ b/nix/status-go/default.nix @@ -3,20 +3,20 @@ androidPkgs, xcodeWrapper }: let - inherit (stdenv.lib) catAttrs concatStrings fileContents last makeBinPath optional optionalString splitString; + inherit (stdenv.lib) catAttrs concatStrings fileContents makeBinPath optional optionalString strings; platform = callPackage ../platform.nix { inherit target-os; }; utils = callPackage ../utils.nix { inherit xcodeWrapper; }; gomobile = callPackage ./gomobile { inherit (androidPkgs) platform-tools; inherit target-os xcodeWrapper utils buildGoPackage; }; buildStatusGoDesktopLib = callPackage ./build-desktop-status-go.nix { inherit buildGoPackage go xcodeWrapper utils; }; buildStatusGoMobileLib = callPackage ./build-mobile-status-go.nix { inherit buildGoPackage go gomobile xcodeWrapper utils; }; - extractStatusGoConfig = f: last (splitString "\n" (fileContents f)); - owner = fileContents ../../STATUS_GO_OWNER; - version = extractStatusGoConfig ../../STATUS_GO_VERSION; # TODO: Simplify this path search with lib.locateDominatingFile - sha256 = extractStatusGoConfig ../../STATUS_GO_SHA256; + extractStatusGoConfig = callPackage ./extract-status-go-config.nix { inherit (stdenv) lib; }; + owner = extractStatusGoConfig "owner"; + version = extractStatusGoConfig "version"; + sha256 = extractStatusGoConfig "src-sha256"; repo = "status-go"; - rev = version; + rev = extractStatusGoConfig "commit-sha1"; goPackagePath = "github.com/${owner}/${repo}"; - src = fetchFromGitHub { inherit rev owner repo sha256; name = "${repo}-source"; }; + src = fetchFromGitHub { inherit rev owner repo sha256; name = "${repo}-${strings.substring 0 7 rev}-source"; }; mobileConfigs = { android = { diff --git a/nix/status-go/extract-status-go-config.nix b/nix/status-go/extract-status-go-config.nix new file mode 100644 index 000000000000..112d86425095 --- /dev/null +++ b/nix/status-go/extract-status-go-config.nix @@ -0,0 +1,20 @@ +# +# This nix expression contains logic to extract the value of a field in the STATUS_GO_VERSION file, when given the field name +# + +{ lib }: + +let + inherit (lib) fileContents findFirst head splitString; + content = fileContents ../../STATUS_GO_VERSION; # TODO: Simplify this path search with lib.locateDominatingFile + extractStatusGoConfig = + fieldName: + let lines = splitString "\n" content; + # Find the first line containing the field name + matchedLine = findFirst (line: (builtins.match "${fieldName}=.+" line) != null) null lines; + in if matchedLine != null + # If line is found, extract the field value + then head (builtins.match "${fieldName}=(.+)" matchedLine) + else throw "Could not find '${fieldName}' in ${content}"; + +in extractStatusGoConfig \ No newline at end of file diff --git a/nix/status-go/gomobile/default.nix b/nix/status-go/gomobile/default.nix index 0575aea3290c..2a1537131ae8 100644 --- a/nix/status-go/gomobile/default.nix +++ b/nix/status-go/gomobile/default.nix @@ -10,7 +10,7 @@ let platform = callPackage ../../platform.nix { inherit target-os; }; in buildGoPackage rec { - name = "gomobile-${version}"; + pname = "gomobile"; version = "20190319-${strings.substring 0 7 rev}"; rev = "167ebed0ec6dd457a6b24a4f61db913f0af11f70"; sha256 = "0lspdhikhnhbwv8v0q6fs3a0pd9sjnhkpg8z03m2dc5h6f84m38w"; diff --git a/scripts/update-status-go.sh b/scripts/update-status-go.sh index e25112e841f0..376300d5d148 100755 --- a/scripts/update-status-go.sh +++ b/scripts/update-status-go.sh @@ -23,18 +23,20 @@ if [ $# -eq 0 ]; then exit 1 fi -STATUS_GO_OWNER="$(cat ${GIT_ROOT}/STATUS_GO_OWNER)" +repoUrl="https://github.com/${STATUS_GO_OWNER:=status-im}/status-go" STATUS_GO_VERSION=$1 -STATUS_GO_SHA256=$(nix-prefetch-url --unpack https://github.com/${STATUS_GO_OWNER}/status-go/archive/${STATUS_GO_VERSION}.zip) - +STATUS_GO_SHA256=$(nix-prefetch-url --unpack ${repoUrl}/archive/${STATUS_GO_VERSION}.zip) +STATUS_GO_COMMIT_SHA1=$(git ls-remote ${repoUrl} U ${STATUS_GO_VERSION} | cut -f1) cat << EOF > ${GIT_ROOT}/STATUS_GO_VERSION ## DO NOT EDIT THIS FILE BY HAND. USE \`scripts/update-status-go.sh \` instead -$STATUS_GO_VERSION +owner=${STATUS_GO_OWNER} +version=${STATUS_GO_VERSION} +commit-sha1=${STATUS_GO_COMMIT_SHA1} +src-sha256=${STATUS_GO_SHA256} EOF -cat << EOF > ${GIT_ROOT}/STATUS_GO_SHA256 -## DO NOT EDIT THIS FILE BY HAND. USE \`scripts/update-status-go.sh \` instead -$STATUS_GO_SHA256 -EOF +echo "SHA-1 for ${STATUS_GO_VERSION} is ${STATUS_GO_COMMIT_SHA1}. +SHA-256 for source archive is ${STATUS_GO_SHA256} +Owner is ${STATUS_GO_OWNER}" diff --git a/shell.nix b/shell.nix index e17e09bb4b83..ba262656d19d 100644 --- a/shell.nix +++ b/shell.nix @@ -4,7 +4,7 @@ let project = import ./default.nix { inherit target-os pkgs nixpkgs-bootstrap; inherit (nixpkgs-bootstrap) config; }; - mkShell = pkgs.callPackage ./nix/bootstrapped-shell.nix { inherit stdenv; inherit (pkgs) mkShell; }; + mkShell = pkgs.callPackage ./nix/bootstrapped-shell.nix { inherit stdenv target-os; inherit (pkgs) mkShell; }; platform = pkgs.callPackage ./nix/platform.nix { inherit target-os; }; # TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib) stdenv = pkgs.stdenvNoCC; @@ -30,6 +30,5 @@ in mkShell { watchman ]; inputsFrom = [ project.shell ]; - TARGET_OS = target-os; shellHook = project.shell.shellHook; }