on iko/ghcjs-patch-master help sign in
Move all of haskell.nix into `haskell-nix` (#289)

Currently the haskell.nix overlays replace `haskell` and `haskellPackages` in the root of pkgs with versions that have just a fraction of what nixpkgs provides. Although `haskell-nix.haskellPackages` could be used to provide a much more complete set there are subtle differences that are likely to cause issues (and nixpkgs has patches for many haskell packages). To make it possible for haskell.nix and nixpkgs haskell to coexist, we need to move the remaining parts of haskell.nix outside of the `haskell-nix` attribute into `haskell-nix`. ``` ghc -> haskell-nix.ghc cabal-install -> haskell-nix.cabal-install haskell.compiler -> haskell-nix.compiler haskell.packages -> haskell-nix.packages bootstrap.haskell.compiler -> haskell-nix.bootstrap.compiler bootstrap.haskell.packages -> haskell-nix.bootstrap.packages ``` The following `haskellPackages` have been removed and instead the nixpkgs versions will now be in `haskellPackages`. User code should be updated if the nixpkgs versions are not desired: ``` haskellPackages.hoogle -> haskell-nix.haskellPackages.hoogle.components.exes.hoogle haskellPackages.happy -> haskell-nix.haskellPackages.happy.components.exes.happy haskellPackages.alex -> haskell-nix.haskellPackages.alex.components.exes.alex; ``` Guard code has been added to overlays/defaults.nix to prevent us inadvertently depending on the nixpkgs `haskell` or `haskellPackages` inside the haskell.nix code base.

commit612e983daaa0ddb296963981d4d5be09c330ea2f authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateTue 5 Nov 2019, 12:50 (7 years ago) parentfe5c3a2
13 files changed+95−100
README.org+1−1 builder/default.nix+2−1 ci.nix+3−3 docs/user-guide.md+1−1 docs/user-guide/cabal-projects.md+1−1 modules/hackage.nix+2−2 overlays/bootstrap.nix+64−75 overlays/default.nix+5 overlays/ghc-packages.nix+4−4 overlays/ghc.nix+3−3 overlays/haskell.nix+7−7 test/fully-static/default.nix+1−1 test/regen.nix+1−1
README.org+1−1
@@ -25,7 +25,7 @@ For =cabal.project= project add a =default.nix=:
2525}:
2626 pkgs.haskell-nix.cabalProject {
2727 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
28− ghc = pkgs.buildPackages.pkgs.haskell.compiler.${haskellCompiler};
28+ ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
2929 }
3030#+end_src
3131
builder/default.nix+2−1
@@ -35,8 +35,9 @@ let
3535
3636 hoogleLocal = let
3737 nixpkgsHoogleLocal = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
38− in { packages ? [], hoogle ? pkgs.haskellPackages.hoogle }:
38+ in { packages ? [], hoogle ? pkgs.haskell-nix.haskellPackages.hoogle.components.exes.hoogle }:
3939 haskellLib.weakCallPackage pkgs nixpkgsHoogleLocal {
40+ ghc = pkgs.haskell-nix.ghc;
4041 inherit packages hoogle;
4142 };
4243
ci.nix+3−3
@@ -46,11 +46,11 @@ in
4646 (ghc-extra-packages.ghc865.remote-iserv.components.exes).remote-iserv;
4747
4848 };
49− haskell.compiler = {
49+ haskell-nix.compiler = {
5050 x86_64-linux = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
51− haskell.compiler;
51+ haskell-nix.compiler;
5252 x86_64-darwin = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin";}));
53− haskell.compiler;
53+ haskell-nix.compiler;
5454 };
5555 tests = {
5656 x86_64-linux = (import ./test { nixpkgs = nixpkgsSrc; nixpkgsArgs = { system = "x86_64-linux"; }; });
docs/user-guide.md+1−1
@@ -90,7 +90,7 @@ If your project has a `cabal.project` you can add a `default.nix` like this:
9090}:
9191 pkgs.haskell-nix.cabalProject {
9292 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
93− ghc = pkgs.buildPackages.pkgs.haskell.compiler.${haskellCompiler};
93+ ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
9494 # pkg-def-extras = [
9595 # # Additional packages ontop of all those listed in `cabal.project`
9696 # ];
docs/user-guide/cabal-projects.md+1−1
@@ -31,7 +31,7 @@ If all goes well, you should now have the file
3131
3232!!! tip "Specifying the GHC version"
3333 To use a specific compiler version, replace `haskellPackages.ghc`
34− with something like `haskell.compiler.ghc865`. The given compiler
34+ with something like `haskell-nix.compiler.ghc865`. The given compiler
3535 must exist in your Nixpkgs version, of course. See also the
3636 [Nixpkgs Manual][compiler].
3737
modules/hackage.nix+2−2
@@ -66,13 +66,13 @@ in {
6666 # this should allow us to use `config` overrides
6767 # in the nixpkgs setup, and properly override the
6868 # complier as needed.
69− default = pkgs.buildPackages.haskell.compiler.${config.compiler.nix-name} or (throw ''
69+ default = pkgs.buildPackages.haskell-nix.compiler.${config.compiler.nix-name} or (throw ''
7070 This version of Nixpkgs does not contain GHC ${config.compiler.version}
7171 (or it is not present at attribute '${config.compiler.nix-name})').
7272 Either switch to a version of Nixpkgs which does have this version, or use a version
7373 of GHC which the current version of Nixpkgs contains.
7474 '');
75− defaultText = "pkgs.buildPackages.haskell.compiler.\${config.compiler.nix-name}";
75+ defaultText = "pkgs.buildPackages.haskell-nix.compiler.\${config.compiler.nix-name}";
7676 };
7777
7878 options.hackage.db = lib.mkOption {
overlays/bootstrap.nix+64−75
@@ -1,9 +1,10 @@
1−self: super: rec {
1+self: super: {
2+ haskell-nix = super.haskell-nix // rec {
23 # Use this to disable the existing haskell infra structure for testing purposes
3− haskell.compiler =
4+ compiler =
45 let bootPkgs = with self.buildPackages; {
5− ghc = buildPackages.bootstrap.haskell.compiler.ghc844;
6− inherit (bootstrap.haskell.packages) alex happy hscolour;
6+ ghc = buildPackages.haskell-nix.bootstrap.compiler.ghc844;
7+ inherit (bootstrap.packages) alex happy hscolour;
78 };
89 sphinx = with self.buildPackages; (python3Packages.sphinx_1_7_9 or python3Packages.sphinx);
910 hsc2hs-align-conditionals-patch = self.fetchpatch {
@@ -70,7 +71,7 @@ self: super: rec {
7071 ;
7172 in ({
7273 ghc844 = self.callPackage ../compiler/ghc {
73− extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc844; };
74+ extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc844; };
7475
7576 inherit bootPkgs sphinx;
7677
@@ -88,7 +89,7 @@ self: super: rec {
8889 ++ self.lib.optional self.stdenv.isDarwin ./patches/ghc/ghc-8.4.4-backport-dylib-command-size-limit.patch;
8990 };
9091 ghc861 = self.callPackage ../compiler/ghc {
91− extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc861; };
92+ extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc861; };
9293
9394 inherit bootPkgs sphinx;
9495
@@ -104,7 +105,7 @@ self: super: rec {
104105 ghc-patches = [ D5123-patch ];
105106 };
106107 ghc862 = self.callPackage ../compiler/ghc {
107− extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc862; };
108+ extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc862; };
108109
109110 inherit bootPkgs sphinx;
110111
@@ -121,7 +122,7 @@ self: super: rec {
121122 ++ [ D5123-patch ];
122123 };
123124 ghc863 = self.callPackage ../compiler/ghc {
124− extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc863; };
125+ extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc863; };
125126
126127 inherit bootPkgs sphinx;
127128
@@ -138,7 +139,7 @@ self: super: rec {
138139 ++ [ D5123-patch ];
139140 };
140141 ghc864 = self.callPackage ../compiler/ghc {
141− extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc864; };
142+ extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc864; };
142143
143144 inherit bootPkgs sphinx;
144145
@@ -155,7 +156,7 @@ self: super: rec {
155156 ++ [ D5123-patch ];
156157 };
157158 ghc865 = self.callPackage ../compiler/ghc {
158− extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc865; };
159+ extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc865; };
159160
160161 inherit bootPkgs sphinx;
161162
@@ -175,7 +176,7 @@ self: super: rec {
175176 ghc865 = let ghcjs865 = self.callPackage ../compiler/ghcjs/ghcjs.nix {
176177 ghcjsSrcJson = ../compiler/ghcjs/ghcjs-src.json;
177178 ghcjsVersion = "8.6.0.1";
178− ghc = self.buildPackages.haskell.compiler.ghc865;
179+ ghc = self.buildPackages.haskell-nix.compiler.ghc865;
179180 }; in let targetPrefix = "js-unknown-ghcjs-"; in self.runCommand "${targetPrefix}ghc-8.6.5" {
180181 passthru = {
181182 inherit targetPrefix;
@@ -194,14 +195,8 @@ self: super: rec {
194195 '';
195196 });
196197
197− ghc = haskell.compiler.ghc865;
198− cabal-install = self.buildPackages.bootstrap.haskell.packages.cabal-install;
199−
200− # see below
201− haskellPackages.hpack = null;
202− haskellPackages.hoogle = self.haskell-nix.haskellPackages.hoogle.components.exes.hoogle;
203− haskellPackages.happy = self.haskell-nix.haskellPackages.happy.components.exes.happy;
204− haskellPackages.alex = self.haskell-nix.haskellPackages.alex.components.exes.alex;
198+ ghc = compiler.ghc865;
199+ cabal-install = self.buildPackages.haskell-nix.bootstrap.packages.cabal-install;
205200
206201 # WARN: The `import ../. {}` will prevent
207202 # any cross to work, as we will loose
@@ -215,11 +210,6 @@ self: super: rec {
215210 # }).components.exes.hello;
216211 # };
217212
218− # stub out lib stuff.
219− haskell.lib = {
220− justStaticExecutables = x: x;
221− };
222−
223213 # NOTE: 8.6.5 prebuilt binaries on macOS, will yield:
224214 #
225215 # > Linking dist/build/cabal/cabal ...
@@ -234,63 +224,62 @@ self: super: rec {
234224
235225
236226 # the bootstrap infra structure (pre-compiled ghc; bootstrapped cabal-install, ...)
237− bootstrap = {
227+ bootstrap = with self.haskell-nix; let ghc = self.buildPackages.haskell-nix.bootstrap.compiler.ghc844; in {
238228 # XXX: import ../. will throw away all other overlays, config values, ...
239229 # this is not ideal!
240− haskell = with self.haskell-nix; let ghc = self.buildPackages.bootstrap.haskell.compiler.ghc844; in {
241− # get binary compilers for bootstrapping. We'll put the eventual proper
242− # compilers into the same place where nix expects them.
243− compiler = import ../compiler/old-ghc-nix { pkgs = self; };
244−
245− packages = {
246− # cabal has it's own bootstrap script which we'll use.
247− cabal-install = import ../compiler/bootstrap/cabal-install.nix {
248− inherit (self) fetchurl stdenv zlib;
249− inherit hackage ghc;
250− src = self.fetchurl {
251− url = "https://github.com/haskell/cabal/archive/Cabal-v3.0.0.0-rc3.tar.gz";
252− sha256 = "1zl2mgg8307ykq3v8nmafc6zdhhj1cw7w8ffpap16dsm65lbnx33";
253− };
254− version = "3.0.0.0";
230+ # get binary compilers for bootstrapping. We'll put the eventual proper
231+ # compilers into the same place where nix expects them.
232+ compiler = import ../compiler/old-ghc-nix { pkgs = self; };
233+
234+ packages = {
235+ # cabal has it's own bootstrap script which we'll use.
236+ cabal-install = import ../compiler/bootstrap/cabal-install.nix {
237+ inherit (self) fetchurl stdenv zlib;
238+ inherit hackage ghc;
239+ src = self.fetchurl {
240+ url = "https://github.com/haskell/cabal/archive/Cabal-v3.0.0.0-rc3.tar.gz";
241+ sha256 = "1zl2mgg8307ykq3v8nmafc6zdhhj1cw7w8ffpap16dsm65lbnx33";
255242 };
243+ version = "3.0.0.0";
244+ };
256245
257− # disable hpack support during bootstrap
258− hpack = null;
259− nix-tools = nix-tools.override {
260− inherit ghc;
261− inherit (bootstrap.haskell.packages) hpack;
262− };
246+ # disable hpack support during bootstrap
247+ hpack = null;
248+ nix-tools = nix-tools.override {
249+ inherit ghc;
250+ inherit (bootstrap.packages) hpack;
251+ };
263252
264− # now that we have nix-tools and hpack, we can just
265− # use `hackage-package` to build any package from
266− # hackage with haskell.nix. For alex and happy we
267− # need to use the boot strap compiler as we need them
268− # to build ghcs from source.
269− alex-project = hackage-project {
270− inherit ghc;
271− inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
272− name = "alex"; version = "3.2.4";
273− index-state = "2019-10-20T00:00:00Z";
274− plan-sha256 = "086kd6aa5bir3y4aqb1wl5zkj6agz5q4wp4snvdnf6cidz5wra06";
275− };
276− alex = bootstrap.haskell.packages.alex-project.alex.components.exes.alex;
277− happy-project = hackage-project {
278− inherit ghc;
279− inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
280− name = "happy"; version = "1.19.11";
281− index-state = "2019-10-20T00:00:00Z";
282− plan-sha256 = "011bxlxdv239psgi80j00km2wcgb68j16sz3fng67d03sqf5i37w";
283− };
284− happy = bootstrap.haskell.packages.happy-project.happy.components.exes.happy;
285− hscolour-project = hackage-project {
286− inherit ghc;
287− inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
288− name = "hscolour"; version = "1.24.4";
289− index-state = "2019-10-20T00:00:00Z";
290− plan-sha256 = "021rwcmkshibc3mfr833ay5hfr19kq6k32lxyrrb6vp9vmihgw4b";
291− };
292− hscolour = bootstrap.haskell.packages.hscolour-project.hscolour.components.exes.HsColour;
253+ # now that we have nix-tools and hpack, we can just
254+ # use `hackage-package` to build any package from
255+ # hackage with haskell.nix. For alex and happy we
256+ # need to use the boot strap compiler as we need them
257+ # to build ghcs from source.
258+ alex-project = hackage-project {
259+ inherit ghc;
260+ inherit (bootstrap.packages) cabal-install nix-tools hpack;
261+ name = "alex"; version = "3.2.4";
262+ index-state = "2019-10-20T00:00:00Z";
263+ plan-sha256 = "086kd6aa5bir3y4aqb1wl5zkj6agz5q4wp4snvdnf6cidz5wra06";
264+ };
265+ alex = bootstrap.packages.alex-project.alex.components.exes.alex;
266+ happy-project = hackage-project {
267+ inherit ghc;
268+ inherit (bootstrap.packages) cabal-install nix-tools hpack;
269+ name = "happy"; version = "1.19.11";
270+ index-state = "2019-10-20T00:00:00Z";
271+ plan-sha256 = "011bxlxdv239psgi80j00km2wcgb68j16sz3fng67d03sqf5i37w";
272+ };
273+ happy = bootstrap.packages.happy-project.happy.components.exes.happy;
274+ hscolour-project = hackage-project {
275+ inherit ghc;
276+ inherit (bootstrap.packages) cabal-install nix-tools hpack;
277+ name = "hscolour"; version = "1.24.4";
278+ index-state = "2019-10-20T00:00:00Z";
279+ plan-sha256 = "021rwcmkshibc3mfr833ay5hfr19kq6k32lxyrrb6vp9vmihgw4b";
293280 };
281+ hscolour = bootstrap.packages.hscolour-project.hscolour.components.exes.HsColour;
294282 };
295283 };
284+ };
296285}
overlays/default.nix+5
@@ -1,4 +1,7 @@
11[
2+ # Hide nixpkgs haskell and haskellPackages from the haskell-nix overlays.
3+ # This should prevent us inadvertantly depending on them.
4+ (_: super: { haskell = {}; haskellPackages = {}; haskell-nix-super = super; })
25 (import ./release-19.03.nix)
36 #(import ./ghcjs-asterius-triple.nix)
47 #(import ./python.nix)
@@ -8,4 +11,6 @@
811 (import ./ghc-packages.nix)
912 (import ./windows.nix)
1013 (import ./armv6l-linux.nix)
14+ # Restore nixpkgs haskell and haskellPackages
15+ (_: super: { inherit (super.haskell-nix-super) haskell haskellPackages; })
1116]
overlays/ghc-packages.nix+4−4
@@ -6,7 +6,7 @@ let
66 EOF
77 '';
88 callCabalSdist = name: src: self.runCommand "${name}-sdist.tar.gz" {
9− nativeBuildInputs = [ self.cabal-install ];
9+ nativeBuildInputs = [ self.haskell-nix.cabal-install ];
1010 } ''
1111 tmp=$(mktemp -d)
1212 cp -r ${src}/* $tmp
@@ -65,7 +65,7 @@ in rec {
6565 ghc-boot-packages = builtins.mapAttrs
6666 (name: value: builtins.mapAttrs
6767 (pkgName: dir: importCabal "${name}-${pkgName}" "${value.passthru.configured-src}/${dir}") ghc-extra-pkgs)
68− self.buildPackages.haskell.compiler;
68+ self.buildPackages.haskell-nix.compiler;
6969
7070 ghc-extra-pkgs-cabal-projects = builtins.mapAttrs (name: value: let package-locs = builtins.mapAttrs (_: dir: "${value.passthru.configured-src}/${dir}") ghc-extra-pkgs; in
7171 self.writeTextFile {
@@ -79,13 +79,13 @@ in rec {
7979 ghci +ghci,
8080 libiserv +network
8181 '';
82− }) self.buildPackages.haskell.compiler;
82+ }) self.buildPackages.haskell-nix.compiler;
8383
8484 ghc-extra-projects = builtins.mapAttrs (name: proj: self.haskell-nix.cabalProject' {
8585 name = "ghc-extra-packages";
8686 src = proj;
8787 index-state = "2019-10-31T00:00:00Z";
88− ghc = self.buildPackages.haskell.compiler.${name};
88+ ghc = self.buildPackages.haskell-nix.compiler.${name};
8989 })
9090 ghc-extra-pkgs-cabal-projects;
9191
overlays/ghc.nix+3−3
@@ -9,7 +9,7 @@ self: super: with super;
99 hardeningDisable = (drv.hardeningDisable or []) ++ [ "stackprotector" "format" ];
1010 };
1111 in {
12− haskell = let
12+ haskell-nix = let
1313 # These patches (ghcPkgOverrides and ghcDrvOverrides) only apply to vanilla source ghcs.
1414 # Not ghcjs or binary distributions.
1515 # We also ignore ghc82. And are only concerned with ghc84+
@@ -24,8 +24,8 @@ self: super: with super;
2424 overrideCompiler = compiler:
2525 (compiler.override ghcPkgOverrides).overrideAttrs ghcDrvOverrides;
2626 in
27− lib.recursiveUpdate super.haskell {
27+ lib.recursiveUpdate super.haskell-nix {
2828 compiler = lib.mapAttrs (_name: overrideCompiler)
29− (lib.filterAttrs (name: _value: needsPatches name) super.haskell.compiler);
29+ (lib.filterAttrs (name: _value: needsPatches name) super.haskell-nix.compiler);
3030 };
3131 }
overlays/haskell.nix+7−7
@@ -142,8 +142,7 @@ self: super: {
142142 inherit (self) pkgs lib symlinkJoin makeWrapper
143143 git nix nix-prefetch-git;
144144 inherit (self.haskell-nix) fetchExternal cleanSourceHaskell mkCabalProjectPkgSet;
145− hpack = self.haskell.lib.justStaticExecutables
146− (self.haskellPackages.hpack);
145+ hpack = null; # nix-tools does not use hpack project files
147146 };
148147 # While `nix-tools-cross-compiled` may be cross compiled,
149148 # getting it from `buildPackages` we should get
@@ -258,7 +257,8 @@ self: super: {
258257 inherit (self.buildPackages.haskell-nix) dotCabal nix-tools haskellLib;
259258 pkgs = self.buildPackages.pkgs;
260259 inherit (self.buildPackages.haskell-nix.haskellPackages.hpack.components.exes) hpack;
261− inherit (self.buildPackages.pkgs) runCommand cabal-install ghc symlinkJoin cacert;
260+ inherit (self.buildPackages.haskell-nix) cabal-install ghc;
261+ inherit (self.buildPackages.pkgs) runCommand symlinkJoin cacert;
262262 };
263263
264264 # Loads a plan and filters the package directories using cleanSourceWith
@@ -351,10 +351,10 @@ self: super: {
351351 # are tested and cached.
352352 haskellNixRoots = self.recurseIntoAttrs (builtins.mapAttrs (_: self.recurseIntoAttrs) {
353353 inherit (self.haskell-nix) nix-tools source-pins;
354− bootstap-nix-tools = self.bootstrap.haskell.packages.nix-tools;
355− alex-plan-nix = withInputs self.bootstrap.haskell.packages.alex-project.plan-nix;
356− happy-plan-nix = withInputs self.bootstrap.haskell.packages.happy-project.plan-nix;
357− hscolour-plan-nix = withInputs self.bootstrap.haskell.packages.hscolour-project.plan-nix;
354+ bootstap-nix-tools = self.haskell-nix.bootstrap.packages.nix-tools;
355+ alex-plan-nix = withInputs self.haskell-nix.bootstrap.packages.alex-project.plan-nix;
356+ happy-plan-nix = withInputs self.haskell-nix.bootstrap.packages.happy-project.plan-nix;
357+ hscolour-plan-nix = withInputs self.haskell-nix.bootstrap.packages.hscolour-project.plan-nix;
358358 ghc-extra-projects = builtins.mapAttrs (_: proj: self.recurseIntoAttrs (withInputs proj.plan-nix))
359359 (self.lib.filterAttrs (n: _: n != "ghc844" && n != "ghc861" && n != "ghc862") self.ghc-extra-projects);
360360 });
test/fully-static/default.nix+1−1
@@ -45,7 +45,7 @@ let
4545 in {
4646 # Select a non-GMP compiler, usually for software licensing reasons.
4747 ghc.package = mkIf (stdenv.hostPlatform.isMusl && !gpl)
48− buildPackages.haskell.compiler.integer-simple.${compiler};
48+ buildPackages.haskell-nix.compiler.integer-simple.${compiler};
4949
5050 # Add GHC flags and libraries for fully static build
5151 packages.pandoc.components.exes.pandoc = withFullyStatic;
test/regen.nix+1−1
@@ -11,7 +11,7 @@ writeScript "regen-tests.sh" ''
1111
1212 set -euo pipefail
1313
14− export PATH="${lib.makeBinPath [ coreutils glibc haskell-nix.nix-tools cabal-install haskell.compiler.ghc865 ]}"
14+ export PATH="${lib.makeBinPath [ coreutils glibc haskell-nix.nix-tools cabal-install haskell-nix.compiler.ghc865 ]}"
1515
1616 cabal_configure() {
1717 cabal new-configure \