-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake-module.nix
More file actions
197 lines (174 loc) · 5.17 KB
/
Copy pathflake-module.nix
File metadata and controls
197 lines (174 loc) · 5.17 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
{inputs, ...}: {
imports = [
inputs.files.flakeModules.default
];
perSystem = {
config,
system,
pkgs,
lib,
...
}: {
devShells.default = pkgs.mkShell {
packages = let
hk = inputs.hk.packages.${system}.hk.overrideAttrs (_old: {
doCheck = false;
});
in
with pkgs; [
# Core tools
yq-go
hk
# Nix formatters and linters
alejandra
deadnix
statix
# GitHub Actions linter
actionlint
# Configuration formatters
pkl
# Commit message linters
gitlint
];
shellHook = ''
# Ensure git hooks are installed (skip in worktrees)
if [ -d .git ]; then
if ! output=$(hk install 2>&1); then
exit_code=$?
echo "$output" >&2
exit $exit_code
fi
fi
'';
};
# Configure files module to sync generated workflows to .github/workflows/
files.files =
lib.mapAttrsToList (name: drv: {
path_ = ".github/workflows/${name}";
inherit drv;
})
config.githubActions.workflowFiles;
# Expose the files writer as an app
apps.write-files = {
type = "app";
program = lib.getExe config.files.writer.drv;
meta.description = "Write generated files to the repository";
};
# CI workflow configuration - dogfooding the github-actions-nix module
githubActions = {
enable = true;
workflows = {
ci = {
name = "CI";
on = {
pullRequest = {};
workflowDispatch = {};
push = {
branches = ["master"];
tags = ["v[0-9]+.[0-9]+.[0-9]+*"];
};
};
concurrency = {
group = "\${{ github.workflow }}-\${{ github.event.pull_request.number || github.ref }}";
cancelInProgress = true;
};
jobs = {
nix-ci = {
uses = "DeterminateSystems/ci/.github/workflows/workflow.yml@main";
permissions = {
id-token = "write";
contents = "read";
};
with_ = {
# Publish to FlakeHub only on version tags. The reusable workflow
# publishes whenever `visibility` is non-empty (on the default
# branch or a tag); leaving it empty on master/PR runs keeps
# build + check while suppressing rolling releases. Tagged pushes
# set it to "public" so the tag's SemVer version is published.
visibility = "\${{ startsWith(github.ref, 'refs/tags/') && 'public' || '' }}";
};
};
};
};
flake-checker = {
name = "Flake Checker";
on = {
pullRequest = {};
workflowDispatch = {};
push.branches = ["master"];
};
jobs = {
check = {
runsOn = "warp-ubuntu-latest-arm64-2x";
permissions = {
id-token = "write";
contents = "read";
};
steps = [
{
uses = "actions/checkout@v4";
}
{
uses = "DeterminateSystems/determinate-nix-action@v3";
}
{
uses = "DeterminateSystems/flakehub-cache-action@main";
}
{
uses = "DeterminateSystems/flake-checker-action@main";
}
{
run = "nix flake check";
}
];
};
};
};
update-flake-lock = {
name = "Update flake.lock";
on = {
workflowDispatch = {};
schedule = [
{cron = "0 0 * * 0";} # Weekly on Sunday at midnight
];
};
permissions = {
id-token = "write";
contents = "write";
pull-requests = "write";
};
jobs = {
update = {
runsOn = "warp-ubuntu-latest-arm64-2x";
steps = [
{
uses = "actions/checkout@v4";
}
{
uses = "DeterminateSystems/determinate-nix-action@v3";
}
{
id = "update";
name = "Update flake.lock";
uses = "DeterminateSystems/update-flake-lock@main";
with_ = {
pr-title = "chore: update flake.lock";
pr-labels = "dependencies\nautomated";
};
}
{
name = "Enable automerge";
if_ = "steps.update.outputs.pull-request-number != ''";
run = "gh pr merge --auto --rebase \${{ steps.update.outputs.pull-request-number }}";
env = {
GH_TOKEN = "\${{ secrets.GH_TOKEN_FOR_UPDATES }}";
};
}
];
};
};
};
};
};
};
}