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)
|
# 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;
|
_stdenv = stdenvNoCC;
|
||||||
statusDesktop = callPackage ./nix/desktop { inherit target-os; stdenv = _stdenv; };
|
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; };
|
status-go = callPackage ./nix/status-go { inherit (xcodeenv) composeXcodeWrapper; inherit (statusMobile) xcodewrapperArgs; androidPkgs = statusMobile.androidComposition; };
|
||||||
nodejs' = pkgs.nodejs-10_x;
|
nodejs' = pkgs.nodejs-10_x;
|
||||||
yarn' = yarn.override { nodejs = nodejs'; };
|
yarn' = yarn.override { nodejs = nodejs'; };
|
||||||
|
@ -50,7 +50,7 @@ with pkgs;
|
||||||
maven
|
maven
|
||||||
watchman
|
watchman
|
||||||
|
|
||||||
status-go
|
status-go.package
|
||||||
] ++ nodePkgBuildInputs
|
] ++ nodePkgBuildInputs
|
||||||
++ lib.optional isDarwin cocoapods
|
++ lib.optional isDarwin cocoapods
|
||||||
++ lib.optional (!isDarwin) gcc7
|
++ lib.optional (!isDarwin) gcc7
|
||||||
|
@ -58,11 +58,6 @@ with pkgs;
|
||||||
++ lib.optionals targetMobile statusMobile.buildInputs;
|
++ lib.optionals targetMobile statusMobile.buildInputs;
|
||||||
shellHook =
|
shellHook =
|
||||||
status-go.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 targetDesktop statusDesktop.shellHook +
|
||||||
lib.optionalString targetMobile statusMobile.shellHook;
|
lib.optionalString targetMobile statusMobile.shellHook;
|
||||||
hardeningDisable = status-go.hardeningDisable;
|
hardeningDisable = status-go.hardeningDisable;
|
||||||
|
|
|
@ -62,94 +62,104 @@ let
|
||||||
goBuildFlags = "-v";
|
goBuildFlags = "-v";
|
||||||
goBuildLdFlags = "-ldflags=-s";
|
goBuildLdFlags = "-ldflags=-s";
|
||||||
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;
|
xcodeWrapper = composeXcodeWrapper xcodewrapperArgs;
|
||||||
|
status-go = buildGoPackage rec {
|
||||||
|
inherit goPackagePath version rev;
|
||||||
|
name = "${repo}-${version}";
|
||||||
|
|
||||||
in buildGoPackage rec {
|
src = pkgs.fetchFromGitHub { inherit rev owner repo sha256; };
|
||||||
inherit goPackagePath version rev;
|
|
||||||
name = "${repo}-${version}";
|
|
||||||
|
|
||||||
src = pkgs.fetchFromGitHub { inherit rev owner repo sha256; };
|
nativeBuildInputs = [ gomobile openjdk ]
|
||||||
|
++ lib.optional isDarwin xcodeWrapper;
|
||||||
|
|
||||||
nativeBuildInputs = [ gomobile openjdk ]
|
# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
|
||||||
++ lib.optional isDarwin xcodeWrapper;
|
hardeningDisable = [ "fortify" ];
|
||||||
|
|
||||||
# Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
|
# gomobile doesn't seem to be able to pass -ldflags with multiple values correctly to go build, so we just patch files here
|
||||||
hardeningDisable = [ "fortify" ];
|
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
|
substituteInPlace cmd/statusd/main.go --replace \
|
||||||
patchPhase = ''
|
"buildStamp = \"N/A\"" \
|
||||||
date=$(date -u '+%Y-%m-%d.%H:%M:%S')
|
"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 \
|
# 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
|
||||||
"buildStamp = \"N/A\"" \
|
preConfigure = lib.optionalString isDarwin ''
|
||||||
"buildStamp = \"$date\""
|
xcrun xcodebuild -version
|
||||||
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
|
buildPhase = ''
|
||||||
preConfigure = lib.optionalString isDarwin ''
|
runHook preBuild
|
||||||
xcrun xcodebuild -version
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
runHook renameImports
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
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
|
||||||
echo "Building $name"
|
echo "Building desktop library"
|
||||||
echo
|
echo
|
||||||
go install ${goBuildFlags} $name
|
#GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build ${goBuildFlags} -buildmode=c-archive -o $out/${desktopOutputFileName} ./lib
|
||||||
done
|
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
|
popd >/dev/null
|
||||||
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
|
|
||||||
${mobileBuildScript}
|
|
||||||
|
|
||||||
runHook postBuild
|
# Build mobile libraries
|
||||||
'';
|
# TODO: Manage to pass -s -w to -ldflags. Seems to only accept a single flag
|
||||||
|
${mobileBuildScript}
|
||||||
|
|
||||||
postInstall = ''
|
runHook postBuild
|
||||||
mkdir -p $bin
|
'';
|
||||||
cp -r "$NIX_BUILD_TOP/go/bin/" $bin
|
|
||||||
|
|
||||||
${mobileInstallScript}
|
postInstall = ''
|
||||||
|
mkdir -p $bin
|
||||||
|
cp -r "$NIX_BUILD_TOP/go/bin/" $bin
|
||||||
|
|
||||||
mkdir -p $out/lib/${desktopSystem} $out/include
|
${mobileInstallScript}
|
||||||
mv $out/${desktopOutputFileName} $out/lib/${desktopSystem}
|
|
||||||
mv $out/libstatus.h $out/include
|
|
||||||
'';
|
|
||||||
|
|
||||||
# remove hardcoded paths to go package in /nix/store, otherwise Nix will fail the build
|
mkdir -p $out/lib/${desktopSystem} $out/include
|
||||||
preFixup = ''
|
mv $out/${desktopOutputFileName} $out/lib/${desktopSystem}
|
||||||
find $out -type f -exec ${removeExpr removeReferences} '{}' + || true
|
mv $out/libstatus.h $out/include
|
||||||
'';
|
'';
|
||||||
|
|
||||||
outputs = [ "out" "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
|
||||||
|
'';
|
||||||
|
|
||||||
meta = {
|
outputs = [ "out" "bin" ];
|
||||||
description = "The Status module that consumes go-ethereum.";
|
|
||||||
license = lib.licenses.mpl20;
|
meta = {
|
||||||
maintainers = with lib.maintainers; [ pombeirp ];
|
description = "The Status module that consumes go-ethereum.";
|
||||||
platforms = with lib.platforms; linux ++ darwin;
|
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