diff options
author | John Ericson <git@JohnEricson.me> | 2018-10-30 15:25:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 15:25:03 -0400 |
commit | 26fa9d2b5191d34fa8760b5efc8a3d25a2d34542 (patch) | |
tree | 4e612069102119cd053f3343d8f07821a2697cc9 /pkgs/development/haskell-modules | |
parent | d48cef7d5b8516368b15b4430c473cb63549f20f (diff) | |
parent | c34f5176f1173ac2cdaeed4512a61389d98f9d9f (diff) | |
download | nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.tar nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.tar.gz nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.tar.bz2 nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.tar.lz nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.tar.xz nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.tar.zst nixlib-26fa9d2b5191d34fa8760b5efc8a3d25a2d34542.zip |
Merge pull request #49477 from obsidiansystems/haskell-shell-completions
haskell-lib: Factor out shell completion scripts helper
Diffstat (limited to 'pkgs/development/haskell-modules')
-rw-r--r-- | pkgs/development/haskell-modules/lib.nix | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index f4ebe549c502..942163ea2096 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -354,4 +354,19 @@ rec { in builtins.listToAttrs (map toKeyVal haskellPaths); + + # Modify a Haskell package to add completion scripts for the given executable + # produced by it. These completion scripts will be picked up automatically if + # the resulting derivation is installed, e.g. by `nix-env -i`. + addOptparseApplicativeCompletionScripts = exeName: pkg: overrideCabal pkg (drv: { + postInstall = (drv.postInstall or "") + '' + bashCompDir="$out/share/bash-completion/completions" + zshCompDir="$out/share/zsh/vendor-completions" + fishCompDir="$out/share/fish/vendor_completions.d" + mkdir -p "$bashCompDir" "$zshCompDir" "$fishCompDir" + "$out/bin/${exeName}" --bash-completion-script "$out/bin/${exeName}" >"$bashCompDir/${exeName}" + "$out/bin/${exeName}" --zsh-completion-script "$out/bin/${exeName}" >"$zshCompDir/_${exeName}" + "$out/bin/${exeName}" --fish-completion-script "$out/bin/${exeName}" >"$fishCompDir/${exeName}.fish" + ''; + }); } |