on iko/ghcjs-patch-master help sign in
Add support for setting ghcOptions on all packages (#1046)
42b1067Hamish Mackenzie
builder/comp-builder.nix+5−4
@@ -40,6 +40,8 @@ let self =
40 && !(stdenv.hostPlatform.isMusl && !stdenv.hostPlatform.isx86)
40 && !(stdenv.hostPlatform.isMusl && !stdenv.hostPlatform.isx86)
41, enableDeadCodeElimination ? component.enableDeadCodeElimination
41, enableDeadCodeElimination ? component.enableDeadCodeElimination
42
42
43+, ghcOptions ? component.ghcOptions
44+
43# Options for Haddock generation
45# Options for Haddock generation
44, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
46, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
45, doHoogle ? component.doHoogle # Also build a hoogle index
47, doHoogle ? component.doHoogle # Also build a hoogle index
@@ -180,10 +182,9 @@ let
180 ++ lib.optionals useLLVM [
182 ++ lib.optionals useLLVM [
181 "--ghc-option=-fPIC" "--gcc-option=-fPIC"
183 "--ghc-option=-fPIC" "--gcc-option=-fPIC"
182 ]
184 ]
185+ ++ map (o: ''--ghc${lib.optionalString (stdenv.hostPlatform.isGhcjs) "js"}-options="${o}"'') ghcOptions
183 );
186 );
184
187
185− setupGhcOptions = lib.optional (package.ghcOptions != null) '' --ghc${lib.optionalString (stdenv.hostPlatform.isGhcjs) "js"}-options="${package.ghcOptions}"'';
186−
187 executableToolDepends =
188 executableToolDepends =
188 (lib.concatMap (c: if c.isHaskell or false
189 (lib.concatMap (c: if c.isHaskell or false
189 then builtins.attrValues (c.components.exes or {})
190 then builtins.attrValues (c.components.exes or {})
@@ -258,7 +259,7 @@ let
258
259
259 haddock = haddockBuilder {
260 haddock = haddockBuilder {
260 inherit componentId component package flags commonConfigureFlags
261 inherit componentId component package flags commonConfigureFlags
261− commonAttrs revision setupGhcOptions doHaddock
262+ commonAttrs revision doHaddock
262 doHoogle hyperlinkSource quickjump setupHaddockFlags
263 doHoogle hyperlinkSource quickjump setupHaddockFlags
263 needsProfiling configFiles preHaddock postHaddock pkgconfig;
264 needsProfiling configFiles preHaddock postHaddock pkgconfig;
264
265
@@ -336,7 +337,7 @@ let
336 buildPhase = ''
337 buildPhase = ''
337 runHook preBuild
338 runHook preBuild
338 # https://gitlab.haskell.org/ghc/ghc/issues/9221
339 # https://gitlab.haskell.org/ghc/ghc/issues/9221
339− $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (setupBuildFlags ++ setupGhcOptions)}
340+ $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " setupBuildFlags}
340 runHook postBuild
341 runHook postBuild
341 '';
342 '';
342
343
builder/haddock-builder.nix+1−2
@@ -16,7 +16,6 @@
16, hyperlinkSource
16, hyperlinkSource
17, quickjump
17, quickjump
18, setupHaddockFlags
18, setupHaddockFlags
19−, setupGhcOptions
20
19
21, needsProfiling
20, needsProfiling
22, componentDrv
21, componentDrv
@@ -108,7 +107,7 @@ let
108 ${lib.optionalString doHoogle "--hoogle"} \
107 ${lib.optionalString doHoogle "--hoogle"} \
109 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
108 ${lib.optionalString hyperlinkSource "--hyperlink-source"} \
110 ${lib.optionalString quickjump "--quickjump"} \
109 ${lib.optionalString quickjump "--quickjump"} \
111− ${lib.concatStringsSep " " (setupHaddockFlags ++ setupGhcOptions)}
110+ ${lib.concatStringsSep " " setupHaddockFlags}
112 }
111 }
113 runHook postHaddock
112 runHook postHaddock
114 '';
113 '';
changelog.md+9
@@ -1,6 +1,15 @@
1This file contains a summary of changes to Haskell.nix and `nix-tools`
1This file contains a summary of changes to Haskell.nix and `nix-tools`
2that will impact users.
2that will impact users.
3
3
4+## Feb 18, 2021
5+* `ghcOptions` has been moved from package and is now a list of strings.
6+ old: packages.x.package.ghcOptions = "someGHCoption";
7+ new: packages.x.ghcOptions = ["someGHCoption"];
8+ To specify ghcOptions for all packages:
9+ ghcOptions = ["someGHCoption"];
10+ For a single component:
11+ packages.x.compoents.library.ghcOptions = ["someGHCoption"];
12+
4## Feb 8, 2021
13## Feb 8, 2021
5* Removed older versions of haskell-language-server from custom-tools
14* Removed older versions of haskell-language-server from custom-tools
6 (0.8.0 is in hackage so we can still get that version).
15 (0.8.0 is in hackage so we can still get that version).
modules/package.nix−5
@@ -136,11 +136,6 @@ in {
136 type = bool;
136 type = bool;
137 default = false;
137 default = false;
138 };
138 };
139−
140− ghcOptions = mkOption {
141− type = nullOr str;
142− default = null;
143− };
144 };
139 };
145
140
146 components = let
141 components = let
modules/plan.nix+4
@@ -229,6 +229,10 @@ let
229 type = listOfFilteringNulls str;
229 type = listOfFilteringNulls str;
230 default = (def.hardeningDisable or []);
230 default = (def.hardeningDisable or []);
231 };
231 };
232+ ghcOptions = mkOption {
233+ type = listOfFilteringNulls str;
234+ default = def.ghcOptions or [];
235+ };
232 };
236 };
233
237
234
238
nix/sources.json+4−4
@@ -66,16 +66,16 @@
66 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
66 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
67 },
67 },
68 "nix-tools": {
68 "nix-tools": {
69− "branch": "master",
69+ "branch": "hkm/global-ghc-options",
70 "builtin": false,
70 "builtin": false,
71 "description": "Translate Cabals Generic Package Description to a Nix expression",
71 "description": "Translate Cabals Generic Package Description to a Nix expression",
72 "homepage": null,
72 "homepage": null,
73 "owner": "input-output-hk",
73 "owner": "input-output-hk",
74 "repo": "nix-tools",
74 "repo": "nix-tools",
75− "rev": "f3148a55adcc9ed1361d524f94f3ccf61e2f1392",
75+ "rev": "16e3fe6ce9204bc8ac37125fb49fff71b53e0051",
76− "sha256": "0796gd2mr3pwsh7rsxljsbh6z1irb2rj7vqhas59z6xbgb8jqif7",
76+ "sha256": "0ks14660mjkhkwjrg748928b40znza7b754kn1srf7rfnw6dscmp",
77 "type": "tarball",
77 "type": "tarball",
78− "url": "https://github.com/input-output-hk/nix-tools/archive/f3148a55adcc9ed1361d524f94f3ccf61e2f1392.tar.gz",
78+ "url": "https://github.com/input-output-hk/nix-tools/archive/16e3fe6ce9204bc8ac37125fb49fff71b53e0051.tar.gz",
79 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
79 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
80 },
80 },
81 "nixpkgs": {
81 "nixpkgs": {
overlays/bootstrap.nix+2
@@ -588,6 +588,8 @@ in {
588 final.haskell-nix.cabalProject ({
588 final.haskell-nix.cabalProject ({
589 name = "nix-tools";
589 name = "nix-tools";
590 src = final.haskell-nix.sources.nix-tools;
590 src = final.haskell-nix.sources.nix-tools;
591+ # This is a handy way to use a local git clone of nix-tools when developing
592+ # src = final.haskell-nix.haskellLib.cleanGit { name = "nix-tools"; src = ../../nix-tools; };
591 index-state = final.haskell-nix.internalHackageIndexState;
593 index-state = final.haskell-nix.internalHackageIndexState;
592 cabalProjectLocal = ''
594 cabalProjectLocal = ''
593 allow-newer: Cabal:base, cryptohash-sha512:base, haskeline:base
595 allow-newer: Cabal:base, cryptohash-sha512:base, haskeline:base
test/ghc-options/cabal.nix+9−1
@@ -8,7 +8,15 @@ let
8 index-state = "2020-05-25T00:00:00Z";
8 index-state = "2020-05-25T00:00:00Z";
9 src = testSrc "ghc-options";
9 src = testSrc "ghc-options";
10 # TODO find a way to get the ghc-options into plan.json so we can use it in plan-to-nix
10 # TODO find a way to get the ghc-options into plan.json so we can use it in plan-to-nix
11+ modules = [ {
12+ packages.test-ghc-options.ghcOptions = ["-DTEST_GHC_OPTION"];
13+
14+ # This should also work here
15+ # ghcOptions = ["-DTEST_GHC_OPTION"];
16+ # or this
11− modules = [ { packages.test-ghc-options.package.ghcOptions = "-DTEST_GHC_OPTION"; } ];
17+ # packages.test-ghc-options.components.library.ghcOptions = ["-DTEST_GHC_OPTION"];
18+ # packages.test-ghc-options.components.exes.test-ghc-options-exe.ghcOptions = ["-DTEST_GHC_OPTION"];
19+ } ];
12 };
20 };
13 packages = project.hsPkgs;
21 packages = project.hsPkgs;
14
22