diff --git a/nix/status-go/build-desktop-status-go.nix b/nix/status-go/build-desktop-status-go.nix index 9a2cb6d685..2e7ec22021 100644 --- a/nix/status-go/build-desktop-status-go.nix +++ b/nix/status-go/build-desktop-status-go.nix @@ -2,6 +2,8 @@ { buildGoPackage, go, xcodeWrapper, pkgs, stdenv }: { owner, repo, rev, version, goPackagePath, src, host, + + # desktop-only arguments goBuildFlags, goBuildLdFlags, outputFileName, hostSystem } @ args': @@ -9,36 +11,24 @@ with stdenv; let - args = removeAttrs args' [ "goBuildFlags" "goBuildLdFlags" "outputFileName" "hostSystem" ]; buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper; }; + args = removeAttrs args' [ "goBuildFlags" "goBuildLdFlags" "outputFileName" "hostSystem" ]; # Remove desktop-only arguments from args buildStatusGoDesktopLib = buildStatusGo (args // { + buildMessage = "Building desktop library"; + #GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${outputFileName} ./lib buildPhase = '' - runHook preBuild - - runHook renameImports - pushd "$NIX_BUILD_TOP/go/src/${goPackagePath}" >/dev/null - echo - echo "Building desktop library" - echo - #GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${outputFileName} ./lib go build -o $out/${outputFileName} ${goBuildFlags} -buildmode=c-archive ${goBuildLdFlags} ./lib popd >/dev/null - - runHook postBuild ''; installPhase = '' - runHook preInstall - mkdir -p $out/lib/${hostSystem} $out/include mv $out/${outputFileName} $out/lib/${hostSystem} mv $out/libstatus.h $out/include - - runHook postInstall ''; outputs = [ "out" ]; diff --git a/nix/status-go/build-mobile-status-go.nix b/nix/status-go/build-mobile-status-go.nix index 41a8fb64ac..3b7dfa7a50 100644 --- a/nix/status-go/build-mobile-status-go.nix +++ b/nix/status-go/build-mobile-status-go.nix @@ -2,29 +2,25 @@ { buildGoPackage, go, gomobile, openjdk, xcodeWrapper, pkgs, stdenv }: { owner, repo, rev, version, goPackagePath, src, host, + + # mobile-only arguments goBuildFlags, goBuildLdFlags, config } @ args': with stdenv; let - args = removeAttrs args' [ "config" "goBuildFlags" "goBuildLdFlags" ]; targetConfig = config; buildStatusGo = pkgs.callPackage ./build-status-go.nix { inherit buildGoPackage go xcodeWrapper; }; + args = removeAttrs args' [ "config" "goBuildFlags" "goBuildLdFlags" ]; # Remove mobile-only arguments from args buildStatusGoMobileLib = buildStatusGo (args // { nativeBuildInputs = [ gomobile ] ++ lib.optional (targetConfig.name == "android") openjdk; + buildMessage = "Building mobile library for ${targetConfig.name}"; + # Build mobile libraries + # TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag buildPhase = '' - runHook preBuild - - runHook renameImports - - # Build mobile libraries - # TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag - echo - echo "Building mobile library for ${targetConfig.name}" - echo GOPATH=${gomobile.dev}:$GOPATH \ PATH=${lib.makeBinPath [ gomobile.bin ]}:$PATH \ ${lib.concatStringsSep " " targetConfig.envVars} \ @@ -32,17 +28,11 @@ let -o ${targetConfig.outputFileName} \ ${goBuildLdFlags} \ ${goPackagePath}/mobile - - runHook postBuild ''; installPhase = '' - runHook preInstall - mkdir -p $out/lib mv ${targetConfig.outputFileName} $out/lib/ - - runHook postInstall ''; outputs = [ "out" ]; diff --git a/nix/status-go/build-status-go.nix b/nix/status-go/build-status-go.nix index 97a6fcc4a6..d11b4fe59a 100644 --- a/nix/status-go/build-status-go.nix +++ b/nix/status-go/build-status-go.nix @@ -2,10 +2,10 @@ { owner, repo, rev, version, goPackagePath, src, host, nativeBuildInputs ? [], - buildPhase, + buildPhase, buildMessage, installPhase ? "", postInstall ? "", - outputs, meta } @ args: + outputs, meta } @ args': with stdenv; @@ -13,6 +13,7 @@ let 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}"; @@ -44,6 +45,27 @@ let xcrun xcodebuild -version ''; + buildPhase = '' + runHook preBuild + + runHook renameImports + + echo + echo "${buildMessage}" + echo + ${buildPhase} + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + ${installPhase} + + runHook postInstall + ''; + # remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build preFixup = '' find $out -type f -exec ${removeExpr removeReferences} '{}' + || true