-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathflake.nix
More file actions
236 lines (194 loc) · 6.63 KB
/
flake.nix
File metadata and controls
236 lines (194 loc) · 6.63 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
{
description = "A data type for optional values";
inputs = {
flake-parts = {
inputs = {
nixpkgs-lib = {
follows = "nixpkgs";
};
};
owner = "hercules-ci";
ref = "main";
repo = "flake-parts";
type = "github";
};
git-hooks_nix = {
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
owner = "cachix";
ref = "master";
repo = "git-hooks.nix";
type = "github";
};
nixpkgs = {
owner = "NixOS";
ref = "nixos-unstable";
repo = "nixpkgs";
type = "github";
};
treefmt-nix = {
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
owner = "numtide";
ref = "main";
repo = "treefmt-nix";
type = "github";
};
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
# The `git-hooks_nix` module will play nicely with the `treefmt-nix` module.
# It will take the configuration we supply,
# and use it appropriately instead of competing with it.
inputs.git-hooks_nix.flakeModule
# The `treefmt-nix` module will set the `formatter` to `treefmt`.
# This lets `nix fmt` use our configuration for `treefmt`.
inputs.treefmt-nix.flakeModule
];
perSystem =
{ config, pkgs, ... }:
{
devShells = {
default = pkgs.mkShellNoCC {
inputsFrom = [
# Include the shell from `git-hooks_nix`.
# This makes all `pre-commit` binaries (include `pre-commit`) available in the shell.
config.pre-commit.devShell
# Include the shell from `treefmt`.
# This makes all `treefmt` binaries (including `treefmt`) available in the shell.
config.treefmt.build.devShell
];
nativeBuildInputs =
[
pkgs.coreutils
pkgs.findutils
pkgs.gnumake
pkgs.nodejs_22
]
# The version of PureScript we use doesn't have pre-built binaries for ARM architectures.
# The `npm` package will fall back to building from source,
# but we need somre more dependencies in order to do that.
# We should be able to remove this once we update to at least version [0.15.9](https://github.com/purescript/purescript/releases/tag/v0.15.9) of PureScript,
# as this was the first version to start producing pre-built ARM binaries: https://github.com/purescript/purescript/pull/4455.
++ pkgs.lib.lists.optionals pkgs.stdenv.hostPlatform.isAarch [
pkgs.llvmPackages_12.libcxxClang
pkgs.llvmPackages_12.libllvm
pkgs.stack
];
};
};
pre-commit = {
settings = {
default_stages = [
"pre-commit"
"pre-push"
];
hooks = {
# Check `.github/workflows` code.
actionlint = {
enable = true;
};
# Check Nix code for anything that is unused.
deadnix = {
enable = true;
};
# Check that we're not accidentally committing AWS credentials.
detect-aws-credentials = {
enable = true;
};
# Check that we're not accidentally committing private keys
detect-private-keys = {
enable = true;
};
# Git submodules are nothing but a can of worms that fails in some non-obvious way each time they're used.
forbid-new-submodules = {
enable = true;
};
# Check markdown files for consistency.
markdownlint = {
enable = true;
settings = {
configuration = {
MD013 = {
# We'd like to use something like `wrap:inner-sentence`:
# https://cirosantilli.com/markdown-style-guide/#option-wrap-inner-sentence,
# or something related to SemBr: https://sembr.org/.
# But that's stymied in an issue: https://github.com/DavidAnson/markdownlint/issues/298.
#
# We set the line length to something large enough to not get hit by it regularly.
line_length = 1000;
};
};
};
};
# While `nil` is a language server,
# it also has come static analysis we want to check.
nil = {
enable = true;
};
# Check for any common mistakes in Shell code we write.
shellcheck = {
enable = true;
};
# Check that we're not making any simple typos in prose.
# This checks not just plain text files (like Markdown),
# but also comments in source code like this comment you're reading right now.
typos = {
enable = true;
};
};
};
};
treefmt = {
programs = {
# Format JSON code consistently.
jsonfmt = {
enable = true;
};
# Format Markdown code consistently.
mdformat = {
enable = true;
};
# Format Nix code consistently.
nixfmt = {
enable = true;
};
# Format PureScript code consistently.
purs-tidy = {
enable = true;
includes = [ "*.purs" ];
};
# Format Shell code consistently.
shfmt = {
enable = true;
};
# Format YAML code consistently.
yamlfmt = {
enable = true;
};
};
settings.global.excludes = [
".direnv/*"
".jj/*"
"bower_components/*"
"node_modules/*"
"output/*"
];
};
};
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
};
}