diff options
author | Nikolay Amiantov <ab@fmap.me> | 2015-03-09 22:11:23 +0300 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2015-03-26 11:29:05 +0100 |
commit | 49f3c375b50eea5f7e3bc59c7ee687fb507edf2e (patch) | |
tree | 21518bc85057167243eef683684e4dbc546998f9 /pkgs/development/haskell-modules/with-packages-wrapper.nix | |
parent | 1368206eb8463dffee6a3c43fdf7ee12ca0aa468 (diff) | |
download | nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.gz nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.bz2 nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.lz nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.xz nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.zst nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.zip |
ghcWithPackages: add withLLVM
Diffstat (limited to 'pkgs/development/haskell-modules/with-packages-wrapper.nix')
-rw-r--r-- | pkgs/development/haskell-modules/with-packages-wrapper.nix | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix index 763164cec876..b2071fa61c0f 100644 --- a/pkgs/development/haskell-modules/with-packages-wrapper.nix +++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix @@ -1,7 +1,11 @@ -{ stdenv, ghc, packages, buildEnv, makeWrapper, ignoreCollisions ? false }: +{ stdenv, ghc, llvmPackages, packages, buildEnv +, makeWrapper +, ignoreCollisions ? false, withLLVM ? false }: + +with stdenv.lib; # This wrapper works only with GHC 6.12 or later. -assert stdenv.lib.versionOlder "6.12" ghc.version; +assert versionOlder "6.12" ghc.version; # It's probably a good idea to include the library "ghc-paths" in the # compiler environment, because we have a specially patched version of @@ -25,15 +29,20 @@ assert stdenv.lib.versionOlder "6.12" ghc.version; # fi let - ghc761OrLater = stdenv.lib.versionOlder "7.6.1" ghc.version; + ghc761OrLater = versionOlder "7.6.1" ghc.version; packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf"; libDir = "$out/lib/ghc-${ghc.version}"; docDir = "$out/share/doc/ghc/html"; packageCfgDir = "${libDir}/package.conf.d"; - paths = stdenv.lib.filter (x: x ? isHaskellLibrary) (stdenv.lib.closePropagation packages); - hasLibraries = stdenv.lib.any (x: x.isHaskellLibrary) paths; + paths = filter (x: x ? isHaskellLibrary) (closePropagation packages); + hasLibraries = any (x: x.isHaskellLibrary) paths; + # CLang is needed on Darwin for -fllvm to work: + # https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/code-generators.html + llvm = makeSearchPath "bin" + ([ llvmPackages.llvm ] + ++ optional stdenv.isDarwin llvmPackages.clang); in -if paths == [] then ghc else +if paths == [] && !withLLVM then ghc else buildEnv { inherit (ghc) name; paths = paths ++ [ghc]; @@ -55,7 +64,8 @@ buildEnv { --set "NIX_GHC" "$out/bin/ghc" \ --set "NIX_GHCPKG" "$out/bin/ghc-pkg" \ --set "NIX_GHC_DOCDIR" "${docDir}" \ - --set "NIX_GHC_LIBDIR" "${libDir}" + --set "NIX_GHC_LIBDIR" "${libDir}" \ + ${optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''} done for prg in runghc runhaskell; do @@ -73,7 +83,7 @@ buildEnv { makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}" done - ${stdenv.lib.optionalString hasLibraries "$out/bin/ghc-pkg recache"} + ${optionalString hasLibraries "$out/bin/ghc-pkg recache"} $out/bin/ghc-pkg check ''; } // { |