-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
115 lines (100 loc) · 3.52 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
{
description = "apropos";
inputs = {
haskell-nix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
haskell-nix.inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
flake-compat-ci.url = "github:hercules-ci/flake-compat-ci";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, haskell-nix, flake-compat, flake-compat-ci }:
let
supportedSystems =
[ "x86_64-linux" ];
perSystem = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = system:
import nixpkgs {
inherit system;
overlays = [ haskell-nix.overlay ];
inherit (haskell-nix) config;
};
nixpkgsFor' = system: import nixpkgs { inherit system; };
compiler-nix-name = "ghc924";
fourmoluFor = system: (nixpkgsFor system).haskell-nix.tool "ghc924" "fourmolu" { };
projectFor = system:
let
deferPluginErrors = true;
pkgs = nixpkgsFor system;
fakeSrc = pkgs.runCommand "real-source" { } ''
cp -rT ${self} $out
chmod u+w $out/cabal.project
'';
in
(nixpkgsFor system).haskell-nix.cabalProject' {
inherit compiler-nix-name;
src = fakeSrc.outPath;
cabalProjectFileName = "cabal.project";
modules = [{ packages = { }; }];
shell = {
withHoogle = true;
tools.haskell-language-server = { };
exactDeps = true;
# We use the ones from Nixpkgs, since they are cached reliably.
# Eventually we will probably want to build these with haskell.nix.
nativeBuildInputs =
[
pkgs.cabal-install
pkgs.hlint
(fourmoluFor system)
pkgs.nixpkgs-fmt
pkgs.haskellPackages.cabal-fmt
pkgs.haskellPackages.apply-refact
pkgs.fd
];
additional = ps: [
ps.digraph
];
};
sha256map = {
"https://github.com/mlabs-haskell/digraph"."32afdad81d02301c6c6f37f2a2e6e9e7f3bdc9eb" = "sha256-eN1wEkd/gAoQHARck/F5US7L4OPJisc9glWxNkvHaF8=";
};
};
formatCheckFor = system:
let
pkgs = nixpkgsFor system;
in
pkgs.runCommand "format-check"
{
nativeBuildInputs = [ self.devShell.${system}.nativeBuildInputs ];
} ''
cd ${self}
export LC_CTYPE=C.UTF-8
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export IN_NIX_SHELL='pure'
make format_check cabalfmt_check nixpkgsfmt_check lint
mkdir $out
'';
in
{
project = perSystem projectFor;
flake = perSystem (system: (projectFor system).flake { });
# this could be done automatically, but would reduce readability
packages = perSystem (system: self.flake.${system}.packages);
checks = perSystem (system:
self.flake.${system}.checks // {
formatCheck = formatCheckFor system;
});
check = perSystem (system:
(nixpkgsFor system).runCommand "combined-test"
{
nativeBuildInputs = builtins.attrValues self.checks.${system};
} "touch $out");
apps = perSystem (system: self.flake.${system}.apps);
devShell = perSystem (system: self.flake.${system}.devShell);
herculesCI.ciSystems = [ "x86_64-linux" ];
};
}