about summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/stern
diff options
context:
space:
mode:
authorBenjamin Staffin <benley@gmail.com>2018-11-26 20:35:48 -0500
committerGitHub <noreply@github.com>2018-11-26 20:35:48 -0500
commit551cee25b6751897fe34975ca60ac6636601ed9a (patch)
treedfbddea98d0b797f9c843a1ef0c91a5551077984 /pkgs/applications/networking/cluster/stern
parent56e12aae54bc67cabe5aa7c8d055438af4f62b5e (diff)
stern: build shell completion scripts even when cross-compiling (#51075)
Moments after merging #49668 I realized that this is not hard to do
correctly, so here it is now.
Diffstat (limited to 'pkgs/applications/networking/cluster/stern')
-rw-r--r--pkgs/applications/networking/cluster/stern/default.nix20
1 files changed, 11 insertions, 9 deletions
diff --git a/pkgs/applications/networking/cluster/stern/default.nix b/pkgs/applications/networking/cluster/stern/default.nix
index 75a88d14e4c8c..bb0f3229ea5e0 100644
--- a/pkgs/applications/networking/cluster/stern/default.nix
+++ b/pkgs/applications/networking/cluster/stern/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+{ stdenv, lib, buildPackages, buildGoPackage, fetchFromGitHub }:
+
+let isCrossBuild = stdenv.hostPlatform != stdenv.buildPlatform; in
 
 buildGoPackage rec {
   name = "stern-${version}";
@@ -15,14 +17,14 @@ buildGoPackage rec {
 
   goDeps = ./deps.nix;
 
-  # Only build shell completion if we're _not_ cross compiling,
-  # because it requires executing the compiled stern binary.
-  postInstall = lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform) ''
-    mkdir -p $bin/share/bash-completion/completions
-    $bin/bin/stern --completion bash > $bin/share/bash-completion/completions/stern
-    mkdir -p $bin/share/zsh/site-functions
-    $bin/bin/stern --completion zsh > $bin/share/zsh/site-functions/_stern
-  '';
+  postInstall =
+    let stern = if isCrossBuild then buildPackages.stern else "$bin"; in
+    ''
+      mkdir -p $bin/share/bash-completion/completions
+      ${stern}/bin/stern --completion bash > $bin/share/bash-completion/completions/stern
+      mkdir -p $bin/share/zsh/site-functions
+      ${stern}/bin/stern --completion zsh > $bin/share/zsh/site-functions/_stern
+    '';
 
   meta = with lib; {
     description      = "Multi pod and container log tailing for Kubernetes";