-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
63 lines (62 loc) · 2.15 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/63143ac2c9186be6d9da6035fa22620018c85932";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
}:
with flake-utils.lib;
eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
hpkgs = pkgs.haskell.packages.ghc96;
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
ormolu.enable = true;
hpack.enable = true;
};
tools = {
## NOTE: We want Ormolu to be exactly the one provided by HLS, but
## this Ormolu is actually a dependency of `hls-ormolu-plugin`,
## itself a dependency of HLS. We therefore define a function
## `getDeps` that gathers direct Haskell build dependencies and we
## use it to go get our Ormolu.
# ormolu = let
# getDeps = p:
# builtins.listToAttrs (map (dependency:
# pkgs.lib.nameValuePair dependency.pname dependency)
# p.passthru.getBuildInputs.haskellBuildInputs);
# in
# (getDeps
# (getDeps
# hpkgs.haskell-language-server)
# .hls-ormolu-plugin)
# .ormolu;
};
};
in {
formatter = pkgs.alejandra;
devShells = {
default = pkgs.mkShell {
## NOTE: `haskell-language-server` provides Ormolu, so there is no
## need to add it here. If it did not, we would have to resort to a
## trick such as the one used in `pre-commit-hooks`'s configuration
## above.
buildInputs = with hpkgs; [ghc hpack cabal-install ormolu haskell-language-server];
inherit (pre-commit) shellHook;
};
ci = pkgs.mkShell {
buildInputs = with hpkgs; [ghc cabal-install];
};
};
});
}