-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
142 lines (127 loc) · 4.59 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
description = "Slacklinker Slack link bot";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:mercurytechnologies/flake-compat";
flake = false;
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig.allow-import-from-derivation = true; # cabal2nix uses IFD
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, ... }:
let
ghcVer = "ghc98";
out = system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
config.allowBroken = true;
config.allowUnfree = true;
};
inherit (pkgs) lib;
hsPkgs = pkgs.haskell.packages.${ghcVer};
in
{
packages = rec {
default = slacklinker;
slacklinker = pkgs.haskell.packages.${ghcVer}.slacklinker;
};
checks = {
inherit (self.packages.${system}) slacklinker;
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
# FIXME(jadel): fourmolu does not understand our language
# extensions. This is undoubtedly because it doesn't see a cabal
# file which is in turn undoubtedly because ours is gitignored.
# Maybe there is a better way to fix this?
tools.fourmolu = pkgs.writeShellScriptBin "fourmolu" ''
${lib.getExe hsPkgs.hpack}
${lib.getExe hsPkgs.fourmolu} "$@"
'';
hooks = {
fourmolu.enable = true;
};
};
};
# for debugging
inherit pkgs;
devShells.default =
hsPkgs.shellFor {
packages = p: [ self.packages.${system}.slacklinker ];
withHoogle = true;
buildInputs = with hsPkgs; [
haskell-language-server
fourmolu
# ghcid
cabal-install
graphql-client
# fast-tags
# friendly
] ++ (with pkgs; [
ngrok
sqlite
refinery-cli
postgresql
pgformatter # executable is called pg_format
cabal2nix
]);
shellHook = self.checks.${system}.pre-commit-check.shellHook;
};
};
in
flake-utils.lib.eachDefaultSystem out // {
# this stuff is *not* per-system
overlays = {
default = self: super: {
haskell = super.haskell // {
packages = super.haskell.packages // {
${ghcVer} = super.haskell.packages."${ghcVer}".override (oldArgs: {
overrides =
self.lib.fold
super.lib.composeExtensions
(oldArgs.overrides or (_: _: { }))
[ (self.haskell.lib.packageSourceOverrides {
slacklinker = ./.;
})
(self.haskell.lib.packagesFromDirectory {
directory = ./nix/deps;
})
(hself: hsuper: {
slacklinker =
import ./nix/build.nix
{ inherit super self hself hsuper;
werror = true;
testToolDepends = [
self.postgresql
self.refinery-cli
];
}
hsuper.slacklinker;
# broken bounds >:(
hoauth2 =
super.haskell.lib.doJailbreak hsuper.hoauth2;
tmp-postgres =
super.haskell.lib.dontCheck hsuper.tmp-postgres;
# possible macOS lack-of-sandbox related breakage
http2 =
if super.stdenv.isDarwin
then super.haskell.lib.dontCheck hsuper.http2
else hsuper.http2;
# some kinda weird test issues on macOS
port-utils =
super.haskell.lib.dontCheck hsuper.port-utils;
})
];
});
};
};
};
};
};
}