-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
179 lines (147 loc) · 4.36 KB
/
Copy pathjustfile
File metadata and controls
179 lines (147 loc) · 4.36 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
flake := env('FLAKE', justfile_directory())
# rebuild is also set as a var so you can add --set to change it if you need to
rebuild := if os() == "macos" { "sudo darwin-rebuild" } else { "nixos-rebuild" }
system-args := if os() == "macos" { "" } else { "--elevate sudo --no-reexec" }
[private]
default:
@just --list --unsorted
# rebuild group
[group('rebuild')]
[no-exit-message]
[private]
builder goal *args:
#!/usr/bin/env bash
set -euo pipefail
{{ rebuild }} {{ goal }} \
--flake {{ flake }} \
{{ system-args }} \
{{ args }}
[group('rebuild')]
[no-exit-message]
[private]
deployer host goal *args:
#!/usr/bin/env bash
set -euo pipefail
just builder {{ goal }} --target-host {{ host }} --use-substitutes {{ args }}
# deploy by switching the new system configuration
[group('rebuild')]
[no-exit-message]
deploy host *args: (deployer host "switch" args)
# deploy by setting the boot configuration
[group('rebuild')]
[no-exit-message]
deploy-boot host *args: (deployer host "boot" args)
[group('rebuild')]
[no-exit-message]
[private]
deployer-all goal:
#!/usr/bin/env bash
set -euo pipefail
just deployer Legion {{ goal }}
just deployer Newton {{ goal }}
just deployer Notebook {{ goal }}
just deployer Orion {{ goal }}
# deploy to all hosts by switching
[group('rebuild')]
[no-exit-message]
deploy-all: (deployer-all "switch")
# deploy to all hosts by setting boot
[group('rebuild')]
[no-exit-message]
deploy-all-boot: (deployer-all "boot")
# rebuild the boot
[group('rebuild')]
[no-exit-message]
boot *args: (builder "boot" args)
# test what happens when you switch
[group('rebuild')]
[no-exit-message]
test *args: (builder "test" args)
# switch the new system configuration
# [group('rebuild')]
# [no-exit-message]
# switch *args: (builder "switch" args)
# switch the new system configuration
[group('rebuild')]
[no-exit-message]
switch *args:
nh {{ if os() == "macos" { "darwin" } else { "os" } }} switch -a {{ args }}
[group('rebuild')]
[macos]
[no-exit-message]
provision host:
sudo nix run github:LnL7/nix-darwin -- switch --flake {{ flake }}#{{ host }}
# package group
# build the package, you must specify the package you want to build
# build the iso image, you must specify the image you want to build
[group('package')]
[no-exit-message]
iso image:
#!/usr/bin/env bash
set -euo pipefail
target="{{ flake }}#nixosConfigurations.{{ image }}.config.system.build.isoImage"
nix build "$target"
# build the tarball, you must specify the host you want to build
[group('package')]
[no-exit-message]
tar host:
sudo nix run {{ flake }}#nixosConfigurations.{{ host }}.config.system.build.tarballBuilder
# dev group
# check the flake for errors
[group('dev')]
[no-exit-message]
check *args:
nix flake check --option allow-import-from-derivation false {{ args }}
[group('dev')]
[no-exit-message]
repl-host host=`hostname`:
nix repl .#nixosConfigurations.{{ host }}
# update a set of given inputs
[group('dev')]
[no-exit-message]
update *input:
nix flake update {{ input }} \
--refresh \
--commit-lock-file \
--commit-lockfile-summary "flake.lock: update {{ if input == "" { "all inputs" } else { input } }}" \
--flake {{ flake }}
# update the pinned brew and chromium sources
[group('dev')]
[no-exit-message]
update-pins *targets:
nix run {{ flake }}#update-pins -- {{ targets }}
# push to the mirrors
[group('dev')]
[no-exit-message]
push-mirrors:
git push git@codeberg.org:AzureHound/dotfiles.git
git push git@forgejo.softshell.duckdns.org:AzureHound/dotfiles.git
git push git@github.com:AzureHound/dotfiles.git
git push git@gitlab.com:AzureHound/dotfiles.git
# rotate all secrets
[group('dev')]
[no-exit-message]
rotate-secrets:
find secrets/ -name "*.yaml" | xargs -I {} sops rotate -i {}
# update the secret keys
[group('dev')]
[no-exit-message]
update-secrets:
find secrets/ -name "*.yaml" | xargs -I {} sops updatekeys -y {}
# utils group
alias fix := repair
# verify the integrity of the nix store
[group('utils')]
[no-exit-message]
verify *args:
nix-store --verify {{ args }}
# repairs the nix store from any breakages it may have
[group('utils')]
[no-exit-message]
repair: (verify "--check-contents --repair")
# clean the nix store and optimise it
[group('utils')]
[no-exit-message]
clean:
nix-collect-garbage --delete-older-than 7d
nix store optimise