on iko/ghcjs-patch-master help sign in
shellFor: Use CABAL_CONFIG only with exactDeps = true (#255)
b47a6bbRodney Lorrimar
builder/comp-builder.nix−1
@@ -148,7 +148,6 @@ stdenv.mkDerivation ({
148 (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
148 (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
149 };
149 };
150
150
151− CABAL_CONFIG = configFiles + /cabal.config;
152 LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
151 LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
153 LC_ALL = "en_US.UTF-8";
152 LC_ALL = "en_US.UTF-8";
154
153
builder/make-config-files.nix+3
@@ -75,6 +75,9 @@ in { identifier, component, fullName, flags ? {} }:
75
75
76 echo ${lib.concatStringsSep " " (lib.mapAttrsToList (fname: val: "--flags=${lib.optionalString (!val) "-" + fname}") flags)} >> $out/configure-flags
76 echo ${lib.concatStringsSep " " (lib.mapAttrsToList (fname: val: "--flags=${lib.optionalString (!val) "-" + fname}") flags)} >> $out/configure-flags
77
77
78+ # Provide a cabal config without remote package repositories
79+ echo "write-ghc-environment-files: never" >> $out/cabal.config
80+
78 # Provide a GHC environment file
81 # Provide a GHC environment file
79 cat > $out/ghc-environment <<EOF
82 cat > $out/ghc-environment <<EOF
80 package-db $out/package.conf.d
83 package-db $out/package.conf.d
builder/setup-builder.nix−1
@@ -45,7 +45,6 @@ in
45 inherit configFiles cleanSrc;
45 inherit configFiles cleanSrc;
46 };
46 };
47
47
48− CABAL_CONFIG = configFiles + /cabal.config;
49 phases = ["unpackPhase" "buildPhase" "installPhase"];
48 phases = ["unpackPhase" "buildPhase" "installPhase"];
50 buildPhase = ''
49 buildPhase = ''
51 for f in Setup.hs Setup.lhs; do
50 for f in Setup.hs Setup.lhs; do
builder/shell-for.nix+3−1
@@ -8,6 +8,7 @@
8 (builtins.attrValues selected)
8 (builtins.attrValues selected)
9, additional ? _: []
9, additional ? _: []
10, withHoogle ? true
10, withHoogle ? true
11+, exactDeps ? false
11, ... } @ args:
12, ... } @ args:
12
13
13let
14let
@@ -80,9 +81,10 @@ in
80 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
81 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
81 LANG = "en_US.UTF-8";
82 LANG = "en_US.UTF-8";
82 LOCALE_ARCHIVE = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive";
83 LOCALE_ARCHIVE = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive";
83− CABAL_CONFIG = "${configFiles}/cabal.config";
84
84
85 passthru = (mkDrvArgs.passthru or {}) // {
85 passthru = (mkDrvArgs.passthru or {}) // {
86 ghc = ghcEnv;
86 ghc = ghcEnv;
87 };
87 };
88+ } // lib.optionalAttrs exactDeps {
89+ CABAL_CONFIG = "${configFiles}/cabal.config";
88 })
90 })
changelog.md+5
@@ -1,6 +1,11 @@
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+## October 12, 2019
5+ * [`shellFor`](https://input-output-hk.github.io/haskell.nix/reference/library/#shellfor) no longer sets `CABAL_CONFIG` by default.
6+ This avoids surprising users, but means that Cabal may select a plan which is different to your Haskell.nix package set.
7+ If you would like the old behaviour, use `shellFor { exactDeps = true; }`.
8+
4## August 9, 2019
9## August 9, 2019
5 * Add the [`haskellLib.collectComponents`](https://input-output-hk.github.io/haskell.nix/reference/library/#haskellLib) function.
10 * Add the [`haskellLib.collectComponents`](https://input-output-hk.github.io/haskell.nix/reference/library/#haskellLib) function.
6
11
docs/reference/library.md+7−5
@@ -285,7 +285,7 @@ packages with `ghci` or `cabal v2-build` (but not Stack).
285
285
286```
286```
287shellFor =
287shellFor =
288− { packages, withHoogle ? true, ...}: ...
288+ { packages, withHoogle ? true, exactDeps ? false, ...}: ...
289```
289```
290
290
291
291
@@ -293,16 +293,18 @@ shellFor =
293|----------------|------|---------------------|
293|----------------|------|---------------------|
294| `packages` | Function | Package selection function. It takes a list of [Haskell packages](#haskell-package) and returns a subset of these packages. |
294| `packages` | Function | Package selection function. It takes a list of [Haskell packages](#haskell-package) and returns a subset of these packages. |
295| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
295| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
296+| `exactDeps` | Boolean | Prevents the Cabal solver from choosing any package dependency other than what are in the package set. |
296| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
297| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
297
298
298**Return value**: a derivation
299**Return value**: a derivation
299
300
300!!! warning
301!!! warning
301
302
302− `shellFor` will set the `CABAL_CONFIG` environment variable to disable
303+ `exactDeps = true` will set the `CABAL_CONFIG` environment variable
303− remote package servers. This is a [known
304+ to disable remote package servers. This is a
304− limitation](../dev/removing-with-package-wrapper.md) which we would
305+ [known limitation](../dev/removing-with-package-wrapper.md)
305− like to solve.
306+ which we would like to solve. Use `exactDeps = false` if this is a
307+ problem.
306
308
307
309
308## ghcWithPackages
310## ghcWithPackages
docs/user-guide/development.md+4
@@ -68,6 +68,10 @@ in
68 # You might want some extra tools in the shell (optional).
68 # You might want some extra tools in the shell (optional).
69 buildInputs = with pkgs.haskellPackages;
69 buildInputs = with pkgs.haskellPackages;
70 [ hlint stylish-haskell ghcid ];
70 [ hlint stylish-haskell ghcid ];
71+
72+ # Prevents cabal from choosing alternate plans, so that
73+ # *all* dependencies are provided by Nix.
74+ exactDeps = true;
71 }
75 }
72```
76```
73
77
test/shell-for/default.nix+2
@@ -23,6 +23,7 @@ let
23 # This adds cabal-install to the shell, which helps tests because
23 # This adds cabal-install to the shell, which helps tests because
24 # they use a nix-shell --pure. Normally you would BYO cabal-install.
24 # they use a nix-shell --pure. Normally you would BYO cabal-install.
25 buildInputs = [ cabal-install ];
25 buildInputs = [ cabal-install ];
26+ exactDeps = true;
26 };
27 };
27
28
28 envPkga = pkgSet.config.hsPkgs.shellFor {
29 envPkga = pkgSet.config.hsPkgs.shellFor {
@@ -31,6 +32,7 @@ let
31 # This adds cabal-install to the shell, which helps tests because
32 # This adds cabal-install to the shell, which helps tests because
32 # they use a nix-shell --pure. Normally you would BYO cabal-install.
33 # they use a nix-shell --pure. Normally you would BYO cabal-install.
33 buildInputs = [ cabal-install ];
34 buildInputs = [ cabal-install ];
35+ exactDeps = true;
34 };
36 };
35
37
36 envDefault = pkgSet.config.hsPkgs.shellFor {
38 envDefault = pkgSet.config.hsPkgs.shellFor {