Skip to content

Commit 8aa698b

Browse files
authored
nix: add support for ghc 9.0.1 (#1995)
* nix: add support for ghc 9.0.1 * Add CI * Don't use overrideScope * Try to disable plugins properly * Avoid removing attrs of hpkgs * Split CI steps * Jailbreak all ghc901 packages * Override `operational` * Disable the test of `dual-tree` * Override `dependent-sum-template` * Disable tests for every ghc901 package * Remove formatters executables from dev shell * Disable pre-commit check for ghc901 * Override `diagrams` packages * Override `monoid-extras` * Disable class plugin and refineImports plugin (consistent with cabal-ghc901.project)
1 parent 4ae0fea commit 8aa698b

File tree

5 files changed

+178
-27
lines changed

5 files changed

+178
-27
lines changed

.github/workflows/nix.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ jobs:
9292
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
9393
- name: Build development shell
9494
run: nix develop --profile dev
95+
- name: Build development shell (GHC 9.0.1)
96+
run: nix develop .#haskell-language-server-901-dev --profile dev
9597
- name: Push development shell
9698
if: ${{ env.HAS_TOKEN == 'true' }}
9799
run: cachix push haskell-language-server dev
98100
- name: Build binaries
99101
run: nix build
102+
- name: Build binaries (GHC 9.0.1)
103+
run: nix build .#haskell-language-server-901
100104
- name: Push binaries
101105
if: ${{ env.HAS_TOKEN == 'true' }}
102106
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server

cabal-ghc901.project

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ source-repository-package
7575
subdir: lsp-test
7676
-- https://github.com/haskell/lsp/pull/312
7777

78+
-- benchmark dependency
79+
source-repository-package
80+
type: git
81+
location: https://github.com/berberman/operational
82+
tag: 0e062895678f49fd673ae493371262cfb8c5ab56
83+
-- https://github.com/HeinrichApfelmus/operational/pull/26
84+
7885
write-ghc-environment-files: never
7986

8087
index-state: 2021-06-30T16:00:00Z

configuration-ghc-901.nix

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# nix version of cabal-ghc901.project
2+
{ pkgs }:
3+
4+
let
5+
disabledPlugins = [
6+
"hls-tactics-plugin"
7+
"hls-brittany-plugin"
8+
"hls-stylish-haskell-plugin"
9+
"hls-fourmolu-plugin"
10+
"hls-splice-plugin"
11+
"hls-ormolu-plugin"
12+
"hls-eval-plugin"
13+
"hls-class-plugin"
14+
"hls-refine-imports-plugin"
15+
];
16+
17+
hpkgsOverride = hself: hsuper:
18+
with pkgs.haskell.lib;
19+
let
20+
lsp-src = pkgs.fetchFromGitHub {
21+
owner = "anka-213";
22+
repo = "lsp";
23+
rev = "tag-ghc-9.0.1-without-pr-326";
24+
sha256 = "lW/EdBnvKPLE2+CGE/grIekOu+U/Wh6zMCN4xhJDtPY=";
25+
};
26+
27+
dependent-sum-src = pkgs.fetchFromGitHub {
28+
owner = "anka-213";
29+
repo = "dependent-sum";
30+
rev = "8cf4c7fbc3bfa2be475a17bb7c94a1e1e9a830b5";
31+
sha256 = "WtxTB6ufTZC6SxOtGSfhlO4mY0y9eWejMSa0yUJ7dHQ=";
32+
};
33+
in {
34+
blaze-textual = hself.callCabal2nix "blaze-textual"
35+
(pkgs.fetchFromGitHub {
36+
owner = "jwaldmann";
37+
repo = "blaze-textual";
38+
rev = "d8ee6cf80e27f9619d621c936bb4bda4b99a183f";
39+
sha256 = "C0dIzf64fBaY8mlhMm1kCQC5Jc1wKBtNO2Y24k7YPUw=";
40+
}) { };
41+
42+
czipwith = hself.callCabal2nix "czipwith" (pkgs.fetchFromGitHub {
43+
owner = "mithrandi";
44+
repo = "czipwith";
45+
rev = "b6245884ae83e00dd2b5261762549b37390179f8";
46+
sha256 = "2uSoGyrxT/OstRcpx55kwP4JwjPbWLxD72LajeyQV0E=";
47+
}) { };
48+
49+
hie-bios = hself.callCabal2nix "hie-bios" (pkgs.fetchFromGitHub {
50+
owner = "jneira";
51+
repo = "hie-bios";
52+
rev = "9b1445ab5efcabfad54043fc9b8e50e9d8c5bbf3";
53+
sha256 = "8ct7t3xIxIAoC+f8VO5e5+QKrd5L5Zu1eButSaE+1Uk=";
54+
}) { };
55+
56+
ghc-api-compat = hself.callCabal2nix "ghc-api-compat"
57+
(pkgs.fetchFromGitHub {
58+
owner = "hsyl20";
59+
repo = "ghc-api-compat";
60+
rev = "8fee87eac97a538dbe81ff1ab18cff10f2f9fa15";
61+
sha256 = "byehvdxQxhNk5ZQUXeFHjAZpAze4Ct9261ro4c5acZk=";
62+
}) { };
63+
64+
th-extras = hself.callCabal2nix "th-extras" (pkgs.fetchFromGitHub {
65+
owner = "anka-213";
66+
repo = "th-extras";
67+
rev = "57a97b4df128eb7b360e8ab9c5759392de8d1659";
68+
sha256 = "Qtha1ge/C0L+uFcV2dZ5xpG59DCxQT7LuK/OYfiM4Pk=";
69+
}) { };
70+
71+
lsp = hself.callCabal2nix "lsp" "${lsp-src}/lsp" { };
72+
lsp-types = hself.callCabal2nix "lsp-types" "${lsp-src}/lsp-types" { };
73+
lsp-test = hself.callCabal2nix "lsp-test" "${lsp-src}/lsp-test" { };
74+
75+
dependent-sum =
76+
hself.callCabal2nix "dependent-sum" "${dependent-sum-src}/dependent-sum"
77+
{ };
78+
79+
dependent-sum-template = hself.callCabal2nix "dependent-sum-template"
80+
"${dependent-sum-src}/dependent-sum-template" { };
81+
82+
hlint = hself.hlint_3_3_1;
83+
84+
ghc-lib-parser = hself.ghc-lib-parser_9_0_1_20210324;
85+
86+
ghc-lib-parser-ex = hself.ghc-lib-parser-ex_9_0_0_4;
87+
88+
operational = hself.callCabal2nix "operational" (pkgs.fetchFromGitHub {
89+
owner = "berberman";
90+
repo = "operational";
91+
rev = "0e062895678f49fd673ae493371262cfb8c5ab56";
92+
sha256 = "P+aocEcqCN8klnW3IMrmIqq6ztBZJxk4sBp1ewN6YaA=";
93+
}) { };
94+
95+
diagrams-core = hself.diagrams-core_1_5_0;
96+
97+
diagrams-lib = hself.diagrams-lib_1_4_4;
98+
99+
dual-tree = hself.dual-tree_0_2_3_0;
100+
101+
monoid-extras = hself.monoid-extras_0_6;
102+
103+
# Re-generate HLS drv excluding some plugins
104+
haskell-language-server =
105+
hself.callCabal2nixWithOptions "haskell-language-server" ./.
106+
(pkgs.lib.concatStringsSep " " [
107+
"-f-brittany"
108+
"-f-class"
109+
"-f-eval"
110+
"-f-fourmolu"
111+
"-f-ormolu"
112+
"-f-splice"
113+
"-f-stylishhaskell"
114+
"-f-tactic"
115+
"-f-refineImports"
116+
]) { };
117+
118+
# YOLO
119+
mkDerivation = args:
120+
hsuper.mkDerivation (args // {
121+
jailbreak = true;
122+
doCheck = false;
123+
});
124+
};
125+
in {
126+
inherit disabledPlugins;
127+
tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride;
128+
}

flake.nix

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,22 @@
3030
overlay = final: prev:
3131
with prev;
3232
let
33-
haskellOverrides = {
34-
overrides = hself: hsuper: {
35-
# we override mkDerivation here to apply the following
36-
# tweak to each haskell package:
37-
# if the package is broken, then we disable its check and relax the cabal bounds;
38-
# otherwise, we leave it unchanged.
39-
# hopefully, this could fix packages marked as broken by nix due to check failures
40-
# or the build failure because of tight cabal bounds
41-
mkDerivation = args:
42-
let
43-
broken = args.broken or false;
44-
check = args.doCheck or true;
45-
jailbreak = args.jailbreak or false;
46-
in hsuper.mkDerivation (args // {
47-
jailbreak = if broken then true else jailbreak;
48-
doCheck = if broken then false else check;
49-
});
50-
};
33+
haskellOverrides = hself: hsuper: {
34+
# we override mkDerivation here to apply the following
35+
# tweak to each haskell package:
36+
# if the package is broken, then we disable its check and relax the cabal bounds;
37+
# otherwise, we leave it unchanged.
38+
# hopefully, this could fix packages marked as broken by nix due to check failures
39+
# or the build failure because of tight cabal bounds
40+
mkDerivation = args:
41+
let
42+
broken = args.broken or false;
43+
check = args.doCheck or true;
44+
jailbreak = args.jailbreak or false;
45+
in hsuper.mkDerivation (args // {
46+
jailbreak = if broken then true else jailbreak;
47+
doCheck = if broken then false else check;
48+
});
5149
};
5250
gitignoreSource = (import gitignore { inherit lib; }).gitignoreSource;
5351

@@ -91,7 +89,10 @@
9189
builtins.mapAttrs (_: dir: gitignoreSource dir) sourceDirs;
9290

9391
extended = hpkgs:
94-
(hpkgs.override haskellOverrides).extend (hself: hsuper:
92+
(hpkgs.override (old: {
93+
overrides = lib.composeExtensions (old.overrides or (_: _: { }))
94+
haskellOverrides;
95+
})).extend (hself: hsuper:
9596
# disable all checks for our packages
9697
builtins.mapAttrs (_: drv: haskell.lib.dontCheck drv)
9798
(lib.composeExtensions
@@ -135,7 +136,7 @@
135136
hooks = {
136137
stylish-haskell.enable = true;
137138
# use stylish-haskell with our target ghc
138-
stylish-haskell.entry = "${hpkgs.stylish-haskell}/bin/stylish-haskell --inplace";
139+
stylish-haskell.entry = pkgs.lib.mkForce "${hpkgs.stylish-haskell}/bin/stylish-haskell --inplace";
139140
stylish-haskell.excludes = [
140141
# Ignored files
141142
"^Setup.hs$"
@@ -156,14 +157,16 @@
156157
};
157158
};
158159

160+
ghc901Config = (import ./configuration-ghc-901.nix) { inherit pkgs; };
161+
159162
# GHC versions
160163
ghcDefault = pkgs.hlsHpkgs ("ghc"
161164
+ pkgs.lib.replaceStrings [ "." ] [ "" ]
162165
pkgs.haskellPackages.ghc.version);
163166
ghc884 = pkgs.hlsHpkgs "ghc884";
164167
ghc8104 = pkgs.hlsHpkgs "ghc8104";
165168
ghc8105 = pkgs.hlsHpkgs "ghc8105";
166-
ghc901 = pkgs.hlsHpkgs "ghc901";
169+
ghc901 = ghc901Config.tweakHpkgs (pkgs.hlsHpkgs "ghc901");
167170

168171
# Create a development shell of hls project
169172
# See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319
@@ -173,13 +176,17 @@
173176
doBenchmark = true;
174177
packages = p:
175178
with builtins;
176-
map (name: p.${name}) (attrNames hlsSources);
179+
map (name: p.${name}) (attrNames
180+
(if hpkgs.ghc.version == "9.0.1" then
181+
removeAttrs hlsSources ghc901Config.disabledPlugins
182+
else
183+
hlsSources));
177184
buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs hpkgs) ]
178185
++ (with hpkgs; [
179186
cabal-install
180187
hlint
181-
ormolu
182-
stylish-haskell
188+
# ormolu
189+
# stylish-haskell
183190
opentelemetry-extra
184191
]);
185192

@@ -188,7 +195,7 @@
188195
export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib
189196
export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib
190197
export PATH=$PATH:$HOME/.local/bin
191-
${(pre-commit-check hpkgs).shellHook}
198+
${if hpkgs.ghc.version != "9.0.1" then (pre-commit-check hpkgs).shellHook else ""}
192199
'';
193200
};
194201
# Create a hls executable
@@ -213,14 +220,14 @@
213220
haskell-language-server-884-dev = mkDevShell ghc884;
214221
haskell-language-server-8104-dev = mkDevShell ghc8104;
215222
haskell-language-server-8105-dev = mkDevShell ghc8105;
216-
haskell-language-server-901-dev = builtins.throw "Nix expression for developing HLS in GHC 9.0.1 is not yet available"; # mkDevShell ghc901;
223+
haskell-language-server-901-dev = mkDevShell ghc901;
217224

218225
# hls package
219226
haskell-language-server = mkExe ghcDefault;
220227
haskell-language-server-884 = mkExe ghc884;
221228
haskell-language-server-8104 = mkExe ghc8104;
222229
haskell-language-server-8105 = mkExe ghc8105;
223-
haskell-language-server-901 = builtins.throw "Nix expression for building HLS in GHC 9.0.1 is not yet available"; # mkExe ghc901;
230+
haskell-language-server-901 = mkExe ghc901;
224231
};
225232

226233
defaultPackage = packages.haskell-language-server;

stack-9.0.1.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ extra-deps:
9494
commit: ca23431a8dfa013992f9164ccc882a3277361f17
9595
# https://github.com/diagrams/active/pull/36
9696

97+
# benchmark dependency
98+
- github: berberman/operational
99+
commit: 0e062895678f49fd673ae493371262cfb8c5ab56
100+
# https://github.com/HeinrichApfelmus/operational/pull/26
101+
97102
configure-options:
98103
ghcide:
99104
- --disable-library-for-ghci

0 commit comments

Comments
 (0)