Unverified Commit eb833beb authored by Bryce Berger's avatar Bryce Berger
Browse files

bacon: install shell completions

parent d325772e
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -3,10 +3,12 @@
  stdenv,
  rustPlatform,
  fetchFromGitHub,
  installShellFiles,
  pkg-config,
  alsa-lib,
  versionCheckHook,
  bacon,
  buildPackages,
  nix-update-script,

  withSound ? false,
@@ -41,7 +43,11 @@ rustPlatform.buildRustPackage (finalAttrs: {
    "sound"
  ];

  nativeBuildInputs = lib.optionals withSound [
  nativeBuildInputs =
    [
      installShellFiles
    ]
    ++ lib.optionals withSound [
      pkg-config
    ];

@@ -51,6 +57,17 @@ rustPlatform.buildRustPackage (finalAttrs: {
  versionCheckProgramArg = [ "--version" ];
  doInstallCheck = true;

  postInstall =
    let
      bacon = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/bacon";
    in
    lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
      installShellCompletion --cmd bacon \
        --bash <(COMPLETE=bash ${bacon}) \
        --fish <(COMPLETE=fish ${bacon}) \
        --zsh <(COMPLETE=zsh ${bacon})
    '';

  passthru = {
    tests = {
      withSound = bacon.override { withSound = true; };