Skip to content

gh: fix cross#225121

Merged
zowoq merged 1 commit intomasterfrom
unknown repository
May 5, 2023
Merged

gh: fix cross#225121
zowoq merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Apr 7, 2023

No description provided.

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 7, 2023

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

@zowoq
Copy link
Copy Markdown
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
Copy Markdown
Author

ghost commented Apr 7, 2023

Copy link
Copy Markdown
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
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 7, 2023
"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 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant