Skip to content

add method for installing bash completions from optparse-applicative #381

Open
@cdepillabout

Description

@cdepillabout

It would be nice to have an easy way of installing bash completions from optparse-applicative.

We've added a small post install script to our own CLI tools with a module like the following:

{pkgs, ...}:
{
    packages.our-pkg-one.components.exes.our-exe-one.build-tools = [ pkgs.installShellFiles ];
    packages.our-pkg-one.components.all.postInstall = pkgs.lib.mkForce "";
    packages.our-pkg-one.components.exes.our-exe-one.postInstall = ''
      $out/bin/our-exe-one --bash-completion-script $out/bin/our-exe-one > our-exe-one.bash
      installShellCompletion --name our-exe-one --bash our-exe-one.bash
    '';

    packages.our-pkg-two.components.exes.our-exe-two.build-tools = [ pkgs.installShellFiles ];
    packages.our-pkg-two.components.all.postInstall = pkgs.lib.mkForce "";
    packages.our-pkg-two.components.exes.our-exe-two.postInstall = ''
      $out/bin/our-exe-two --bash-completion-script $out/bin/our-exe-two > our-exe-two.bash
      installShellCompletion --name our-exe-two --bash our-exe-two.bash
    '';

However, this is somewhat repetitive. It would be ideal if haskell.nix provided some sort of functionality for easily enabling this for a given package/exe.


The haskell stuff in nixpkgs has a function for doing this:

https://github.com/NixOS/nixpkgs/blob/9dacdec2d9757dd3f2daa68f8760a543581b609a/pkgs/development/haskell-modules/lib.nix#L369-L414

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions