-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
200 lines (172 loc) Β· 4.91 KB
/
Taskfile.yml
File metadata and controls
200 lines (172 loc) Β· 4.91 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
# https://taskfile.dev
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
cmds:
- ./scripts/dry.bash
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.wsl.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:
- cp .githooks/* .git/hooks/
- git config --local core.whitespace cr-at-eol
fmt:
cmds:
- treefmt
build-cmd:
deps:
- mkdir
sources:
- ./cmd/**.go
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 ./...
build-lint:
internal: true
deps:
- mkdir
cmds:
- go build -v -o dist/lint ./cmd/lint
sources:
- internal/**/*.go
- ./cmd/lint/*.go
generates:
- dist/lint
lint:
deps:
- build-lint
cmds:
- ./dist/lint
lint-all:
desc: Includes heavy linters
deps:
- build-lint
cmds:
- ./dist/lint -all
check:
deps:
- 'build-cmd'
- 'test'
- 'lint-all'
update:
desc: Bump dependencies
cmds:
- nix flake update --commit-lock-file
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, it triggers https://github.com/kachick/dotfiles/actions/workflows/cleanup-github-packages.yml
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-with-ghcr.bash {{.TAG}}'
build-container:
cmds:
- './containers/build.bash'
ci-dev:
desc: Provided for CI
deps:
- 'default'
- 'setup'
# 'test-sample-nixos' # Run as a dedicated job in GHA
# 'test', # Needs home-manager, so needless in Nix-CI
- 'lint-all'
- 'fmt'
ci-darwin:
desc: Basically giveup to develop on macOS. However I need to use task-runner for minimum use.
cmds:
- task --version