Move shellHook to status-go package
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
parent
8e6b8b1ff1
commit
d453e510a2
|
@ -26,7 +26,7 @@ with pkgs;
|
|||
# TODO: Try to use stdenv for iOS. The problem is with building iOS as the build is trying to pass parameters to Apple's ld that are meant for GNU's ld (e.g. -dynamiclib)
|
||||
_stdenv = stdenvNoCC;
|
||||
statusDesktop = callPackage ./nix/desktop { inherit target-os; stdenv = _stdenv; };
|
||||
statusMobile = callPackage ./nix/mobile { inherit target-os config status-go; stdenv = _stdenv; };
|
||||
statusMobile = callPackage ./nix/mobile { inherit target-os config; status-go = status-go.package; stdenv = _stdenv; };
|
||||
status-go = callPackage ./nix/status-go { inherit (xcodeenv) composeXcodeWrapper; inherit (statusMobile) xcodewrapperArgs; androidPkgs = statusMobile.androidComposition; };
|
||||
nodejs' = pkgs.nodejs-10_x;
|
||||
yarn' = yarn.override { nodejs = nodejs'; };
|
||||
|
@ -50,7 +50,7 @@ with pkgs;
|
|||
maven
|
||||
watchman
|
||||
|
||||
status-go
|
||||
status-go.package
|
||||
] ++ nodePkgBuildInputs
|
||||
++ lib.optional isDarwin cocoapods
|
||||
++ lib.optional (!isDarwin) gcc7
|
||||
|
@ -58,11 +58,6 @@ with pkgs;
|
|||
++ lib.optionals targetMobile statusMobile.buildInputs;
|
||||
shellHook =
|
||||
status-go.shellHook +
|
||||
''
|
||||
export STATUS_GO_INCLUDEDIR=${status-go}/include
|
||||
export STATUS_GO_LIBDIR=${status-go}/lib
|
||||
export STATUS_GO_BINDIR=${status-go.bin}/bin
|
||||
'' +
|
||||
lib.optionalString targetDesktop statusDesktop.shellHook +
|
||||
lib.optionalString targetMobile statusMobile.shellHook;
|
||||
hardeningDisable = status-go.hardeningDisable;
|
||||
|
|
|
@ -62,94 +62,104 @@ let
|
|||
goBuildFlags = "-v";
|
||||
goBuildLdFlags = "-ldflags=-s";
|
||||
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;
|
||||
status-go = buildGoPackage rec {
|
||||
inherit goPackagePath version rev;
|
||||
name = "${repo}-${version}";
|
||||
|
||||
in buildGoPackage rec {
|
||||
inherit goPackagePath version rev;
|
||||
name = "${repo}-${version}";
|
||||
src = pkgs.fetchFromGitHub { inherit rev owner repo sha256; };
|
||||
|
||||
src = pkgs.fetchFromGitHub { inherit rev owner repo sha256; };
|
||||
nativeBuildInputs = [ gomobile openjdk ]
|
||||
++ lib.optional isDarwin xcodeWrapper;
|
||||
|
||||
nativeBuildInputs = [ gomobile openjdk ]
|
||||
++ lib.optional isDarwin xcodeWrapper;
|
||||
# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
|
||||
hardeningDisable = [ "fortify" ];
|
||||
|
||||
# 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')
|
||||
|
||||
# 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\""
|
||||
'';
|
||||
|
||||
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
|
||||
'';
|
||||
|
||||
# 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
|
||||
'';
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
runHook renameImports
|
||||
|
||||
runHook renameImports
|
||||
pushd "$NIX_BUILD_TOP/go/src/${goPackagePath}" >/dev/null
|
||||
|
||||
pushd "$NIX_BUILD_TOP/go/src/${goPackagePath}" >/dev/null
|
||||
|
||||
echo
|
||||
echo "Building desktop library"
|
||||
echo
|
||||
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${desktopOutputFileName} ./lib
|
||||
go build -o $out/${desktopOutputFileName} ${goBuildFlags} -buildmode=c-archive ${goBuildLdFlags} ./lib
|
||||
|
||||
# Build command-line tools
|
||||
for name in ./cmd/*; do
|
||||
echo
|
||||
echo "Building $name"
|
||||
echo "Building desktop library"
|
||||
echo
|
||||
go install ${goBuildFlags} $name
|
||||
done
|
||||
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${desktopOutputFileName} ./lib
|
||||
go build -o $out/${desktopOutputFileName} ${goBuildFlags} -buildmode=c-archive ${goBuildLdFlags} ./lib
|
||||
|
||||
popd >/dev/null
|
||||
# Build command-line tools
|
||||
for name in ./cmd/*; do
|
||||
echo
|
||||
echo "Building $name"
|
||||
echo
|
||||
go install ${goBuildFlags} $name
|
||||
done
|
||||
|
||||
# Build mobile libraries
|
||||
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
|
||||
${mobileBuildScript}
|
||||
popd >/dev/null
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
# Build mobile libraries
|
||||
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
|
||||
${mobileBuildScript}
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $bin
|
||||
cp -r "$NIX_BUILD_TOP/go/bin/" $bin
|
||||
|
||||
${mobileInstallScript}
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
mkdir -p $out/lib/${desktopSystem} $out/include
|
||||
mv $out/${desktopOutputFileName} $out/lib/${desktopSystem}
|
||||
mv $out/libstatus.h $out/include
|
||||
'';
|
||||
postInstall = ''
|
||||
mkdir -p $bin
|
||||
cp -r "$NIX_BUILD_TOP/go/bin/" $bin
|
||||
|
||||
# remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
|
||||
preFixup = ''
|
||||
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
||||
'';
|
||||
${mobileInstallScript}
|
||||
|
||||
outputs = [ "out" "bin" ];
|
||||
mkdir -p $out/lib/${desktopSystem} $out/include
|
||||
mv $out/${desktopOutputFileName} $out/lib/${desktopSystem}
|
||||
mv $out/libstatus.h $out/include
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "The Status module that consumes go-ethereum.";
|
||||
license = lib.licenses.mpl20;
|
||||
maintainers = with lib.maintainers; [ pombeirp ];
|
||||
platforms = with lib.platforms; linux ++ darwin;
|
||||
# remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
|
||||
preFixup = ''
|
||||
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
||||
'';
|
||||
|
||||
outputs = [ "out" "bin" ];
|
||||
|
||||
meta = {
|
||||
description = "The Status module that consumes go-ethereum.";
|
||||
license = lib.licenses.mpl20;
|
||||
maintainers = with lib.maintainers; [ pombeirp ];
|
||||
platforms = with lib.platforms; linux ++ darwin;
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
package = status-go;
|
||||
hardeningDisable = status-go.hardeningDisable;
|
||||
shellHook =
|
||||
''
|
||||
export STATUS_GO_INCLUDEDIR=${status-go}/include
|
||||
export STATUS_GO_LIBDIR=${status-go}/lib
|
||||
export STATUS_GO_BINDIR=${status-go.bin}/bin
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue