diff options
author | sternenseemann <sternenseemann@systemli.org> | 2022-09-09 20:33:20 +0200 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2022-10-07 00:37:53 +0200 |
commit | ac1f1ad0e0a8cfd35db476529c82354e033a48cc (patch) | |
tree | 0ee227a5d60eadf6d51baa55cb5c3834e645c441 /pkgs/development/haskell-modules/make-package-set.nix | |
parent | e7b47a72fef2eb23342cd4f395ac305b8afa1ad4 (diff) | |
download | nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.tar nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.tar.gz nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.tar.bz2 nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.tar.lz nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.tar.xz nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.tar.zst nixlib-ac1f1ad0e0a8cfd35db476529c82354e033a48cc.zip |
haskell: support cross in generateOptparseApplicativeCompletions
Deprecate haskell.lib{,.compose}.generateOptparseApplicativeCompletion* in favor of the newly added haskell.packages.*.generateOptparseApplicativeCompletions (plural!) which takes into account whether we are cross-compiling or not. If we are, generating completions is disabled, since we can't execute software built for a different platform. The move is necessary, so we can receive the /same/ stdenv as the package we are overriding in order to accurately check whether we can execute produced binaries. Resolves #174040. Resolves #49648.
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 9d7cbe6f8f1b..843d1a9694c3 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 + ) { }; + } |