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