2019-05-09 16:16:15 +00:00
|
|
|
{ buildGoPackage, go, xcodeWrapper, stdenv, utils }:
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-11-29 10:20:08 +00:00
|
|
|
{ owner, repo, rev, cleanVersion, goPackagePath, src, host,
|
2019-05-02 18:13:16 +00:00
|
|
|
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;
|
2019-11-29 10:20:08 +00:00
|
|
|
version = "${cleanVersion}-${strings.substring 0 7 rev}-${host}";
|
2019-05-02 18:13:16 +00:00
|
|
|
|
2019-11-20 12:42:41 +00:00
|
|
|
nativeBuildInputs =
|
2019-05-14 17:29:36 +00:00
|
|
|
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-11-20 12:42:41 +00:00
|
|
|
preFixup = preFixup + ''
|
2019-05-02 18:13:16 +00:00
|
|
|
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
2019-11-20 12:42:41 +00:00
|
|
|
return # make sure we stop fixup so as to not allow the host preFixup script to proceed
|
2019-05-02 18:13:16 +00:00
|
|
|
'';
|
|
|
|
|
2019-11-28 16:43:28 +00:00
|
|
|
passthru = { inherit owner repo 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
|