2019-05-09 16:16:15 +00:00
|
|
|
{ buildGoPackage, go, xcodeWrapper, stdenv, utils }:
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
{ 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-14 17:29:36 +00:00
|
|
|
preFixup ? "",
|
2019-05-06 14:52:02 +00:00
|
|
|
outputs, meta } @ args':
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
with stdenv;
|
|
|
|
|
|
|
|
let
|
2019-07-19 18:42:16 +00:00
|
|
|
inherit (stdenv.lib) strings;
|
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
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 // {
|
2019-07-19 18:42:16 +00:00
|
|
|
pname = repo;
|
|
|
|
version = "${version}-${strings.substring 0 7 rev}-${host}";
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-05-14 17:29:36 +00:00
|
|
|
nativeBuildInputs =
|
|
|
|
nativeBuildInputs ++
|
|
|
|
lib.optional isDarwin xcodeWrapper;
|
2019-05-02 18:13:16 +00:00
|
|
|
|
|
|
|
# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
|
|
|
|
hardeningDisable = [ "fortify" ];
|
|
|
|
|
2019-05-09 16:16:15 +00:00
|
|
|
# Ensure XCode is present, instead of failing at the end of the build
|
|
|
|
preConfigure = lib.optionalString isDarwin utils.enforceXCodeAvailable;
|
2019-05-02 18:13:16 +00:00
|
|
|
|
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-14 17:29:36 +00:00
|
|
|
# replace hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
|
2019-05-02 18:13:16 +00:00
|
|
|
preFixup = ''
|
2019-05-14 17:29:36 +00:00
|
|
|
${preFixup}
|
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
|
|
|
return
|
|
|
|
'';
|
|
|
|
|
2019-07-29 08:33:35 +00:00
|
|
|
passthru = { inherit owner version rev; };
|
2019-07-19 18:42:16 +00:00
|
|
|
|
2019-05-02 18:13:16 +00:00
|
|
|
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
|
2019-07-29 08:33:35 +00:00
|
|
|
maintainers = (meta.maintainers or [ ]) ++ [ lib.maintainers.pombeirp ];
|
2019-05-02 18:13:16 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2019-05-14 17:29:36 +00:00
|
|
|
in buildStatusGo
|