Skip to content

nix: add support for ghc 9.0.1 #1995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ jobs:
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
- name: Build development shell
run: nix develop --profile dev
- name: Build development shell (GHC 9.0.1)
run: nix develop .#haskell-language-server-901-dev --profile dev
- name: Push development shell
if: ${{ env.HAS_TOKEN == 'true' }}
run: cachix push haskell-language-server dev
- name: Build binaries
run: nix build
- name: Build binaries (GHC 9.0.1)
run: nix build .#haskell-language-server-901
- name: Push binaries
if: ${{ env.HAS_TOKEN == 'true' }}
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server
7 changes: 7 additions & 0 deletions cabal-ghc901.project
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ source-repository-package
subdir: lsp-test
-- https://github.com/haskell/lsp/pull/312

-- benchmark dependency
source-repository-package
type: git
location: https://github.com/berberman/operational
tag: 0e062895678f49fd673ae493371262cfb8c5ab56
-- https://github.com/HeinrichApfelmus/operational/pull/26

write-ghc-environment-files: never

index-state: 2021-06-30T16:00:00Z
Expand Down
128 changes: 128 additions & 0 deletions configuration-ghc-901.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# nix version of cabal-ghc901.project
{ pkgs }:

let
disabledPlugins = [
"hls-tactics-plugin"
"hls-brittany-plugin"
"hls-stylish-haskell-plugin"
"hls-fourmolu-plugin"
"hls-splice-plugin"
"hls-ormolu-plugin"
"hls-eval-plugin"
"hls-class-plugin"
"hls-refine-imports-plugin"
];

hpkgsOverride = hself: hsuper:
with pkgs.haskell.lib;
let
lsp-src = pkgs.fetchFromGitHub {
owner = "anka-213";
repo = "lsp";
rev = "tag-ghc-9.0.1-without-pr-326";
sha256 = "lW/EdBnvKPLE2+CGE/grIekOu+U/Wh6zMCN4xhJDtPY=";
};

dependent-sum-src = pkgs.fetchFromGitHub {
owner = "anka-213";
repo = "dependent-sum";
rev = "8cf4c7fbc3bfa2be475a17bb7c94a1e1e9a830b5";
sha256 = "WtxTB6ufTZC6SxOtGSfhlO4mY0y9eWejMSa0yUJ7dHQ=";
};
in {
blaze-textual = hself.callCabal2nix "blaze-textual"
(pkgs.fetchFromGitHub {
owner = "jwaldmann";
repo = "blaze-textual";
rev = "d8ee6cf80e27f9619d621c936bb4bda4b99a183f";
sha256 = "C0dIzf64fBaY8mlhMm1kCQC5Jc1wKBtNO2Y24k7YPUw=";
}) { };

czipwith = hself.callCabal2nix "czipwith" (pkgs.fetchFromGitHub {
owner = "mithrandi";
repo = "czipwith";
rev = "b6245884ae83e00dd2b5261762549b37390179f8";
sha256 = "2uSoGyrxT/OstRcpx55kwP4JwjPbWLxD72LajeyQV0E=";
}) { };

hie-bios = hself.callCabal2nix "hie-bios" (pkgs.fetchFromGitHub {
owner = "jneira";
repo = "hie-bios";
rev = "9b1445ab5efcabfad54043fc9b8e50e9d8c5bbf3";
sha256 = "8ct7t3xIxIAoC+f8VO5e5+QKrd5L5Zu1eButSaE+1Uk=";
}) { };

ghc-api-compat = hself.callCabal2nix "ghc-api-compat"
(pkgs.fetchFromGitHub {
owner = "hsyl20";
repo = "ghc-api-compat";
rev = "8fee87eac97a538dbe81ff1ab18cff10f2f9fa15";
sha256 = "byehvdxQxhNk5ZQUXeFHjAZpAze4Ct9261ro4c5acZk=";
}) { };

th-extras = hself.callCabal2nix "th-extras" (pkgs.fetchFromGitHub {
owner = "anka-213";
repo = "th-extras";
rev = "57a97b4df128eb7b360e8ab9c5759392de8d1659";
sha256 = "Qtha1ge/C0L+uFcV2dZ5xpG59DCxQT7LuK/OYfiM4Pk=";
}) { };

lsp = hself.callCabal2nix "lsp" "${lsp-src}/lsp" { };
lsp-types = hself.callCabal2nix "lsp-types" "${lsp-src}/lsp-types" { };
lsp-test = hself.callCabal2nix "lsp-test" "${lsp-src}/lsp-test" { };

dependent-sum =
hself.callCabal2nix "dependent-sum" "${dependent-sum-src}/dependent-sum"
{ };

dependent-sum-template = hself.callCabal2nix "dependent-sum-template"
"${dependent-sum-src}/dependent-sum-template" { };

hlint = hself.hlint_3_3_1;

ghc-lib-parser = hself.ghc-lib-parser_9_0_1_20210324;

ghc-lib-parser-ex = hself.ghc-lib-parser-ex_9_0_0_4;

operational = hself.callCabal2nix "operational" (pkgs.fetchFromGitHub {
owner = "berberman";
repo = "operational";
rev = "0e062895678f49fd673ae493371262cfb8c5ab56";
sha256 = "P+aocEcqCN8klnW3IMrmIqq6ztBZJxk4sBp1ewN6YaA=";
}) { };

diagrams-core = hself.diagrams-core_1_5_0;

diagrams-lib = hself.diagrams-lib_1_4_4;

dual-tree = hself.dual-tree_0_2_3_0;

monoid-extras = hself.monoid-extras_0_6;

# Re-generate HLS drv excluding some plugins
haskell-language-server =
hself.callCabal2nixWithOptions "haskell-language-server" ./.
(pkgs.lib.concatStringsSep " " [
"-f-brittany"
"-f-class"
"-f-eval"
"-f-fourmolu"
"-f-ormolu"
"-f-splice"
"-f-stylishhaskell"
"-f-tactic"
"-f-refineImports"
]) { };

# YOLO
mkDerivation = args:
hsuper.mkDerivation (args // {
jailbreak = true;
doCheck = false;
});
};
in {
inherit disabledPlugins;
tweakHpkgs = hpkgs: hpkgs.extend hpkgsOverride;
}
61 changes: 34 additions & 27 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@
overlay = final: prev:
with prev;
let
haskellOverrides = {
overrides = hself: hsuper: {
# we override mkDerivation here to apply the following
# tweak to each haskell package:
# if the package is broken, then we disable its check and relax the cabal bounds;
# otherwise, we leave it unchanged.
# hopefully, this could fix packages marked as broken by nix due to check failures
# or the build failure because of tight cabal bounds
mkDerivation = args:
let
broken = args.broken or false;
check = args.doCheck or true;
jailbreak = args.jailbreak or false;
in hsuper.mkDerivation (args // {
jailbreak = if broken then true else jailbreak;
doCheck = if broken then false else check;
});
};
haskellOverrides = hself: hsuper: {
# we override mkDerivation here to apply the following
# tweak to each haskell package:
# if the package is broken, then we disable its check and relax the cabal bounds;
# otherwise, we leave it unchanged.
# hopefully, this could fix packages marked as broken by nix due to check failures
# or the build failure because of tight cabal bounds
mkDerivation = args:
let
broken = args.broken or false;
check = args.doCheck or true;
jailbreak = args.jailbreak or false;
in hsuper.mkDerivation (args // {
jailbreak = if broken then true else jailbreak;
doCheck = if broken then false else check;
});
};
gitignoreSource = (import gitignore { inherit lib; }).gitignoreSource;

Expand Down Expand Up @@ -91,7 +89,10 @@
builtins.mapAttrs (_: dir: gitignoreSource dir) sourceDirs;

extended = hpkgs:
(hpkgs.override haskellOverrides).extend (hself: hsuper:
(hpkgs.override (old: {
overrides = lib.composeExtensions (old.overrides or (_: _: { }))
haskellOverrides;
})).extend (hself: hsuper:
# disable all checks for our packages
builtins.mapAttrs (_: drv: haskell.lib.dontCheck drv)
(lib.composeExtensions
Expand Down Expand Up @@ -135,7 +136,7 @@
hooks = {
stylish-haskell.enable = true;
# use stylish-haskell with our target ghc
stylish-haskell.entry = "${hpkgs.stylish-haskell}/bin/stylish-haskell --inplace";
stylish-haskell.entry = pkgs.lib.mkForce "${hpkgs.stylish-haskell}/bin/stylish-haskell --inplace";
stylish-haskell.excludes = [
# Ignored files
"^Setup.hs$"
Expand All @@ -156,14 +157,16 @@
};
};

ghc901Config = (import ./configuration-ghc-901.nix) { inherit pkgs; };

# GHC versions
ghcDefault = pkgs.hlsHpkgs ("ghc"
+ pkgs.lib.replaceStrings [ "." ] [ "" ]
pkgs.haskellPackages.ghc.version);
ghc884 = pkgs.hlsHpkgs "ghc884";
ghc8104 = pkgs.hlsHpkgs "ghc8104";
ghc8105 = pkgs.hlsHpkgs "ghc8105";
ghc901 = pkgs.hlsHpkgs "ghc901";
ghc901 = ghc901Config.tweakHpkgs (pkgs.hlsHpkgs "ghc901");

# Create a development shell of hls project
# See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319
Expand All @@ -173,13 +176,17 @@
doBenchmark = true;
packages = p:
with builtins;
map (name: p.${name}) (attrNames hlsSources);
map (name: p.${name}) (attrNames
(if hpkgs.ghc.version == "9.0.1" then
removeAttrs hlsSources ghc901Config.disabledPlugins
else
hlsSources));
buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs hpkgs) ]
++ (with hpkgs; [
cabal-install
hlint
ormolu
stylish-haskell
# ormolu
# stylish-haskell
opentelemetry-extra
]);

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

# hls package
haskell-language-server = mkExe ghcDefault;
haskell-language-server-884 = mkExe ghc884;
haskell-language-server-8104 = mkExe ghc8104;
haskell-language-server-8105 = mkExe ghc8105;
haskell-language-server-901 = builtins.throw "Nix expression for building HLS in GHC 9.0.1 is not yet available"; # mkExe ghc901;
haskell-language-server-901 = mkExe ghc901;
};

defaultPackage = packages.haskell-language-server;
Expand Down
5 changes: 5 additions & 0 deletions stack-9.0.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ extra-deps:
commit: ca23431a8dfa013992f9164ccc882a3277361f17
# https://github.com/diagrams/active/pull/36

# benchmark dependency
- github: berberman/operational
commit: 0e062895678f49fd673ae493371262cfb8c5ab56
# https://github.com/HeinrichApfelmus/operational/pull/26

configure-options:
ghcide:
- --disable-library-for-ghci
Expand Down