Skip to content

Commit

Permalink
Add function to build a ghc standalone archive (OSX/iOS only)
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy committed Jan 23, 2017
1 parent e026568 commit 4f9f00f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkgs/development/compilers/ghc/head.nix
Expand Up @@ -85,8 +85,17 @@ in stdenv.mkDerivation (rec {
} // stdenv.lib.optionalAttrs (cross != null) {
name = "${cross.config}-ghc-${version}";

patches = [ ./ios-linker.patch ];

preConfigure = commonPreConfigure + ''
sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk
sed 's|#BuildFlavour = quick-cross|BuildFlavour = quick-cross|' mk/build.mk.sample > mk/build.mk
echo "GhcRtsCcOpts = -glldb -Og" >> mk/build.mk
'';

postUnpack = ''
mkdir -p $out/nix-support
mv $sourceRoot $out/nix-support/source
sourceRoot=$out/nix-support/source
'';

configureFlags = [
Expand All @@ -103,6 +112,8 @@ in stdenv.mkDerivation (rec {

dontSetConfigureCross = true;

dontStrip = true;

passthru = {
inherit bootPkgs cross;

Expand Down
14 changes: 14 additions & 0 deletions pkgs/os-specific/darwin/ghc-standalone-archive/default.nix
@@ -0,0 +1,14 @@
{ runCommand, cctools }:
{ haskellPackages, src, deps ? p : [], name }: let
inherit (haskellPackages) ghc ghcWithPackages;
with-env = ghcWithPackages deps;
crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
ghcName = "${crossPrefix}ghc";
in runCommand name { buildInputs = [ with-env cctools ]; } ''
mkdir -p $out/lib
mkdir -p $out/include
${ghcName} ${src} -staticlib -outputdir . -o $out/lib/${name}.a -stubdir $out/include
for file in ${ghc}/lib/${ghcName}-${ghc.version}/include/*; do
ln -sv $file $out/include
done
''
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -18042,4 +18042,6 @@ in
simplenote = callPackage ../applications/misc/simplenote { };

hy = callPackage ../development/interpreters/hy {};

ghc-standalone-archive = callPackage ../os-specific/darwin/ghc-standalone-archive { inherit (darwin) cctools; };
}

0 comments on commit 4f9f00f

Please sign in to comment.