lol

haskellPackages.ghcWithHoogle: add `passthru.hoogle`

Package sets built with `haskellPackages.ghcWithHoogle` provide a Hoogle
executable which points to a Hoogle database, but there's no way to
programmatically access the derivation containing the Hoogle database
from the package set.

This adds a `passthru.hoogle` attribute to package sets built with
`haskellPackages.ghcWithHoogle`, and a `passthru.database` helper to
derivations built with `haskellPackages.hoogleWithPackages`.

+26 -8
+1 -1
pkgs/development/haskell-modules/hoogle-local-wrapper.sh
··· 2 2 3 3 COMMAND=$1 4 4 shift 5 - exec @hoogle@/bin/hoogle "$COMMAND" --database @out@/share/doc/hoogle/default.hoo "$@" 5 + exec @hoogle@/bin/hoogle "$COMMAND" --database @database@ "$@"
+20 -4
pkgs/development/haskell-modules/hoogle.nix
··· 8 8 buildPackages, 9 9 haskellPackages, 10 10 writeText, 11 + runCommand, 11 12 }: 12 13 13 14 # This argument is a function which selects a list of Haskell packages from any ··· 40 41 # we grab the doc outputs 41 42 (map (lib.getOutput "doc") packages); 42 43 44 + # Hoogle database path, relative to `$out`. 45 + databasePath = "share/doc/hoogle/default.hoo"; 46 + 43 47 in 44 - buildPackages.stdenv.mkDerivation { 48 + buildPackages.stdenv.mkDerivation (finalAttrs: { 45 49 name = "hoogle-with-packages"; 46 50 buildInputs = [ 47 51 ghc ··· 101 105 ) 102 106 } 103 107 108 + databasePath="$out/"${lib.escapeShellArg databasePath} 109 + 104 110 echo building hoogle database 105 - hoogle generate --database $out/share/doc/hoogle/default.hoo --local=$out/share/doc/hoogle 111 + hoogle generate --database "$databasePath" --local=$out/share/doc/hoogle 106 112 107 113 echo building haddock index 108 114 # adapted from GHC's gen_contents_index ··· 122 128 echo finishing up 123 129 mkdir -p $out/bin 124 130 substitute ${wrapper} $out/bin/hoogle \ 125 - --subst-var out --subst-var-by shell ${stdenv.shell} \ 131 + --subst-var-by shell ${stdenv.shell} \ 132 + --subst-var-by database "$databasePath" \ 126 133 --subst-var-by hoogle ${hoogle} 127 134 chmod +x $out/bin/hoogle 128 135 ''; 129 136 130 137 passthru = { 131 138 isHaskellLibrary = false; # for the filter in ./with-packages-wrapper.nix 139 + 140 + # The path to the Hoogle database. 141 + database = "${finalAttrs.finalPackage}/${databasePath}"; 142 + 143 + tests.can-search-database = runCommand "can-search-database" { } '' 144 + # This succeeds even if no results are found, but `Prelude.map` should 145 + # always be available. 146 + ${finalAttrs.finalPackage}/bin/hoogle search Prelude.map > $out 147 + ''; 132 148 }; 133 149 134 150 meta = { ··· 137 153 hydraPlatforms = with lib.platforms; none; 138 154 maintainers = with lib.maintainers; [ ttuegel ]; 139 155 }; 140 - } 156 + })
+5 -3
pkgs/development/haskell-modules/with-packages-wrapper.nix
··· 47 47 let 48 48 inherit (haskellPackages) llvmPackages ghc; 49 49 50 - packages = 51 - selectPackages haskellPackages 52 - ++ lib.optional withHoogle (hoogleWithPackages selectPackages); 50 + hoogleWithPackages' = if withHoogle then hoogleWithPackages selectPackages else null; 51 + 52 + packages = selectPackages haskellPackages ++ [ hoogleWithPackages' ]; 53 53 54 54 isGhcjs = ghc.isGhcjs or false; 55 55 isHaLVM = ghc.isHaLVM or false; ··· 201 201 preferLocalBuild = true; 202 202 passthru = { 203 203 inherit (ghc) version meta; 204 + 205 + hoogle = hoogleWithPackages'; 204 206 205 207 # Inform users about backwards incompatibilities with <= 21.05 206 208 override =