-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
173 lines (171 loc) · 5.22 KB
/
flake.nix
File metadata and controls
173 lines (171 loc) · 5.22 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
{
description = "nullkomma";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*";
# keep-sorted start
fh.url = "https://flakehub.com/f/DeterminateSystems/fh/0.1.*";
flake-checker.url = "https://flakehub.com/f/DeterminateSystems/flake-checker/0.2.*";
flake-iter.url = "https://flakehub.com/f/DeterminateSystems/flake-iter/0.1.*";
# keep-sorted end
flake-parts = {
inputs.nixpkgs-lib.follows = "nixpkgs";
url = "https://flakehub.com/f/hercules-ci/flake-parts/0.1.*";
};
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/0.1.*";
nix-unit = {
url = "github:nix-community/nix-unit/?tag=v2.24.1";
inputs = {
flake-parts.follows = "flake-parts";
nixpkgs.follows = "nixpkgs";
};
};
treefmt-nix.url = "github:numtide/treefmt-nix/3d0579f5cc93436052d94b73925b48973a104204";
};
outputs =
{ flake-parts, self, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
# keep-sorted start
inputs.nix-unit.modules.flake.default
inputs.treefmt-nix.flakeModule
# keep-sorted end
];
systems = [
# keep-sorted start
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
# keep-sorted end
];
perSystem =
{
inputs',
pkgs,
self',
...
}:
{
checks = {
test-template-bad-readme =
pkgs.runCommand "test-bad-readme"
{
buildInputs = [
pkgs.nix
];
__noChroot = true;
NIX_CONFIG = "experimental-features = nix-command flakes";
}
''
mkdir -p $TMPDIR/home
export HOME=$TMPDIR/home
# cd $tmp
nix flake init --template ${self}#default
echo "bad _markdown*" > README.md
if ! nix flake check; then
touch $out
else
echo "Test failed: nix flake check succeeded unexpectedly"
exit 1
fi
'';
test-template-good-readme =
pkgs.runCommand "test-good-readme"
{
buildInputs = [
pkgs.nix
];
__noChroot = true;
NIX_CONFIG = "experimental-features = nix-command flakes";
}
''
mkdir -p $TMPDIR/home
export HOME=$TMPDIR/home
# cd $tmp
nix flake init --template ${self}#default
echo "good *markdown*" > README.md
if nix flake check; then
touch $out
else
echo "Test failed: nix flake check failed unexpectedly"
exit 1
fi
'';
};
devShells.default = pkgs.mkShell {
packages = [
# keep-sorted start
inputs'.fh.packages.default
inputs'.flake-checker.packages.default
inputs'.flake-iter.packages.default
pkgs.git
pkgs.gnumake
pkgs.nixd
self'.formatter
# keep-sorted end
];
};
treefmt = {
programs = {
# keep-sorted start
actionlint.enable = true;
beautysh.enable = true;
black.enable = true;
cmake-format.enable = true;
deadnix.enable = true;
hclfmt.enable = true;
isort.enable = true;
jsonfmt.enable = true;
keep-sorted.enable = true;
mdformat.enable = true;
nixfmt.enable = true;
prettier.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
sqlfluff.enable = true;
toml-sort.enable = true;
yamlfmt.enable = true;
# keep-sorted end
};
};
nix-unit = {
inputs = {
inherit (inputs)
nixpkgs
flake-parts
nix-unit
treefmt-nix
;
};
tests = {
"test example system-specific" = {
expr = "1";
expected = "1";
};
};
};
};
flake = {
schemas = inputs.flake-schemas.schemas;
templates = rec {
base = {
description = "nullkomma template";
path = ./templates/base;
welcomeText = ''
Welcome to the nullkomma template
'';
};
default = base;
};
tests = {
"test example system-agnostic" = {
expr = "2";
expected = "2";
};
"test template welcome text" = {
expr = self.templates.default.description;
expected = "nullkomma template";
};
};
};
};
}