diff options
Diffstat (limited to 'pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r-- | pkgs/development/haskell-modules/generic-builder.nix | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index a6fd7bb0ba9..a8d530516a5 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -73,6 +73,7 @@ in , coreSetup ? false # Use only core packages to build Setup.hs. , useCpphs ? false , hardeningDisable ? stdenv.lib.optional (ghc.isHaLVM or false) "all" +, enableSeparateBinOutput ? false , enableSeparateDataOutput ? false , enableSeparateDocOutput ? doHaddock , # Don't fail at configure time if there are multiple versions of the @@ -80,6 +81,10 @@ in # built. Will delay failures, if any, to compile time. allowInconsistentDependencies ? false , maxBuildCores ? 4 # GHC usually suffers beyond -j4. https://ghc.haskell.org/trac/ghc/ticket/9221 +, # Build a pre-linked .o file for this Haskell library. This can make it + # slightly faster to load this library into GHCi, but takes extra disk space + # and compile time. + enableLibraryForGhci ? true } @ args: assert editedCabalFile != null -> revision != null; @@ -111,6 +116,8 @@ let # the target dir for haddock documentation docdir = docoutput: docoutput + "/share/doc/" + pname + "-" + version; + binDir = if enableSeparateBinOutput then "$bin/bin" else "$out/bin"; + newCabalFileUrl = "http://hackage.haskell.org/package/${pname}-${version}/revision/${revision}.cabal"; newCabalFile = fetchurl { url = newCabalFileUrl; @@ -143,7 +150,10 @@ let buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags); defaultConfigureFlags = [ - "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$abi/\\$libname" + "--verbose" + "--prefix=$out" + "--libdir=\\$prefix/lib/\\$compiler" + "--libsubdir=\\$abi/\\$libname" (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}") "--with-gcc=$CC" # Clang won't work without that extra information. @@ -163,7 +173,7 @@ let (optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests")) (enableFeature doBenchmark "benchmarks") "--enable-library-vanilla" # TODO: Should this be configurable? - "--enable-library-for-ghci" # TODO: Should this be configurable? + (enableFeature enableLibraryForGhci "library-for-ghci") ] ++ optionals (enableDeadCodeElimination && (stdenv.lib.versionOlder "8.0.1" ghc.version)) [ "--ghc-option=-split-sections" ] ++ optionals dontStrip [ @@ -173,7 +183,8 @@ let "--ghcjs" ] ++ optionals isCross ([ "--configure-option=--host=${stdenv.hostPlatform.config}" - ] ++ crossCabalFlags); + ] ++ crossCabalFlags + ) ++ optionals enableSeparateBinOutput ["--bindir=${binDir}"]; setupCompileFlags = [ (optionalString (!coreSetup) "-${nativePackageDbFlag}=$setupPackageConfDir") @@ -233,7 +244,10 @@ assert allPkgconfigDepends != [] -> pkgconfig != null; stdenv.mkDerivation ({ name = "${pname}-${version}"; - outputs = [ "out" ] ++ (optional enableSeparateDataOutput "data") ++ (optional enableSeparateDocOutput "doc"); + outputs = [ "out" ] + ++ (optional enableSeparateDataOutput "data") + ++ (optional enableSeparateDocOutput "doc") + ++ (optional enableSeparateBinOutput "bin"); setOutputFlags = false; pos = builtins.unsafeGetAttrPos "pname" args; @@ -414,7 +428,7 @@ stdenv.mkDerivation ({ find $packageConfDir -maxdepth 0 -empty -delete; ''} ${optionalString isGhcjs '' - for exeDir in "$out/bin/"*.jsexe; do + for exeDir in "${binDir}/"*.jsexe; do exe="''${exeDir%.jsexe}" printWords '#!${nodejs}/bin/node' > "$exe" echo >> "$exe" @@ -424,7 +438,7 @@ stdenv.mkDerivation ({ ''} ${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"} ${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && stdenv.lib.versionOlder ghc.version "7.10") '' - for exe in "$out/bin/"* ; do + for exe in "${binDir}/"* ; do install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe" done ''} |