@@ -39,37 +39,28 @@ let
40 defaultSetupSrc = if stdenv.hostPlatform.isGhcjs then ./Setup.ghcjs.hs else ./Setup.hs;
40 defaultSetupSrc = if stdenv.hostPlatform.isGhcjs then ./Setup.ghcjs.hs else ./Setup.hs;
42− # Get the Cabal lib used to build `cabal-install`.
42+ # This is the `Cabal` library that was built for `cabal-install` to use.
43− # To avoid infinite recursion we have to leave this out for packages
43+ # It makes sense to use this version (when possible) because it will match the behavior of
44− # needed to build `cabal-install`.
44+ # building with `cabal-install` (including fixes that may not be in the
45− # We always do this for ghcjs as the patched version of Cabal is needed.
45+ # version of Cabal bundled with GHC).
46− cabalLibDepends = lib.optional (
47− stdenv.hostPlatform.isGhcjs || (
48− !builtins.elem package.identifier.name
49− ["nix-tools" "alex" "happy" "hscolour" "Cabal" "bytestring" "aeson" "time"
50− "filepath" "base-compat-batteries" "base-compat" "unix" "directory" "transformers"
51− "containers" "binary" "mtl" "text" "process" "parsec"]
54− buildPackages.haskell-nix.cabal-install-unchecked.${compiler-nix-name}.project.hsPkgs.Cabal.components.library;
46+ cabalFromCabalInstall = buildPackages.haskell-nix.cabal-install-unchecked.${compiler-nix-name}.project.hsPkgs.Cabal.components.library;
56− # This logic is needed so that we don't get duplicate packages if we
48+ # Check there is no chance we are building `cabalFromCabalInstall`. Using `cabalFromCabalInstall`
57− # add a custom Cabal package to the dependencies. That way custom
49+ # to build itseld would cause infinite recursion.
58− # setups won't complain about e.g. binary from the Cabal dependencies
50+ useCabalFromCabalInstall =
59− # and binary from the global package-db.
51+ # `cabalFromCabalInstall` is not cross compiled
60− nonReinstallablePkgs = if (
61− stdenv.hostPlatform.isGhcjs || (
52+ stdenv.buildPlatform != stdenv.hostPlatform
54+ # These are the dependencies of `Cabal`
62 !builtins.elem package.identifier.name
55 !builtins.elem package.identifier.name
63 ["nix-tools" "alex" "happy" "hscolour" "Cabal" "bytestring" "aeson" "time"
56 ["nix-tools" "alex" "happy" "hscolour" "Cabal" "bytestring" "aeson" "time"
64 "filepath" "base-compat-batteries" "base-compat" "unix" "directory" "transformers"
57 "filepath" "base-compat-batteries" "base-compat" "unix" "directory" "transformers"
65− "containers" "binary" "mtl" "text" "process" "parsec"]
58+ "containers" "binary" "mtl" "text" "process" "parsec"];
69 defaultSetup = setup-builder ({
60 defaultSetup = setup-builder ({
70 name = "${ghc.targetPrefix}default-Setup";
61 name = "${ghc.targetPrefix}default-Setup";
71 component = {
62 component = {
72− depends = config.setup-depends ++ cabalLibDepends;
63+ depends = config.setup-depends ++ lib.optional useCabalFromCabalInstall cabalFromCabalInstall;
73 libs = [];
64 libs = [];
74 frameworks = [];
65 frameworks = [];
75 doExactConfig = false;
66 doExactConfig = false;
@@ -103,7 +94,13 @@ let
103 cat ${defaultSetupSrc} > $out/Setup.hs
94 cat ${defaultSetupSrc} > $out/Setup.hs
105 inherit defaultSetupSrc;
96 inherit defaultSetupSrc;
97+ } // lib.optionalAttrs useCabalFromCabalInstall {
98+ # This is needed so that we don't get duplicate packages when we
99+ # add a custom Cabal package to the dependencies. That way custom
100+ # setups won't complain about e.g. binary from the Cabal dependencies
101+ # and binary from the global package-db.
106− } // (if nonReinstallablePkgs == null then {} else { inherit nonReinstallablePkgs; }));
102+ nonReinstallablePkgs = [];
108 # buildPackages.runCommand "default-Setup" { nativeBuildInputs = [(ghc.passthru.buildGHC or ghc)]; } ''
105 # buildPackages.runCommand "default-Setup" { nativeBuildInputs = [(ghc.passthru.buildGHC or ghc)]; } ''
109 # cat ${defaultSetupSrc} > Setup.hs
106 # cat ${defaultSetupSrc} > Setup.hs
@@ -134,7 +131,7 @@ in rec {
134 checks = pkgs.recurseIntoAttrs (builtins.mapAttrs
131 checks = pkgs.recurseIntoAttrs (builtins.mapAttrs
135 (_: d: haskellLib.check d)
132 (_: d: haskellLib.check d)
136 (lib.filterAttrs (_: d: d.config.doCheck) components.tests));
133 (lib.filterAttrs (_: d: d.config.doCheck) components.tests));
137− inherit (package) identifier detailLevel isLocal isProject;
134+ inherit (package) identifier detailLevel isLocal isProject buildType;
138 inherit setup cabalFile;
135 inherit setup cabalFile;
139 isHaskell = true;
136 isHaskell = true;
140 inherit src;
137 inherit src;