Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh: fix cross #225121

Merged
merged 1 commit into from May 5, 2023
Merged

gh: fix cross #225121

merged 1 commit into from May 5, 2023

Conversation

ghost
Copy link

@ghost ghost commented Apr 7, 2023

No description provided.

@ghost
Copy link
Author

ghost commented Apr 7, 2023

@ofborg build pkgsCross.aarch64-multiplatform.gh
@ofborg build gh

@zowoq
Copy link
Contributor

zowoq commented Apr 7, 2023

diff --git a/pkgs/applications/version-management/gh/default.nix b/pkgs/applications/version-management/gh/default.nix
index da32620cf58..7a5d7d4febf 100644
--- a/pkgs/applications/version-management/gh/default.nix
+++ b/pkgs/applications/version-management/gh/default.nix
@@ -1,4 +1,4 @@
-{ lib, fetchFromGitHub, buildGoModule, installShellFiles, testers, gh }:
+{ lib, fetchFromGitHub, buildGoModule, installShellFiles, stdenv, testers, gh }:
 
 buildGoModule rec {
   pname = "gh";
@@ -15,27 +15,23 @@ buildGoModule rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  # upstream unsets these to handle cross but it breaks our build
-  postPatch = ''
-    substituteInPlace Makefile \
-      --replace "GOOS= GOARCH= GOARM= GOFLAGS= CGO_ENABLED=" ""
-  '';
-
   buildPhase = ''
     runHook preBuild
-    make GO_LDFLAGS="-s -w" GH_VERSION=${version} bin/gh manpages
+    make GO_LDFLAGS="-s -w" GH_VERSION=${version} bin/gh ${lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) "manpages"}
     runHook postBuild
   '';
 
   installPhase = ''
     runHook preInstall
     install -Dm755 bin/gh -t $out/bin
+   '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installManPage share/man/*/*.[1-9]
 
     installShellCompletion --cmd gh \
       --bash <($out/bin/gh completion -s bash) \
       --fish <($out/bin/gh completion -s fish) \
       --zsh <($out/bin/gh completion -s zsh)
+  '' + ''
     runHook postInstall
   '';
 

@ghost
Copy link
Author

ghost commented Apr 7, 2023

Copy link
Contributor

@zowoq zowoq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think disabling completion and man for cross is fine, please update this to match the diff I posted.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Apr 7, 2023
@ofborg ofborg bot requested a review from zowoq April 7, 2023 08:43
"zowoq" wrote this commit:

  #225121 (comment)
@zowoq zowoq merged commit 661117e into NixOS:master May 5, 2023
@ghost ghost deleted the pr/gh/fix-cross branch May 5, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant