2024-10-07 11:49:37 +00:00
|
|
|
{ lib, stdenv, meta, source, buildGoPackage,
|
|
|
|
go-bindata, mockgen, protoc-gen-go, protobuf3_20 }:
|
2024-05-29 15:53:24 +00:00
|
|
|
|
|
|
|
buildGoPackage {
|
2022-05-19 15:50:41 +00:00
|
|
|
pname = source.repo;
|
|
|
|
version = "${source.cleanVersion}-${source.shortRev}";
|
|
|
|
|
|
|
|
inherit meta;
|
|
|
|
inherit (source) src goPackagePath;
|
|
|
|
|
2024-10-07 11:49:37 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
go-bindata mockgen protoc-gen-go protobuf3_20
|
|
|
|
];
|
|
|
|
|
2022-05-19 15:50:41 +00:00
|
|
|
phases = ["unpackPhase" "configurePhase" "buildPhase"];
|
|
|
|
|
2024-04-26 12:34:04 +00:00
|
|
|
# https://pkg.go.dev/net#hdr-Name_Resolution
|
|
|
|
# https://github.com/status-im/status-mobile/issues/19736
|
|
|
|
# https://github.com/status-im/status-mobile/issues/19581
|
|
|
|
# TODO: try removing when go is upgraded to 1.22
|
|
|
|
GODEBUG = "netdns=cgo+2";
|
|
|
|
|
2024-05-30 09:11:56 +00:00
|
|
|
# Since go 1.21 status-go compiled library includes references to cgo runtime.
|
|
|
|
# FIXME: Remove this when go 1.23 or later versions fix this madness.
|
|
|
|
allowGoReference = true;
|
|
|
|
|
2022-05-19 15:50:41 +00:00
|
|
|
preBuild = ''
|
|
|
|
pushd go/src/$goPackagePath
|
|
|
|
go run cmd/library/*.go > $NIX_BUILD_TOP/main.go
|
2024-10-07 11:49:37 +00:00
|
|
|
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
|
2022-05-19 15:50:41 +00:00
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Build the Go library
|
2024-05-29 15:53:24 +00:00
|
|
|
# ld flags and netgo tag are necessary for integration tests to work on MacOS
|
|
|
|
# https://github.com/status-im/status-mobile/issues/20135
|
2022-05-19 15:50:41 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2022-11-08 13:17:38 +00:00
|
|
|
go build \
|
|
|
|
-buildmode='c-archive' \
|
2024-05-29 15:53:24 +00:00
|
|
|
${lib.optionalString stdenv.isDarwin "-ldflags=-extldflags=-lresolv"} \
|
|
|
|
-tags='gowaku_skip_migrations gowaku_no_rln ${lib.optionalString stdenv.isDarwin "netgo"}' \
|
2022-11-08 13:17:38 +00:00
|
|
|
-o "$out/libstatus.a" \
|
|
|
|
$NIX_BUILD_TOP/main.go
|
2022-05-19 15:50:41 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
}
|