-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
121 lines (106 loc) · 4.38 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{ inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/23.05";
utils.url = github:numtide/flake-utils;
};
outputs = { nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
utils.lib.eachSystem [ "ghc90" "ghc92" "ghc94" "ghc96" ] (compiler:
let
config = { };
overlay = self: super: {
haskell = super.haskell // {
packages = super.haskell.packages // {
"${compiler}" = super.haskell.packages."${compiler}".override (old: {
overrides =
self.lib.fold
self.lib.composeExtensions
(_: _: { })
[ (self.haskell.lib.packageSourceOverrides {
hlint = {
ghc90 = "3.3.6";
ghc92 = "3.4.1";
ghc94 = "3.5";
# The following line is not actually used because the
# Nixpkgs version we're on doesn't include
# `hlint-3.6.1`, yet. Instead, the actual
# `hlint-3.6.1` build comes from `ghc96/hlint.nix`.
# Once we upgrade to a new enough Nixpkgs we can
# delete that file and then the following line will
# kick in and work.
ghc96 = "3.6.1";
}."${compiler}";
hlint-plugin =
self.lib.cleanSourceWith
{ filter = name: type:
self.lib.cleanSourceFilter name type
&& !(self.lib.hasSuffix ".nix" name)
&& !(builtins.baseNameOf name == "README.md");
src = ./.;
};
})
(self.haskell.lib.packagesFromDirectory {
directory = {
ghc90 = ./ghc90;
ghc92 = ./ghc92;
ghc94 = ./ghc94;
ghc96 = ./ghc96;
}."${compiler}";
})
# `ghc-lib-parser-ex` and `hlint` both need to be built
# against the `ghc` API and not the `ghc-lib*` APIs,
# otherwise the built plugin will not be accepted by GHC.
(hself: hsuper: {
ghc-lib-parser-ex =
self.haskell.lib.enableCabalFlag
hsuper.ghc-lib-parser-ex
"no-ghc-lib";
hlint =
self.haskell.lib.disableCabalFlag
hsuper.hlint
"ghc-lib";
})
];
});
};
};
};
pkgs =
import nixpkgs { inherit config system; overlays = [ overlay ]; };
in
rec {
packages = pkgs.haskell.packages."${compiler}".hlint-plugin;
checks =
let
module = pkgs.writeText "Main.hs"
''
{-# LANGUAGE OverloadedStrings #-}
main :: IO ()
main | otherwise = (mempty)
'';
expected = pkgs.writeText "expected.txt"
''
Main.hs:4:20: warning:
Redundant bracket
Perhaps: mempty
|
4 | main | otherwise = (mempty)
| ^^^^^^^^
'';
in
pkgs.runCommand "hlint-plugin-${compiler}-test"
{ nativeBuildInputs = [
(pkgs.haskell.packages."${compiler}".ghcWithPackages
(pkgs: [ pkgs.hlint-plugin ])
)
];
}
''
ln --symbolic ${module} Main.hs
ghc -fplugin HLint.Plugin -fplugin-opt='HLint.Plugin:--ignore=Redundant guard' -Wno-missed-extra-shared-lib -c Main.hs 2> >(tee actual.txt >&2)
diff ${expected} actual.txt
touch $out
'';
devShells = pkgs.haskell.packages."${compiler}".hlint-plugin.env;
}
));
}