haskell.nix/builder/hspkg-builder.nix
Hamish Mackenzie 46fad81954 Considerate/overlays fixes (#262)
* Fix loadArchive clang++ error on macOS

GHC 8.6.4 introduced an issue where linking to `-libc++` will cause
GHC to resolve the library path to `c++` which in turn is a link to
clang++. This results in the following error:

```
ghc: loadArchive: Neither an archive, nor a fat archive: `/nix/store/?-clang-wrapper-5.0.2/bin/clang++'

<no location info>: error:
    loadArchive "/nix/store/?-clang-wrapper-5.0.2/bin/clang++": failed
```

The provided patch reverts the linking behavior of GHC to not resolve
`-libc++` to `c++`.

* Propagate unpack hooks to setup
2019-10-22 17:15:10 +08:00

59 lines
1.5 KiB
Nix

{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, fetchurl, runCommand, comp-builder, setup-builder }:
{ flags
, package
, components
, cabal-generator
, name
, sha256
, src
, revision
, revisionSha256
, patches
, shellHook
, ...
}@config:
let
cabalFile = if revision == null || revision == 0 then null else
fetchurl {
name = "${name}-${toString revision}.cabal";
url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal";
sha256 = revisionSha256;
};
defaultSetupSrc = builtins.toFile "Setup.hs" ''
import Distribution.Simple
main = defaultMain
'';
defaultSetup = buildPackages.runCommand "default-Setup" { nativeBuildInputs = [(ghc.passthru.buildGHC or ghc)]; } ''
cat ${defaultSetupSrc} > Setup.hs
mkdir -p $out/bin
${(ghc.passthru.buildGHC or ghc).targetPrefix}ghc Setup.hs --make -o $out/bin/Setup
'';
setup = if package.buildType == "Simple" && package.setup-depends == []
then defaultSetup
else setup-builder {
setup-depends = package.setup-depends;
inherit package name src flags revision patches defaultSetupSrc;
inherit (config) preUnpack postUnpack;
};
buildComp = componentId: component: comp-builder {
inherit componentId component package name src flags setup cabalFile cabal-generator patches revision
shellHook
;
};
in {
components = haskellLib.applyComponents buildComp config;
inherit (package) identifier detailLevel isLocal;
inherit setup cabalFile;
isHaskell = true;
}