on iko/ghcjs-patch-master help sign in
Give more control over the compilation of Setup.hs (#277)
e15c59bHamish Mackenzie
builder/default.nix+1
@@ -9,6 +9,7 @@ let
9 setup-builder = haskellLib.weakCallPackage pkgs ./setup-builder.nix {
9 setup-builder = haskellLib.weakCallPackage pkgs ./setup-builder.nix {
10 ghc = (ghc.passthru.buildGHC or ghc);
10 ghc = (ghc.passthru.buildGHC or ghc);
11 hsPkgs = hsPkgs.buildPackages;
11 hsPkgs = hsPkgs.buildPackages;
12+ inherit buildPackages pkgconfig;
12 inherit haskellLib nonReinstallablePkgs makeSetupConfigFiles;
13 inherit haskellLib nonReinstallablePkgs makeSetupConfigFiles;
13 };
14 };
14
15
builder/hspkg-builder.nix+4−1
@@ -39,7 +39,10 @@ let
39 setup = if package.buildType == "Simple" && package.setup-depends == []
39 setup = if package.buildType == "Simple" && package.setup-depends == []
40 then defaultSetup
40 then defaultSetup
41 else setup-builder {
41 else setup-builder {
42+ component = components.setup // {
42− setup-depends = package.setup-depends;
43+ depends = components.setup.depends ++ package.setup-depends;
44+ extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
45+ };
43 inherit package name src flags revision patches defaultSetupSrc;
46 inherit package name src flags revision patches defaultSetupSrc;
44 inherit (config) preUnpack postUnpack;
47 inherit (config) preUnpack postUnpack;
45 };
48 };
builder/setup-builder.nix+13−22
@@ -1,33 +1,15 @@
1−{ stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles }:
1+{ stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles, pkgconfig }:
2
2
3−{ setup-depends, package, name, src, flags, revision, patches, defaultSetupSrc
3+{ component, package, name, src, flags, revision, patches, defaultSetupSrc
4, preUnpack ? null, postUnpack ? null
4, preUnpack ? null, postUnpack ? null
5}:
5}:
6
6
7let
7let
8− component = {
9− depends = setup-depends;
10− libs = [];
11− frameworks = [];
12− doExactConfig = false;
13− # We have to set hsSourceDirs or cleanCabalComponent will
14− # include everything (and as a result all the components of
15− # the package will depend on eveything in the package).
16− # TODO find a better way
17− hsSourceDirs = ["setup-src"];
18− includeDirs = [];
19− asmSources = [];
20− cSources = [];
21− cmmSources = [];
22− cxxSources = [];
23− jsSources = [];
24− extraSrcFiles = [ "Setup.hs" "Setup.lhs" ];
25− };
26 cleanSrc = haskellLib.cleanCabalComponent package component src;
8 cleanSrc = haskellLib.cleanCabalComponent package component src;
27
9
28 fullName = "${name}-setup";
10 fullName = "${name}-setup";
29
11
30− includeGhcPackage = lib.any (p: p.identifier.name == "ghc") setup-depends;
12+ includeGhcPackage = lib.any (p: p.identifier.name == "ghc") component.depends;
31
13
32 configFiles = makeSetupConfigFiles {
14 configFiles = makeSetupConfigFiles {
33 inherit (package) identifier;
15 inherit (package) identifier;
@@ -37,12 +19,21 @@ let
37 inherit preUnpack postUnpack;
19 inherit preUnpack postUnpack;
38 };
20 };
39
21
22+ executableToolDepends =
23+ (lib.concatMap (c: if c.isHaskell or false
24+ then builtins.attrValues (c.components.exes or {})
25+ else [c]) component.build-tools) ++
26+ lib.optional (component.pkgconfig != []) pkgconfig;
27+
40in
28in
41 stdenv.lib.fix (drv:
29 stdenv.lib.fix (drv:
42 stdenv.mkDerivation ({
30 stdenv.mkDerivation ({
43 name = "${fullName}";
31 name = "${fullName}";
44 src = cleanSrc;
32 src = cleanSrc;
33+ buildInputs = component.libs
34+ ++ component.frameworks
35+ ++ builtins.concatLists component.pkgconfig;
45− nativeBuildInputs = [ghc];
36+ nativeBuildInputs = [ghc] ++ executableToolDepends;
46
37
47 passthru = {
38 passthru = {
48 inherit (package) identifier;
39 inherit (package) identifier;
modules/package.nix+21
@@ -213,6 +213,27 @@ in {
213 };
213 };
214 };
214 };
215 in {
215 in {
216+ setup = mkOption {
217+ type = nullOr componentType;
218+ default = {
219+ depends = [];
220+ libs = [];
221+ frameworks = [];
222+ doExactConfig = false;
223+ # We have to set hsSourceDirs or cleanCabalComponent will
224+ # include everything (and as a result all the components of
225+ # the package will depend on eveything in the package).
226+ # TODO find a better way
227+ hsSourceDirs = ["setup-src"];
228+ includeDirs = [];
229+ asmSources = [];
230+ cSources = [];
231+ cmmSources = [];
232+ cxxSources = [];
233+ jsSources = [];
234+ extraSrcFiles = [ "Setup.hs" "Setup.lhs" ];
235+ };
236+ };
216 library = mkOption {
237 library = mkOption {
217 type = nullOr componentType;
238 type = nullOr componentType;
218 default = null;
239 default = null;