about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/hoogle.nix
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2021-11-20 17:43:12 +0100
committersterni <sternenseemann@systemli.org>2022-01-06 12:21:45 +0100
commitfb075fab731adbacfec384ad910bf48920c099c4 (patch)
tree3e58e2936dc170bebf483a2acc097d0d45762a1a /pkgs/development/haskell-modules/hoogle.nix
parentbaaf9459d6105c243239289e1e82e3cdd5ac4809 (diff)
haskellPackages.{ghcWithPackages, ghcWithHoogle}: make overrideable
This is achieved by passing the entire package set to the respective
wrappers and passing the select function as a second attribute. Together
with the new support for callPackage-ing functions this allows for
things like `ghcWithPackages.override { useLLVM = true; } (p: [ … ])`.

To make this possible for `ghcWithHoogle` as well, we need to make the
wrapper a bit more bespoke and inline the hoogle feature as well. The
hoogle wrapper, however, can remain separate and is exposed as
`hoogleWithPackages` additionally, as it can also serve standalone use.
`hoogleLocal` is kept for backwards compatibility (including the old,
suboptimal API), but will inform users about the better alternative via
a warning.
Diffstat (limited to 'pkgs/development/haskell-modules/hoogle.nix')
-rw-r--r--pkgs/development/haskell-modules/hoogle.nix38
1 files changed, 13 insertions, 25 deletions
diff --git a/pkgs/development/haskell-modules/hoogle.nix b/pkgs/development/haskell-modules/hoogle.nix
index d55f37f980d8a..0b3f71995c99f 100644
--- a/pkgs/development/haskell-modules/hoogle.nix
+++ b/pkgs/development/haskell-modules/hoogle.nix
@@ -1,34 +1,22 @@
 # Install not only the Hoogle library and executable, but also a local Hoogle
 # database which provides "Source" links to all specified 'packages' -- or the
 # current Haskell Platform if no custom package set is provided.
-#
-# It is intended to be used in config.nix similarly to:
-#
-# { packageOverrides = pkgs: rec {
-#
-#   haskellPackages =
-#     let callPackage = pkgs.lib.callPackageWith haskellPackages;
-#     in pkgs.recurseIntoAttrs (pkgs.haskellPackages.override {
-#         extension = self: super: {
-#           hoogleLocal = pkgs.haskellPackages.hoogleLocal.override {
-#             packages = with pkgs.haskellPackages; [
-#               mmorph
-#               monadControl
-#             ];
-#           };
-#         };
-#       });
-# }}
-#
-# This will build mmorph and monadControl, and have the hoogle installation
-# refer to their documentation via symlink so they are not garbage collected.
 
-{ lib, stdenv, buildPackages
-, hoogle, writeText, ghc
-, packages
+{ lib, stdenv, buildPackages, haskellPackages
+, writeText
 }:
 
+# This argument is a function which selects a list of Haskell packages from any
+# passed Haskell package set.
+#
+# Example:
+#   (hpkgs: [ hpkgs.mtl hpkgs.lens ])
+selectPackages:
+
 let
+  inherit (haskellPackages) ghc hoogle;
+  packages = selectPackages haskellPackages;
+
   wrapper = ./hoogle-local-wrapper.sh;
   isGhcjs = ghc.isGhcjs or false;
   opts = lib.optionalString;
@@ -55,7 +43,7 @@ let
 
 in
 buildPackages.stdenv.mkDerivation {
-  name = "hoogle-local-0.1";
+  name = "hoogle-with-packages";
   buildInputs = [ghc hoogle];
 
   inherit docPackages;