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:
parent
9c3ff8c88c
commit
16fba373c9
|
@ -1,4 +1,5 @@
|
||||||
{ lib, stdenv, meta, source, buildGoPackage }:
|
{ lib, stdenv, meta, source, buildGoPackage,
|
||||||
|
go-bindata, mockgen, protoc-gen-go, protobuf3_20 }:
|
||||||
|
|
||||||
buildGoPackage {
|
buildGoPackage {
|
||||||
pname = source.repo;
|
pname = source.repo;
|
||||||
|
@ -7,6 +8,10 @@ buildGoPackage {
|
||||||
inherit meta;
|
inherit meta;
|
||||||
inherit (source) src goPackagePath;
|
inherit (source) src goPackagePath;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
go-bindata mockgen protoc-gen-go protobuf3_20
|
||||||
|
];
|
||||||
|
|
||||||
phases = ["unpackPhase" "configurePhase" "buildPhase"];
|
phases = ["unpackPhase" "configurePhase" "buildPhase"];
|
||||||
|
|
||||||
# https://pkg.go.dev/net#hdr-Name_Resolution
|
# https://pkg.go.dev/net#hdr-Name_Resolution
|
||||||
|
@ -22,6 +27,7 @@ buildGoPackage {
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
pushd go/src/$goPackagePath
|
pushd go/src/$goPackagePath
|
||||||
go run cmd/library/*.go > $NIX_BUILD_TOP/main.go
|
go run cmd/library/*.go > $NIX_BUILD_TOP/main.go
|
||||||
|
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
|
||||||
popd
|
popd
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ callPackage, lib, buildGoPackage
|
{ callPackage, lib, buildGoPackage
|
||||||
, androidPkgs, openjdk, gomobile, xcodeWrapper, removeReferencesTo
|
, androidPkgs, openjdk, gomobile, xcodeWrapper, removeReferencesTo
|
||||||
|
, go-bindata, mockgen, protobuf3_20, protoc-gen-go
|
||||||
, meta
|
, meta
|
||||||
, source
|
, source
|
||||||
, platform ? "android"
|
, platform ? "android"
|
||||||
|
@ -15,7 +16,7 @@ let
|
||||||
isAndroid = platform == "android";
|
isAndroid = platform == "android";
|
||||||
enforceXCodeAvailable = callPackage ./enforceXCodeAvailable.nix { };
|
enforceXCodeAvailable = callPackage ./enforceXCodeAvailable.nix { };
|
||||||
|
|
||||||
in buildGoPackage {
|
in buildGoPackage rec {
|
||||||
pname = source.repo;
|
pname = source.repo;
|
||||||
version = "${source.cleanVersion}-${source.shortRev}-${platform}";
|
version = "${source.cleanVersion}-${source.shortRev}-${platform}";
|
||||||
|
|
||||||
|
@ -27,8 +28,9 @@ in buildGoPackage {
|
||||||
__noChroot = isIOS;
|
__noChroot = isIOS;
|
||||||
|
|
||||||
extraSrcPaths = [ gomobile ];
|
extraSrcPaths = [ gomobile ];
|
||||||
nativeBuildInputs = [ gomobile removeReferencesTo ]
|
nativeBuildInputs = [
|
||||||
++ optional isAndroid openjdk
|
gomobile removeReferencesTo go-bindata mockgen protoc-gen-go protobuf3_20
|
||||||
|
] ++ optional isAndroid openjdk
|
||||||
++ optional isIOS xcodeWrapper;
|
++ optional isIOS xcodeWrapper;
|
||||||
|
|
||||||
ldflags = goBuildLdFlags;
|
ldflags = goBuildLdFlags;
|
||||||
|
@ -44,6 +46,13 @@ in buildGoPackage {
|
||||||
# TODO: try removing when go is upgraded to 1.22
|
# TODO: try removing when go is upgraded to 1.22
|
||||||
GODEBUG = "netdns=cgo+2";
|
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 = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
echo -e "\nBuilding $pname for: ${concatStringsSep "," targets}"
|
echo -e "\nBuilding $pname for: ${concatStringsSep "," targets}"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v2.3.0",
|
"version": "develop",
|
||||||
"commit-sha1": "effde33d493ff52b66c8013067c9aa6444d84473",
|
"commit-sha1": "ba37c32c07d1b05a94d1c7f7cb1b38fb82730f7b",
|
||||||
"src-sha256": "1rd0mczdkvjm9pbmza234v1jy1bvqh3ni2xck1l42ha4sld2aqjl"
|
"src-sha256": "1f1bbw70iircicda9w0hch56hxr7p1vvzkrk58v8p5sq23xzdf6y"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue