Commit 6d2c0248 authored by 06kellyjac's avatar 06kellyjac
Browse files

notation: provide completions when cross-compiling

parent c79de89e
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildGoModule,
  fetchFromGitHub,
  installShellFiles,
  testers,

  stdenv,
  buildPackages,
}:

buildGoModule (finalAttrs: {
@@ -36,11 +38,19 @@ buildGoModule (finalAttrs: {
    "-X github.com/notaryproject/notation/internal/version.BuildMetadata="
  ];

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd notation \
      --bash <($out/bin/notation completion bash) \
      --fish <($out/bin/notation completion fish) \
      --zsh <($out/bin/notation completion zsh)
  postInstall =
    let
      exe =
        if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
          "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}"
        else
          lib.getExe buildPackages.notation;
    in
    ''
      installShellCompletion --cmd ${finalAttrs.meta.mainProgram} \
        --bash <(${exe} completion bash) \
        --fish <(${exe} completion fish) \
        --zsh <(${exe} completion zsh)
    '';

  passthru.tests.version = testers.testVersion {