Files
haskell.nix/builder/setup-builder.nix
T
Hamish Mackenzie efab350c0f Fix setup-depends dependencies (#124)
* Use setup-depends from nix-tools output

* Use `-package ghc` when building Setup.hs

* Include --package-db when building Setup

* Fix for tests on case insensitive FS (macOS)

The file `conduit.hs` looks like `Conduit.hs` to ghc and it uses it
by mistake for `import Conduit`.
2019-07-12 21:48:13 +08:00

47 lines
1.2 KiB
Nix

{ stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles }:
{ setup-depends, package, name, src, flags }:
let
fullName = "${name}-setup";
includeGhcPackage = lib.any (p: p.identifier.name == "ghc") setup-depends;
configFiles = makeSetupConfigFiles {
inherit (package) identifier;
inherit fullName flags;
component = {
depends = setup-depends;
libs = [];
frameworks = [];
doExactConfig = false;
};
};
in
stdenv.lib.fix (drv:
stdenv.mkDerivation {
name = "${fullName}";
inherit src;
nativeBuildInputs = [ghc];
CABAL_CONFIG = configFiles + /cabal.config;
phases = ["unpackPhase" "buildPhase" "installPhase"];
buildPhase = ''
for f in Setup.hs Setup.lhs; do
if [ -f $f ]; then
echo Compiling package $f
ghc $f '' + (if includeGhcPackage then "-package ghc " else "")
+ ''-package-db ${configFiles}/package.conf.d --make -o ./Setup
setup=$(pwd)/Setup
fi
done
[ -f ./Setup ] || (echo Failed to build Setup && exit 1)
'';
installPhase = ''
mkdir -p $out/bin
install ./Setup $out/bin/Setup
'';
})