-
Notifications
You must be signed in to change notification settings - Fork 29
/
flake.nix
111 lines (111 loc) · 3.2 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
{
description = "nix-output-monitor";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
inherit (nixpkgs.legacyPackages.${system})
lib
haskell
pkgs
haskellPackages
;
hlib = (_: haskell.lib.compose) system;
golden-tests = import ./test/golden/all.nix;
cleanSelf = lib.sourceFilesBySuffices self [
".hs"
".cabal"
"stderr"
"stdout"
"stderr.json"
"stdout.json"
".zsh"
".bash"
"LICENSE"
"CHANGELOG.md"
"default.nix"
];
in
rec {
packages = {
default = lib.pipe { } [
(haskellPackages.callPackage self)
haskellPackages.buildFromCabalSdist
hlib.justStaticExecutables
(hlib.appendConfigureFlag "--ghc-option=-Werror")
(hlib.overrideCabal {
src = cleanSelf;
doCheck = system == "x86_64-linux";
preCheck = ''
# ${lib.concatStringsSep ", " (golden-tests ++ map (x: x.drvPath) golden-tests)}
export TESTS_FROM_FILE=true;
'';
buildTools = [ pkgs.installShellFiles ];
postInstall = ''
ln -s nom "$out/bin/nom-build"
ln -s nom "$out/bin/nom-shell"
chmod a+x $out/bin/nom-shell
installShellCompletion completions/*
'';
})
];
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
hlint.enable = true;
nixfmt = {
excludes = [ "default.nix" ];
package = lib.getBin pkgs.nixfmt-rfc-style;
};
statix.enable = true;
cabal2nix.enable = true;
editorconfig-checker = {
enable = true;
excludes = [ ".*\\.md" ];
};
fourmolu.enable = true;
ormolu.settings.defaultExtensions = [
"TypeApplications"
"BangPatterns"
"ImportQualifiedPost"
"BlockArguments"
];
cabal-fmt.enable = true;
shellcheck = {
enable = true;
excludes = [ "\\.zsh" ];
};
};
};
};
devShells.default = haskellPackages.shellFor {
packages = _: [ packages.default ];
buildInputs = [
pre-commit-hooks.packages.${system}.default
haskellPackages.haskell-language-server
pkgs.haskell.packages.ghc92.weeder
pkgs.haskellPackages.cabal-install
pkgs.pv
];
withHoogle = true;
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
}
);
}