From 176797576ccbc924323598cc1886b4f8c0ad330f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 29 May 2014 20:00:04 -0500 Subject: [PATCH] Build Haddocks with source hyperlinks unless doHscolour is false --- pkgs/build-support/cabal/default.nix | 11 +++++++++-- .../libraries/haskell/unlambda/default.nix | 1 + .../{libraries => tools}/haskell/hscolour/default.nix | 3 ++- pkgs/top-level/haskell-packages.nix | 6 ++++-- 4 files changed, 16 insertions(+), 5 deletions(-) rename pkgs/development/{libraries => tools}/haskell/hscolour/default.nix (85%) diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix index 70fb72f99fb9..c5fdfe71e3b7 100644 --- a/pkgs/build-support/cabal/default.nix +++ b/pkgs/build-support/cabal/default.nix @@ -1,12 +1,13 @@ # generic builder for Cabal packages { stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales -, gnugrep, coreutils +, gnugrep, coreutils, hscolour , enableLibraryProfiling ? false , enableSharedLibraries ? false , enableSharedExecutables ? false , enableStaticLibraries ? true , enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version +, enableHyperlinkSource ? true , extension ? (self : super : {}) }: @@ -50,6 +51,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs; propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs; doCheck = enableCheckPhase && x.doCheck; + hyperlinkSource = enableHyperlinkSource && x.hyperlinkSource; }; defaults = @@ -92,6 +94,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; buildInputs = [ghc Cabal] ++ self.extraBuildInputs; extraBuildInputs = self.buildTools ++ (optionals self.doCheck self.testDepends) ++ + (optional self.hyperlinkSource hscolour) ++ (if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++ (if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends); @@ -140,6 +143,9 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; # and run any regression test suites the package might have doCheck = enableCheckPhase; + # pass the '--hyperlink-source' flag to ./Setup haddock + hyperlinkSource = enableHyperlinkSource; + # abort the build if the configure phase detects that the package # depends on multiple versions of the same build input strictConfigurePhase = true; @@ -219,7 +225,8 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; ./Setup build ${self.buildTarget} export GHC_PACKAGE_PATH=$(${ghc.GHCPackages}) - test -n "$noHaddock" || ./Setup haddock --html --hoogle + test -n "$noHaddock" || ./Setup haddock --html --hoogle \ + ${optionalString self.hyperlinkSource "--hyperlink-source"} eval "$postBuild" ''; diff --git a/pkgs/development/libraries/haskell/unlambda/default.nix b/pkgs/development/libraries/haskell/unlambda/default.nix index 474bb1a8b092..a9e0def2bc70 100644 --- a/pkgs/development/libraries/haskell/unlambda/default.nix +++ b/pkgs/development/libraries/haskell/unlambda/default.nix @@ -7,6 +7,7 @@ cabal.mkDerivation (self: { isLibrary = true; isExecutable = true; buildDepends = [ mtl ]; + hyperlinkSource = false; meta = { description = "Unlambda interpreter"; license = "GPL"; diff --git a/pkgs/development/libraries/haskell/hscolour/default.nix b/pkgs/development/tools/haskell/hscolour/default.nix similarity index 85% rename from pkgs/development/libraries/haskell/hscolour/default.nix rename to pkgs/development/tools/haskell/hscolour/default.nix index d8bc08b4b33c..88c4545ff6d9 100644 --- a/pkgs/development/libraries/haskell/hscolour/default.nix +++ b/pkgs/development/tools/haskell/hscolour/default.nix @@ -1,4 +1,4 @@ -{ cabal }: +{ cabal, hyperlinkSource ? true }: cabal.mkDerivation (self: { pname = "hscolour"; @@ -6,6 +6,7 @@ cabal.mkDerivation (self: { sha256 = "15ix93sw4p7g5ln2halcgqppdc0i0vmkzcjzxvqzkk9yp9pq3nrs"; isLibrary = true; isExecutable = true; + hyperlinkSource = hyperlinkSource; meta = { homepage = "http://code.haskell.org/~malcolm/hscolour/"; description = "Colourise Haskell code"; diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 614a989bb74e..41eca6be8fdb 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -96,6 +96,7 @@ self : let callPackage = x : y : modifyPrio (newScope self x y); in cabal = callPackage ../build-support/cabal { Cabal = null; # prefer the Cabal version shipped with the compiler + hscolour = self.hscolourBootstrap; inherit enableLibraryProfiling enableCheckPhase enableStaticLibraries enableSharedLibraries enableSharedExecutables; glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null; @@ -1117,8 +1118,6 @@ self : let callPackage = x : y : modifyPrio (newScope self x y); in hsBibutils = callPackage ../development/libraries/haskell/hs-bibutils {}; - hscolour = callPackage ../development/libraries/haskell/hscolour {}; - hsdns = callPackage ../development/libraries/haskell/hsdns {}; hsemail = if (pkgs.stdenv.lib.versionOlder ghc.version "7") then null else @@ -2605,6 +2604,9 @@ self : let callPackage = x : y : modifyPrio (newScope self x y); in hlint = callPackage ../development/tools/haskell/hlint {}; + hscolour = callPackage ../development/tools/haskell/hscolour {}; + hscolourBootstrap = self.hscolour.override { hyperlinkSource = false; }; + hslogger = callPackage ../development/tools/haskell/hslogger {}; tar = callPackage ../development/libraries/haskell/tar {};