nix: add preBuild phase for generating files (#21390)

effde33d...ba37c32c

https://github.com/status-im/status-go/pull/5920

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Siddarth Kumar 2024-10-07 17:19:37 +05:30 committed by GitHub
parent 9c3ff8c88c
commit 16fba373c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 7 deletions

View File

@ -1,4 +1,5 @@
{ lib, stdenv, meta, source, buildGoPackage }:
{ lib, stdenv, meta, source, buildGoPackage,
go-bindata, mockgen, protoc-gen-go, protobuf3_20 }:
buildGoPackage {
pname = source.repo;
@ -7,6 +8,10 @@ buildGoPackage {
inherit meta;
inherit (source) src goPackagePath;
nativeBuildInputs = [
go-bindata mockgen protoc-gen-go protobuf3_20
];
phases = ["unpackPhase" "configurePhase" "buildPhase"];
# https://pkg.go.dev/net#hdr-Name_Resolution
@ -22,6 +27,7 @@ buildGoPackage {
preBuild = ''
pushd go/src/$goPackagePath
go run cmd/library/*.go > $NIX_BUILD_TOP/main.go
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
popd
'';

View File

@ -1,5 +1,6 @@
{ callPackage, lib, buildGoPackage
, androidPkgs, openjdk, gomobile, xcodeWrapper, removeReferencesTo
, go-bindata, mockgen, protobuf3_20, protoc-gen-go
, meta
, source
, platform ? "android"
@ -15,7 +16,7 @@ let
isAndroid = platform == "android";
enforceXCodeAvailable = callPackage ./enforceXCodeAvailable.nix { };
in buildGoPackage {
in buildGoPackage rec {
pname = source.repo;
version = "${source.cleanVersion}-${source.shortRev}-${platform}";
@ -27,8 +28,9 @@ in buildGoPackage {
__noChroot = isIOS;
extraSrcPaths = [ gomobile ];
nativeBuildInputs = [ gomobile removeReferencesTo ]
++ optional isAndroid openjdk
nativeBuildInputs = [
gomobile removeReferencesTo go-bindata mockgen protoc-gen-go protobuf3_20
] ++ optional isAndroid openjdk
++ optional isIOS xcodeWrapper;
ldflags = goBuildLdFlags;
@ -44,6 +46,13 @@ in buildGoPackage {
# TODO: try removing when go is upgraded to 1.22
GODEBUG = "netdns=cgo+2";
preBuild = ''
echo 'Generate static files'
pushd go/src/$goPackagePath
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
popd
'';
buildPhase = ''
runHook preBuild
echo -e "\nBuilding $pname for: ${concatStringsSep "," targets}"

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v2.3.0",
"commit-sha1": "effde33d493ff52b66c8013067c9aa6444d84473",
"src-sha256": "1rd0mczdkvjm9pbmza234v1jy1bvqh3ni2xck1l42ha4sld2aqjl"
"version": "develop",
"commit-sha1": "ba37c32c07d1b05a94d1c7f7cb1b38fb82730f7b",
"src-sha256": "1f1bbw70iircicda9w0hch56hxr7p1vvzkrk58v8p5sq23xzdf6y"
}