From c34f5176f1173ac2cdaeed4512a61389d98f9d9f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 30 Oct 2018 14:20:24 -0400 Subject: haskell-lib: Factor out shell completion scripts helper --- pkgs/development/haskell-modules/lib.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pkgs/development') diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index 8dae7c8d72c0..10edf69478b0 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -407,4 +407,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" + ''; + }); } -- cgit 1.4.1