Unverified Commit 2d59b75f authored by Thierry Delafontaine's avatar Thierry Delafontaine
Browse files

opencode: wrap program before installing shell completions

Fixes failures when generating shell completions by ensuring the
binary is wrapped before `installShellCompletion`.
parent b0c20454
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -114,18 +114,6 @@ stdenvNoCC.mkDerivation (finalAttrs: {
    runHook preInstall

    install -Dm755 dist/opencode-*/bin/opencode $out/bin/opencode
    install -Dm644 schema.json $out/share/opencode/schema.json

    runHook postInstall
  '';

  postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
    installShellCompletion --cmd opencode \
      --bash <($out/bin/opencode completion) \
      --zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
  '';

  postFixup = ''
    wrapProgram $out/bin/opencode \
     --prefix PATH : ${
       lib.makeBinPath (
@@ -137,6 +125,16 @@ stdenvNoCC.mkDerivation (finalAttrs: {
         ]
       )
     }

    install -Dm644 schema.json $out/share/opencode/schema.json

    runHook postInstall
  '';

  postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
    installShellCompletion --cmd opencode \
      --bash <($out/bin/opencode completion) \
      --zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
  '';

  nativeInstallCheckInputs = [