2019-05-02 18:13:16 +00:00
|
|
|
{ buildGoPackage, go, xcodeWrapper, stdenv }:
|
|
|
|
|
|
|
|
{ owner, repo, rev, version, goPackagePath, src, host,
|
|
|
|
nativeBuildInputs ? [],
|
2019-05-06 14:52:02 +00:00
|
|
|
buildPhase, buildMessage,
|
2019-05-02 18:13:16 +00:00
|
|
|
installPhase ? "",
|
|
|
|
postInstall ? "",
|
2019-05-06 14:52:02 +00:00
|
|
|
outputs, meta } @ args':
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
with stdenv;
|
|
|
|
|
|
|
|
let
|
|
|
|
removeReferences = [ go ];
|
|
|
|
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
|
|
|
|
|
2019-05-06 14:52:02 +00:00
|
|
|
args = removeAttrs args' [ "buildMessage" ]; # Remove our arguments from args before passing them on to buildGoPackage
|
2019-05-02 18:13:16 +00:00
|
|
|
buildStatusGo = buildGoPackage (args // {
|
|
|
|
name = "${repo}-${version}-${host}";
|
|
|
|
|
|
|
|
nativeBuildInputs = nativeBuildInputs ++ lib.optional isDarwin xcodeWrapper;
|
|
|
|
|
|
|
|
# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
|
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
|
|
|
# gomobile doesn't seem to be able to pass -ldflags with multiple values correctly to go build, so we just patch files here
|
|
|
|
patchPhase = ''
|
|
|
|
date=$(date -u '+%Y-%m-%d.%H:%M:%S')
|
|
|
|
|
|
|
|
substituteInPlace cmd/statusd/main.go --replace \
|
|
|
|
"buildStamp = \"N/A\"" \
|
|
|
|
"buildStamp = \"$date\""
|
|
|
|
substituteInPlace params/version.go --replace \
|
|
|
|
"var Version string" \
|
|
|
|
"var Version string = \"${version}\""
|
|
|
|
substituteInPlace params/version.go --replace \
|
|
|
|
"var GitCommit string" \
|
|
|
|
"var GitCommit string = \"${rev}\""
|
|
|
|
substituteInPlace vendor/github.com/ethereum/go-ethereum/metrics/metrics.go --replace \
|
|
|
|
"var EnabledStr = \"false\"" \
|
|
|
|
"var EnabledStr = \"true\""
|
|
|
|
'';
|
|
|
|
|
|
|
|
# we print out the version so that we fail fast in case there's any problem running xcrun, instead of failing at the end of the build
|
|
|
|
preConfigure = lib.optionalString isDarwin ''
|
|
|
|
xcrun xcodebuild -version
|
|
|
|
'';
|
|
|
|
|
2019-05-06 14:52:02 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
runHook renameImports
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "${buildMessage}"
|
|
|
|
echo
|
|
|
|
${buildPhase}
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
${installPhase}
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
# remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
|
|
|
|
preFixup = ''
|
|
|
|
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
|
|
|
return
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
# Add default meta information
|
|
|
|
inherit (meta) platforms;
|
|
|
|
description = meta.description or "The Status module that consumes go-ethereum.";
|
|
|
|
license = lib.licenses.mpl20;
|
|
|
|
} // meta // {
|
|
|
|
# add an extra maintainer to every package
|
|
|
|
maintainers = (meta.maintainers or []) ++
|
|
|
|
[ lib.maintainers.pombeirp ];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
in buildStatusGo
|