on iko/ghcjs-patch-master help sign in
shellFor: Use CABAL_CONFIG only with exactDeps = true (#255)

* shellFor: Use CABAL_CONFIG only with exactDeps = true * shells: Put write-ghc-environment-files: never in cabal.config

commitb47a6bb1a28d4fba83b6f304605ba7112fe06344 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateSun 13 Oct 2019, 21:43 (7 years ago) parentdf51ce6
8 files changed+24−8
builder/comp-builder.nix−1 builder/make-config-files.nix+3 builder/setup-builder.nix−1 builder/shell-for.nix+3−1 changelog.md+5 docs/reference/library.md+7−5 docs/user-guide/development.md+4 test/shell-for/default.nix+2
builder/comp-builder.nix−1
@@ -148,7 +148,6 @@ stdenv.mkDerivation ({
148148 (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
149149 };
150150
151− CABAL_CONFIG = configFiles + /cabal.config;
152151 LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
153152 LC_ALL = "en_US.UTF-8";
154153
builder/make-config-files.nix+3
@@ -75,6 +75,9 @@ in { identifier, component, fullName, flags ? {} }:
7575
7676 echo ${lib.concatStringsSep " " (lib.mapAttrsToList (fname: val: "--flags=${lib.optionalString (!val) "-" + fname}") flags)} >> $out/configure-flags
7777
78+ # Provide a cabal config without remote package repositories
79+ echo "write-ghc-environment-files: never" >> $out/cabal.config
80+
7881 # Provide a GHC environment file
7982 cat > $out/ghc-environment <<EOF
8083 package-db $out/package.conf.d
builder/setup-builder.nix−1
@@ -45,7 +45,6 @@ in
4545 inherit configFiles cleanSrc;
4646 };
4747
48− CABAL_CONFIG = configFiles + /cabal.config;
4948 phases = ["unpackPhase" "buildPhase" "installPhase"];
5049 buildPhase = ''
5150 for f in Setup.hs Setup.lhs; do
builder/shell-for.nix+3−1
@@ -8,6 +8,7 @@
88 (builtins.attrValues selected)
99, additional ? _: []
1010, withHoogle ? true
11+, exactDeps ? false
1112, ... } @ args:
1213
1314let
@@ -80,9 +81,10 @@ in
8081 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
8182 LANG = "en_US.UTF-8";
8283 LOCALE_ARCHIVE = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive";
83− CABAL_CONFIG = "${configFiles}/cabal.config";
8484
8585 passthru = (mkDrvArgs.passthru or {}) // {
8686 ghc = ghcEnv;
8787 };
88+ } // lib.optionalAttrs exactDeps {
89+ CABAL_CONFIG = "${configFiles}/cabal.config";
8890 })
changelog.md+5
@@ -1,6 +1,11 @@
11This file contains a summary of changes to Haskell.nix and `nix-tools`
22that will impact users.
33
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+
49## August 9, 2019
510 * Add the [`haskellLib.collectComponents`](https://input-output-hk.github.io/haskell.nix/reference/library/#haskellLib) function.
611
docs/reference/library.md+7−5
@@ -285,7 +285,7 @@ packages with `ghci` or `cabal v2-build` (but not Stack).
285285
286286```
287287shellFor =
288− { packages, withHoogle ? true, ...}: ...
288+ { packages, withHoogle ? true, exactDeps ? false, ...}: ...
289289```
290290
291291
@@ -293,16 +293,18 @@ shellFor =
293293|----------------|------|---------------------|
294294| `packages` | Function | Package selection function. It takes a list of [Haskell packages](#haskell-package) and returns a subset of these packages. |
295295| `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. |
296297| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
297298
298299**Return value**: a derivation
299300
300301!!! warning
301302
302− `shellFor` will set the `CABAL_CONFIG` environment variable to disable
303− remote package servers. This is a [known
304− limitation](../dev/removing-with-package-wrapper.md) which we would
305− like to solve.
303+ `exactDeps = true` will set the `CABAL_CONFIG` environment variable
304+ to disable remote package servers. This is a
305+ [known limitation](../dev/removing-with-package-wrapper.md)
306+ which we would like to solve. Use `exactDeps = false` if this is a
307+ problem.
306308
307309
308310## ghcWithPackages
docs/user-guide/development.md+4
@@ -68,6 +68,10 @@ in
6868 # You might want some extra tools in the shell (optional).
6969 buildInputs = with pkgs.haskellPackages;
7070 [ hlint stylish-haskell ghcid ];
71+
72+ # Prevents cabal from choosing alternate plans, so that
73+ # *all* dependencies are provided by Nix.
74+ exactDeps = true;
7175 }
7276```
7377
test/shell-for/default.nix+2
@@ -23,6 +23,7 @@ let
2323 # This adds cabal-install to the shell, which helps tests because
2424 # they use a nix-shell --pure. Normally you would BYO cabal-install.
2525 buildInputs = [ cabal-install ];
26+ exactDeps = true;
2627 };
2728
2829 envPkga = pkgSet.config.hsPkgs.shellFor {
@@ -31,6 +32,7 @@ let
3132 # This adds cabal-install to the shell, which helps tests because
3233 # they use a nix-shell --pure. Normally you would BYO cabal-install.
3334 buildInputs = [ cabal-install ];
35+ exactDeps = true;
3436 };
3537
3638 envDefault = pkgSet.config.hsPkgs.shellFor {