2019-05-02 18:13:16 +00:00
|
|
|
|
2019-05-17 08:55:24 +00:00
|
|
|
{ stdenv, utils, callPackage,
|
|
|
|
buildGoPackage, go, xcodeWrapper }:
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
{ owner, repo, rev, version, goPackagePath, src, host,
|
2019-05-06 14:52:02 +00:00
|
|
|
|
|
|
|
# desktop-only arguments
|
2019-05-02 18:13:16 +00:00
|
|
|
goBuildFlags, goBuildLdFlags,
|
|
|
|
outputFileName,
|
|
|
|
hostSystem } @ args':
|
|
|
|
|
|
|
|
let
|
2019-07-29 08:33:35 +00:00
|
|
|
buildStatusGo = callPackage ./build-status-go.nix {
|
|
|
|
inherit buildGoPackage go xcodeWrapper utils;
|
|
|
|
};
|
|
|
|
|
2019-10-22 11:56:13 +00:00
|
|
|
# Remove desktop-only arguments from args
|
2019-07-29 08:33:35 +00:00
|
|
|
args = removeAttrs args' [
|
2019-10-22 11:56:13 +00:00
|
|
|
"goBuildFlags" "goBuildLdFlags" "outputFileName" "hostSystem"
|
|
|
|
];
|
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
buildStatusGoDesktopLib = buildStatusGo (args // {
|
2019-05-06 14:52:02 +00:00
|
|
|
buildMessage = "Building desktop library";
|
|
|
|
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${outputFileName} ./lib
|
2019-10-22 11:56:13 +00:00
|
|
|
buildPhase =
|
|
|
|
let
|
|
|
|
CGO_LDFLAGS = stdenv.lib.concatStringsSep " " goBuildLdFlags;
|
|
|
|
in ''
|
2019-05-02 18:13:16 +00:00
|
|
|
pushd "$NIX_BUILD_TOP/go/src/${goPackagePath}" >/dev/null
|
|
|
|
|
2019-10-22 11:56:13 +00:00
|
|
|
go build -o $out/${outputFileName} \
|
|
|
|
${goBuildFlags} \
|
|
|
|
-buildmode=c-archive \
|
|
|
|
-ldflags='${CGO_LDFLAGS}' \
|
|
|
|
./lib
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib/${hostSystem} $out/include
|
|
|
|
mv $out/${outputFileName} $out/lib/${hostSystem}
|
|
|
|
mv $out/libstatus.h $out/include
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
2019-07-29 08:33:35 +00:00
|
|
|
meta = { platforms = with stdenv.lib.platforms; linux ++ darwin; };
|
2019-05-02 18:13:16 +00:00
|
|
|
});
|
|
|
|
|
2019-07-29 08:33:35 +00:00
|
|
|
in buildStatusGoDesktopLib
|