Skip to content

Commit 6123268

Browse files
guiboumergify[bot]jneira
authored
Flake ghc 92 (#2621)
* refactor(flake): Use a separate flake for hackage sources This will be easier to update, and pass them as one dictionary. * flake: support for GHC 9.2 I've naively copied most of the special cases for `GHC 9.0.1`. - `nix develop .\#haskell-language-server-921` gives me a shell in which I'm able to `cabal build` - `nix build .#haskell-language-server-921` builds HLS binary. I was able to use it in a proprietary codebase (by importing the flake) and it works fine. - some plugins are disabled, `brittany`, `stylishhaskell`, `hlint`, `haddockComments`, `alternateNumberFormat`. I didn't fight too much to fix this because I'm not using them. I'll do an effort in the future to fix them. - `nix develop .\#haskell-language-server-921-dev` does not starts, I need to investigate. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Javier Neira <[email protected]>
1 parent f33954e commit 6123268

File tree

4 files changed

+185
-22
lines changed

4 files changed

+185
-22
lines changed

configuration-ghc-921.nix

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# nix version of cabal-ghc901.project
2+
{ pkgs, hackage }:
3+
4+
let
5+
disabledPlugins = [
6+
"hls-brittany-plugin"
7+
"hls-stylish-haskell-plugin"
8+
];
9+
10+
hpkgsOverride = hself: hsuper:
11+
with pkgs.haskell.lib;
12+
{
13+
fourmolu = hself.callCabal2nix "fourmolu" hackage.fourmolu {};
14+
primitive-extras = hself.primitive-extras_0_10_1_2;
15+
ghc-exactprint = hself.callCabal2nix "ghc-exactprint" hackage.ghc-exactprint {};
16+
constraints-extras = hself.callCabal2nix "constraints-extras" hackage.constraints-extras {};
17+
retrie = hself.callCabal2nix "retrie" hackage.retrie {};
18+
hlint = doJailbreak (hself.callCabal2nix "hlint" hackage.hlint {});
19+
20+
# Re-generate HLS drv excluding some plugins
21+
haskell-language-server =
22+
hself.callCabal2nixWithOptions "haskell-language-server" ./.
23+
(pkgs.lib.concatStringsSep " " [
24+
"-f-brittany"
25+
"-f-stylishhaskell"
26+
"-f-hlint"
27+
"-f-haddockComments"
28+
"-f-alternateNumberFormat"
29+
"-f-eval"
30+
]) { };
31+
32+
# YOLO
33+
mkDerivation = args:
34+
hsuper.mkDerivation (args // {
35+
jailbreak = true;
36+
doCheck = false;
37+
});
38+
};
39+
in {
40+
inherit disabledPlugins;
41+
tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride;
42+
}

flake.lock

+85-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+14-16
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,16 @@
2222
flake = false;
2323
};
2424

25-
lsp-source = {
26-
url = "https://hackage.haskell.org/package/lsp-1.4.0.0/lsp-1.4.0.0.tar.gz";
27-
flake = false;
28-
};
29-
lsp-types-source = {
30-
url = "https://hackage.haskell.org/package/lsp-types-1.4.0.0/lsp-types-1.4.0.0.tar.gz";
31-
flake = false;
32-
};
33-
lsp-test-source = {
34-
url = "https://hackage.haskell.org/package/lsp-test-0.14.0.2/lsp-test-0.14.0.2.tar.gz";
35-
flake = false;
36-
};
25+
hackage-sources.url = "path:./flake_hackage";
3726
};
3827
outputs =
39-
{ self, nixpkgs, flake-compat, flake-utils, pre-commit-hooks, gitignore, lsp-source, lsp-types-source, lsp-test-source }:
28+
{ self, nixpkgs, flake-compat, flake-utils, pre-commit-hooks, gitignore, hackage-sources }:
4029
{
4130
overlay = final: prev:
4231
with prev;
4332
let
33+
hackage = hackage-sources.inputs;
34+
4435
haskellOverrides = hself: hsuper: {
4536
# we override mkDerivation here to apply the following
4637
# tweak to each haskell package:
@@ -88,9 +79,9 @@
8879
# We need an older version
8980
hiedb = hself.hiedb_0_4_1_0;
9081

91-
lsp = hsuper.callCabal2nix "lsp" lsp-source {};
92-
lsp-types = hsuper.callCabal2nix "lsp-types" lsp-types-source {};
93-
lsp-test = hsuper.callCabal2nix "lsp-test" lsp-test-source {};
82+
lsp = hsuper.callCabal2nix "lsp" hackage.lsp {};
83+
lsp-types = hsuper.callCabal2nix "lsp-types" hackage.lsp-types {};
84+
lsp-test = hsuper.callCabal2nix "lsp-test" hackage.lsp-test {};
9485

9586
implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle"
9687
(builtins.fetchTarball {
@@ -144,6 +135,7 @@
144135
} // (flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ])
145136
(system:
146137
let
138+
hackage = hackage-sources.inputs;
147139
pkgs = import nixpkgs {
148140
inherit system;
149141
overlays = [ self.overlay ];
@@ -182,6 +174,7 @@
182174
};
183175

184176
ghc901Config = (import ./configuration-ghc-901.nix) { inherit pkgs; };
177+
ghc921Config = (import ./configuration-ghc-921.nix) { inherit pkgs hackage; };
185178

186179
# GHC versions
187180
ghcDefault = pkgs.hlsHpkgs ("ghc"
@@ -190,6 +183,7 @@
190183
ghc884 = pkgs.hlsHpkgs "ghc884";
191184
ghc8107 = pkgs.hlsHpkgs "ghc8107";
192185
ghc901 = ghc901Config.tweakHpkgs (pkgs.hlsHpkgs "ghc901");
186+
ghc921 = ghc921Config.tweakHpkgs (pkgs.hlsHpkgs "ghc921");
193187

194188
# For markdown support
195189
myst-parser = pkgs.python3Packages.callPackage ./myst-parser.nix {};
@@ -224,6 +218,8 @@
224218
map (name: p.${name}) (attrNames
225219
(if hpkgs.ghc.version == "9.0.1" then
226220
removeAttrs hlsSources ghc901Config.disabledPlugins
221+
else if hpkgs.ghc.version == "9.2.1" then
222+
removeAttrs hlsSources ghc921Config.disabledPlugins
227223
else
228224
hlsSources));
229225
buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs hpkgs) pythonWithPackages ]
@@ -266,12 +262,14 @@
266262
haskell-language-server-884-dev = mkDevShell ghc884;
267263
haskell-language-server-8107-dev = mkDevShell ghc8107;
268264
haskell-language-server-901-dev = mkDevShell ghc901;
265+
haskell-language-server-921-dev = mkDevShell ghc921;
269266

270267
# hls package
271268
haskell-language-server = mkExe ghcDefault;
272269
haskell-language-server-884 = mkExe ghc884;
273270
haskell-language-server-8107 = mkExe ghc8107;
274271
haskell-language-server-901 = mkExe ghc901;
272+
haskell-language-server-921 = mkExe ghc921;
275273

276274
# docs
277275
docs = docs;

flake_hackage/flake.nix

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
description = "Sources from hackage";
3+
4+
inputs = {
5+
lsp = {
6+
url = "https://hackage.haskell.org/package/lsp-1.4.0.0/lsp-1.4.0.0.tar.gz";
7+
flake = false;
8+
};
9+
lsp-types = {
10+
url = "https://hackage.haskell.org/package/lsp-types-1.4.0.0/lsp-types-1.4.0.0.tar.gz";
11+
flake = false;
12+
};
13+
lsp-test = {
14+
url = "https://hackage.haskell.org/package/lsp-test-0.14.0.2/lsp-test-0.14.0.2.tar.gz";
15+
flake = false;
16+
};
17+
ghc-exactprint = {
18+
url = "https://hackage.haskell.org/package/ghc-exactprint-1.4.1/ghc-exactprint-1.4.1.tar.gz";
19+
flake = false;
20+
};
21+
22+
constraints-extras = {
23+
url = "https://hackage.haskell.org/package/constraints-extras-0.3.2.1/constraints-extras-0.3.2.1.tar.gz";
24+
flake = false;
25+
};
26+
27+
retrie = {
28+
url = "https://hackage.haskell.org/package/retrie-1.2.0.1/retrie-1.2.0.1.tar.gz";
29+
flake = false;
30+
};
31+
32+
fourmolu = {
33+
url = "https://hackage.haskell.org/package/fourmolu-0.5.0.1/fourmolu-0.5.0.1.tar.gz";
34+
flake = false;
35+
};
36+
37+
hlint = {
38+
url = "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz";
39+
flake = false;
40+
};
41+
};
42+
43+
outputs = {self, ...}: {};
44+
}

0 commit comments

Comments
 (0)