lol

haskell-ng: hoogleLocal support

+126 -3
+1
pkgs/development/haskell-modules/default.nix
··· 56 56 57 57 ghcWithPackages = pkgs: callPackage ./with-packages-wrapper.nix { 58 58 inherit (self) llvmPackages; 59 + haskellPackages = self; 59 60 packages = pkgs self; 60 61 }; 61 62
+6
pkgs/development/haskell-modules/hoogle-local-wrapper.sh
··· 1 + #! @shell@ 2 + 3 + COMMAND=$1 4 + shift 5 + HOOGLE_DOC_PATH=@out@/share/hoogle/doc exec @hoogle@/bin/hoogle \ 6 + "$COMMAND" -d @out@/share/hoogle "$@"
+107
pkgs/development/haskell-modules/hoogle.nix
··· 1 + # Install not only the Hoogle library and executable, but also a local Hoogle 2 + # database which provides "Source" links to all specified 'packages' -- or the 3 + # current Haskell Platform if no custom package set is provided. 4 + # 5 + # It is intended to be used in config.nix similarly to: 6 + # 7 + # { packageOverrides = pkgs: rec { 8 + # 9 + # haskellPackages = 10 + # let callPackage = pkgs.lib.callPackageWith haskellPackages; 11 + # in pkgs.recurseIntoAttrs (pkgs.haskellPackages.override { 12 + # extension = self: super: { 13 + # hoogleLocal = pkgs.haskellPackages.hoogleLocal.override { 14 + # packages = with pkgs.haskellPackages; [ 15 + # mmorph 16 + # monadControl 17 + # ]; 18 + # }; 19 + # }; 20 + # }); 21 + # }} 22 + # 23 + # This will build mmorph and monadControl, and have the hoogle installation 24 + # refer to their documentation via symlink so they are not garbage collected. 25 + 26 + { stdenv, hoogle, rehoo 27 + , ghc, packages ? [ ghc.ghc ] 28 + }: 29 + 30 + let 31 + inherit (stdenv.lib) optional; 32 + wrapper = ./hoogle-local-wrapper.sh; 33 + in 34 + stdenv.mkDerivation { 35 + name = "hoogle-local-0.1"; 36 + buildInputs = [hoogle rehoo]; 37 + 38 + phases = [ "installPhase" ]; 39 + 40 + docPackages = packages; 41 + installPhase = '' 42 + if [ -z "$docPackages" ]; then 43 + echo "ERROR: The packages attribute has not been set" 44 + exit 1 45 + fi 46 + 47 + mkdir -p $out/share/hoogle/doc 48 + export HOOGLE_DOC_PATH=$out/share/hoogle/doc 49 + 50 + cd $out/share/hoogle 51 + 52 + function import_dbs() { 53 + find $1 -name '*.txt' | while read f; do 54 + newname=$(basename "$f" | tr '[:upper:]' '[:lower:]') 55 + if [[ -f $f && ! -f ./$newname ]]; then 56 + cp -p $f ./$newname 57 + hoogle convert -d "$(dirname $f)" "./$newname" 58 + fi 59 + done 60 + } 61 + 62 + for i in $docPackages; do 63 + findInputs $i docPackages propagated-native-build-inputs 64 + findInputs $i docPackages propagated-build-inputs 65 + done 66 + 67 + for i in $docPackages; do 68 + if [[ ! $i == $out ]]; then 69 + for docdir in $i/share/doc/*-ghc-*/* $i/share/doc/*; do 70 + if [[ -d $docdir ]]; then 71 + import_dbs $docdir 72 + ln -sf $docdir $out/share/hoogle/doc 73 + fi 74 + done 75 + fi 76 + done 77 + 78 + import_dbs ${ghc}/share/doc/ghc*/html/libraries 79 + ln -sf ${ghc}/share/doc/ghc*/html/libraries/* $out/share/hoogle/doc 80 + 81 + chmod 644 *.hoo *.txt 82 + rehoo -j4 -c64 . 83 + 84 + rm -fr downloads *.dep *.txt 85 + mv default.hoo x || exit 0 86 + rm -f *.hoo 87 + mv x default.hoo || exit 1 88 + 89 + if [ ! -f default.hoo ]; then 90 + echo "Unable to build the default Hoogle database" 91 + exit 1 92 + fi 93 + 94 + mkdir -p $out/bin 95 + substitute ${wrapper} $out/bin/hoogle \ 96 + --subst-var out --subst-var-by shell ${stdenv.shell} \ 97 + --subst-var-by hoogle ${hoogle} 98 + chmod +x $out/bin/hoogle 99 + ''; 100 + 101 + meta = { 102 + description = "A local Hoogle database"; 103 + platforms = ghc.meta.platforms; 104 + hydraPlatforms = with stdenv.lib.platforms; none; 105 + maintainers = with stdenv.lib.maintainers; [ ttuegel ]; 106 + }; 107 + }
+6
pkgs/development/haskell-modules/lib.nix
··· 79 79 80 80 triggerRebuild = drv: i: overrideCabal drv (drv: { postUnpack = ": trigger rebuild ${toString i}"; }); 81 81 82 + withHoogle = haskellEnv: with haskellEnv.haskellPackages; 83 + import ./hoogle.nix { 84 + inherit (pkgs) stdenv; 85 + inherit hoogle rehoo ghc; 86 + packages = haskellEnv.paths; 87 + }; 82 88 }
+6 -3
pkgs/development/haskell-modules/with-packages-wrapper.nix
··· 1 1 { stdenv, lib, ghc, llvmPackages, packages, buildEnv, makeWrapper 2 2 , ignoreCollisions ? false, withLLVM ? false 3 3 , postBuild ? "" 4 + , haskellPackages 4 5 }: 5 6 6 7 # This wrapper works only with GHC 6.12 or later. ··· 94 95 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"} 95 96 $out/bin/${ghcCommand}-pkg check 96 97 '' + postBuild; 97 - } // { 98 - preferLocalBuild = true; 99 - inherit (ghc) version meta; 98 + passthru = { 99 + preferLocalBuild = true; 100 + inherit (ghc) version meta; 101 + inherit haskellPackages; 102 + }; 100 103 }