Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
232 lines (200 loc) Β· 6.26 KB
/
Copy pathTaskfile.yml
File metadata and controls
232 lines (200 loc) Β· 6.26 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
# https://taskfile.dev/styleguide/
# Avoid chaining commands with ; or && in a single line. Use multiple cmd items for independent steps, or write a script under scripts/ instead.
version: '3'
silent: false
# Don't use negated glob patterns. They often make hashing much slower.
tasks:
default:
deps:
- help
apply:
desc: Shorthand to rebuild NixOS or home-manager
cmds:
- |
if [ -f '/etc/NIXOS' ]; then
task nixos
else
task home-manager
fi
nixos:
desc: Enable NixOS config for current device
sources:
- '.env'
- 'flake.nix'
- 'flake.lock'
- 'nixos/**/*'
- 'overlays/**/*'
- 'home-manager/**/*'
- 'pkgs/**/*'
- 'config/**/*'
cmds:
- sudo nixos-rebuild switch --flake ".#$(hostname)" --show-trace
home-manager:
aliases:
- hm
desc: Enable home-manager config for current user and device
sources:
- '.env'
- 'flake.nix'
- 'flake.lock'
- 'overlays/**/*'
- 'home-manager/**/*'
- 'pkgs/**/*'
- 'config/**/*'
cmds:
# Using hostname simplify flake option, see https://discourse.nixos.org/t/get-hostname-in-home-manager-flake-for-host-dependent-user-configs/18859/2
# However prefer to use special ENV here for my current use. It is useful if sharing same config for similar env but on different devices
- nix run '.#home-manager' -- switch -b backup --show-trace --flake ".#${USER}@${HM_HOST_SLUG}"
test:
desc: Make sure NixOS and/or home-manager will work for current user and device
deps:
- test-go
- test-sample-nixos
- check-nixos
- test-home-session-vars
cmds:
- ./scripts/dry.bash
test-home-session-vars:
desc: Verify non-NixOS Home Manager session variables in sandbox
cmds:
- nix-build scripts/test-home-session-vars.nix --no-out-link
check-nixos:
desc: Dry-run all NixOS configurations in this repository
cmds:
- nix build .#nixosConfigurations.moss.config.system.build.toplevel --dry-run
- nix build .#nixosConfigurations.algae.config.system.build.toplevel --dry-run
- nix build .#nixosConfigurations.desktop-free.config.system.build.toplevel --dry-run
- nix build .#nixosConfigurations.wsl.config.system.build.toplevel --dry-run
- nix build .#nixosConfigurations.sandbox.config.system.build.toplevel --dry-run
test-sample-nixos:
desc: Verify the sample NixOS configuration template
cmds:
- ./nixos/hosts/sample/verify.bash
test-go:
sources:
- '**/*.go'
- 'config/**/*'
cmds:
- go test ./...
mkdir:
internal: true
cmds:
- mkdir -p dist/race
setup:
desc: You should run this task just after cloned
deps:
- help
- build-cmd
cmds:
- git config --local include.path ../.gitconfig
# Check commands
- git config --list --local --includes --show-origin
- git hook list pre-commit
fmt:
cmds:
- dprint fmt
build-cmd:
deps:
- mkdir
sources:
- '**/*.go'
- 'go.mod'
- 'go.sum'
generates:
- dist/**
# Checking race condition requires CGO_ENABLED=1 and gcc. See https://github.com/golang/go/issues/9918
cmds:
- go build -v -o dist ./...
lint:
deps:
- build-cmd
cmds:
- ./dist/lint
lint-all:
desc: Includes heavy linters
deps:
- build-cmd
cmds:
- ./dist/lint -all
sync-workflows:
aliases:
- sync-packages
desc: Synchronize workflow files with pkgs/list.toml
cmds:
- go run ./cmd/ci-build sync-workflows
- dprint fmt .github/workflows/nix.yml .github/workflows/update-local-packages.yml
check-sync-workflows:
internal: true
cmds:
- go run ./cmd/ci-build sync-workflows --check
check:
deps:
- 'build-cmd'
- 'test'
- 'lint-all'
- 'check-sync-workflows'
update:
desc: Bump dependencies
cmds:
- nix flake update
- nix run .#dedup-flake-inputs
- |
if ! git diff --exit-code flake.nix flake.lock > /dev/null; then
git commit --no-gpg-sign -m "flake.lock: Update" flake.nix flake.lock
fi
- nix run .#bump_gomod -- .
help:
desc: If forgot anything
cmds:
- task --list-all
workspace:
desc: Open Terminal Multiplexer that configured to maintain this repository
cmds:
- zellij --layout ./config/zellij/layouts/dotfiles.kdl
sandbox:
desc: Run container
cmds:
- ./containers/sandbox.bash
get-ghcr-token:
desc: Get public token. You can use as `task get-ghcr-token >> .env`
# https://github.com/orgs/community/discussions/26279#discussioncomment-3251171
cmds:
- echo "GHCR_READONLY_TOKEN=$(curl https://ghcr.io/token\?scope\="repository:kachick/home:pull" | jq .token)"
ghcr:
# It looks like no paging and sorting API. So keep feawest than last 50 images
# Now it is cared in deployment workflow (container.yml) via reusable cleanup-ghcr workflow
desc: Run container with selecting the tag with fuzzy finder
cmds:
- |
curl -H "Authorization: Bearer ${GHCR_READONLY_TOKEN}" https://ghcr.io/v2/kachick/home/tags/list | jq -r '.tags | map(select(. | contains("utc"))) | reverse | .[]' | fzf --bind 'enter:become(task ghcr-{})'
ghcr-*:
desc: Run container which is built and registered via GitHub Actions
vars:
TAG: '{{index .MATCH 0}}'
cmds:
- './containers/sandbox.bash --ghcr {{.TAG}}'
build-container:
cmds:
- './containers/build.bash'
test-container:
desc: Run container smoke tests against local or GHCR image
vars:
IMAGE: '{{.IMAGE | default "localhost/provisioned-systemd-home"}}'
cmds:
- './containers/test.bash {{.IMAGE}}'
load-container-layered:
desc: Build and stream-load the layered container image into podman
cmds:
- |
stream_path="$(nix build .#container-layered.passthru.stream --no-link --print-out-paths)"
"$stream_path" | podman load
ci-dev:
desc: Provided for CI
deps:
- 'default'
- 'setup'
# 'test-sample-nixos' # Run in nix workflow in GHA
# 'test', # Needs home-manager, so needless in Nix-CI
- 'test-go'
- 'lint-all'
- 'test-home-session-vars'