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.
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
|
{ stdenv, lib, buildPackages, buildGoPackage, fetchFromGitHub }:
|
||||||
|
|
||||||
|
let isCrossBuild = stdenv.hostPlatform != stdenv.buildPlatform; in
|
||||||
|
|
||||||
buildGoPackage rec {
|
buildGoPackage rec {
|
||||||
name = "stern-${version}";
|
name = "stern-${version}";
|
||||||
@@ -15,14 +17,14 @@ buildGoPackage rec {
|
|||||||
|
|
||||||
goDeps = ./deps.nix;
|
goDeps = ./deps.nix;
|
||||||
|
|
||||||
# Only build shell completion if we're _not_ cross compiling,
|
postInstall =
|
||||||
# because it requires executing the compiled stern binary.
|
let stern = if isCrossBuild then buildPackages.stern else "$bin"; in
|
||||||
postInstall = lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform) ''
|
''
|
||||||
mkdir -p $bin/share/bash-completion/completions
|
mkdir -p $bin/share/bash-completion/completions
|
||||||
$bin/bin/stern --completion bash > $bin/share/bash-completion/completions/stern
|
${stern}/bin/stern --completion bash > $bin/share/bash-completion/completions/stern
|
||||||
mkdir -p $bin/share/zsh/site-functions
|
mkdir -p $bin/share/zsh/site-functions
|
||||||
$bin/bin/stern --completion zsh > $bin/share/zsh/site-functions/_stern
|
${stern}/bin/stern --completion zsh > $bin/share/zsh/site-functions/_stern
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Multi pod and container log tailing for Kubernetes";
|
description = "Multi pod and container log tailing for Kubernetes";
|
||||||
|
|||||||
Reference in New Issue
Block a user