Skip to content

Commit 48401ba

Browse files
authored
Fix Nix build, bumping haskell.nix (#397) (#398)
* Fix Nix build, bumping haskell.nix (#397) Fixes `nix-shell` and `nix-build` for the repo, which was failing with a dependency error (#397). This PR takes two steps to fix this: 1. It bumps the version of `haskell.nix` we use, switching to GHC 8.10.7 and Nixpkgs 21.11 so that we still use the haskell.nix cache 2. After 1., I ran into an error where haskell.nix was using Cabal-3.2.1.0 even though `stylish-haskell.cabal` needs Cabal >= 3.4. To fix this, I had to explicitly mark the Cabal library as "reinstallable"—otherwise, haskell.nix uses the exact version that comes with GHC. (See [haskell-nix issue #1337][1] for details.) [1]: input-output-hk/haskell.nix#1337 I tested this change locally. Both `nix-build` and `nix-shell` succeeded without needing to build GHC from source. * Set shell.nix to explicitly import haskell-language-server = 1.6.1.1 The version of haskell-language-server from pkgs ran into a bug without an explicit hie.yaml. Importing a specific version fixes that problem.
1 parent 851439e commit 48401ba

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

default.nix

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
{ pkgs ? import ./haskell-pkgs.nix
2-
, haskellCompiler ? "ghc8104"
2+
, haskellCompiler ? "ghc8107"
33
}:
44
pkgs.haskell-nix.cabalProject {
55
src = pkgs.haskell-nix.haskellLib.cleanGit {
66
name = "stylish-haskell";
77
src = ./.;
88
};
9+
910
compiler-nix-name = haskellCompiler;
11+
12+
# need to make Cabal reinstallable, otherwise Haskell.nix uses the
13+
# version of Cabal that ships with the compiler even when that would
14+
# violate the constraint in stylish-haskell.cabal
15+
#
16+
# (eg nix-build failed because it tried to use Cabal-3.2.1.0 while
17+
# stylish-haskell needs Cabal >= 3.4 && < 3.7)
18+
#
19+
# See haskell-nix issue #1337 for details:
20+
# https://github.com/input-output-hk/haskell.nix/issues/1337
21+
modules = [
22+
({ lib, ... }: {
23+
options.nonReinstallablePkgs = lib.mkOption { apply = lib.remove "Cabal"; };
24+
})
25+
];
1026
}

haskell-pkgs.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ let
22
# Fetch the latest haskell.nix and import its default.nix
33
haskellNix = import
44
(builtins.fetchTarball {
5-
url = "https://github.com/input-output-hk/haskell.nix/archive/1b9b05beed75a1be98405501fbb33ac1f080069e.tar.gz";
5+
url = "https://github.com/input-output-hk/haskell.nix/archive/cc40a24585ccba274dc9a5af96d5506034e0d658.tar.gz";
66
})
77
{ };
88

99
# haskell.nix provides access to the nixpkgs pins which are used by our CI,
1010
# hence you will be more likely to get cache hits when using these.
1111
# But you can also just use your own, e.g. '<nixpkgs>'.
12-
nixpkgsSrc = haskellNix.sources.nixpkgs-2009;
12+
nixpkgsSrc = haskellNix.sources.nixpkgs-2111;
1313

1414
# haskell.nix provides some arguments to be passed to nixpkgs, including some
1515
# patches and also the haskell.nix functionality itself as an overlay.

shell.nix

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ hsPkgs.shellFor {
1414
# You might want some extra tools in the shell (optional).
1515
# Some common tools can be added with the `tools` argument
1616
tools = {
17-
cabal = "3.2.0.0";
18-
hlint = "2.2.11";
19-
stylish-haskell = "0.12.2.0";
17+
cabal = "3.6.2.0";
18+
hlint = "3.3.6";
19+
haskell-language-server = "1.6.1.1";
2020
};
2121
# See overlays/tools.nix for more details
2222

2323
# Some you may need to get some other way.
2424
buildInputs = [
2525
pkgs.ghcid
2626
pkgs.nixpkgs-fmt
27+
pkgs.stylish-haskell
2728
];
2829

2930
# Prevents cabal from choosing alternate plans, so that

0 commit comments

Comments
 (0)