From 3bf0d2b9608b6c2da2996b601783f30afd8e6765 Mon Sep 17 00:00:00 2001 From: Patrick John Wheeler Date: Wed, 17 Apr 2013 00:06:10 +0200 Subject: [PATCH] ghc-wrapper: install the GHC documentation into the user's profile The freaky implementation was done that way in order to avoid unnecessary re-builds of all Haskell packages by changing the wrapper script used internally in those builds. See for further details. --- pkgs/development/compilers/ghc/wrapper.nix | 11 +++++++++-- pkgs/top-level/haskell-packages.nix | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/wrapper.nix b/pkgs/development/compilers/ghc/wrapper.nix index bc28fdc91319..55fd16be5edb 100644 --- a/pkgs/development/compilers/ghc/wrapper.nix +++ b/pkgs/development/compilers/ghc/wrapper.nix @@ -1,4 +1,4 @@ -{ stdenv, ghc, makeWrapper, coreutils }: +{ stdenv, ghc, makeWrapper, coreutils, forUserEnv ? false }: let ghc761OrLater = !stdenv.lib.versionOlder ghc.version "7.6.1"; @@ -54,4 +54,11 @@ stdenv.mkDerivation ({ inherit ghc; inherit (ghc) meta; ghcVersion = ghc.version; -} // (stdenv.lib.optionalAttrs ghc761OrLater { preFixup = "sed -i -e 's|-package-conf|${packageDBFlag}|' $out/bin/ghc-get-packages.sh"; })) +} // (stdenv.lib.optionalAttrs ghc761OrLater { preFixup = "sed -i -e 's|-package-conf|${packageDBFlag}|' $out/bin/ghc-get-packages.sh"; }) + // (stdenv.lib.optionalAttrs forUserEnv { + postFixup= '' + ln -s $ghc/lib $out/lib; + mkdir -p $out/share/doc + ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghc.version} + ''; + })) diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 7c6c237b194b..3bf5d3d7f749 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -89,6 +89,16 @@ let result = let callPackage = x : y : modifyPrio (newScope result.final x y); ghc = ghc; # refers to ghcPlain }; + # The normal GHC wrapper doesn't create links to the documentation in + # ~/.nix-profile. Having this second wrapper allows us to remedy the + # situation without re-building all Haskell packages. At the next + # stdenv-updates merge, this second wrapper will go away. + + ghcUserEnvWrapper = pkgs.appendToName "new" (callPackage ../development/compilers/ghc/wrapper.nix { + ghc = ghc; # refers to ghcPlain + forUserEnv = true; + }); + # An experimental wrapper around ghcPlain that does not automatically # pick up packages from the profile, but instead has a fixed set of packages # in its global database. The set of packages can be specified as an