diff options
Diffstat (limited to 'pkgs/development/haskell-modules/make-package-set.nix')
-rw-r--r-- | pkgs/development/haskell-modules/make-package-set.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 9d7cbe6f8f1b2..843d1a9694c30 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -597,4 +597,34 @@ in package-set { inherit pkgs lib callPackage; } self // { } pkg; + /* + Modify a Haskell package to add shell completion scripts for the + given executables produced by it. These completion scripts will be + picked up automatically if the resulting derivation is installed, + e.g. by `nix-env -i`. + + This depends on the `--*-completion` flag `optparse-applicative` provides + automatically. Since we need to invoke installed executables, completions + are not generated if we are cross-compiling. + + commands: names of the executables built by the derivation + pkg: Haskell package that builds the executables + + Example: + generateOptparseApplicativeCompletions [ "exec1" "exec2" ] pkg + + Type: [str] -> drv -> drv + */ + generateOptparseApplicativeCompletions = + self.callPackage ( + { stdenv }: + + commands: + pkg: + + if stdenv.buildPlatform.canExecute stdenv.hostPlatform + then lib.foldr haskellLib.__generateOptparseApplicativeCompletion pkg commands + else pkg + ) { }; + } |