-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
133 lines (118 loc) · 3.8 KB
/
Taskfile.yml
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
---
version: "3"
vars:
LOCAL_HOST: quine
tasks:
default:
silent: true
cmds:
- task -l
check:
cmds:
- nix flake check --all-systems
update:
desc: Update all the flake inputs
cmds:
- nix flake update
update:input:
desc: Update a specific flake input (e.g., task update:input input=nixpkgs)
vars:
input: '{{ or .input (fail "Flake input name `input` is required") }}'
cmds:
- nix flake lock --update-input {{.input}}
nixos-rebuild-remote:
internal: true
cmds:
- nixos-rebuild --fast --use-remote-sudo --build-host {{.BUILD_HOST}} --target-host {{.TARGET_HOST}} --flake {{.FLAKE_URI}} {{.ACTION}} |& nom
nixos-rebuild-local:
internal: true
cmds:
- |
if [[ "{{ .TARGET_HOST }}" == "{{ .LOCAL_HOST }}" ]]; then
sudo nixos-rebuild --flake .#quine {{.ACTION}} --show-trace |& nom
else
nixos-rebuild --fast --use-remote-sudo --target-host {{.TARGET_HOST}} --flake {{.FLAKE_URI}} {{.ACTION}} --show-trace |& nom
fi
deploy-key:
cmds:
- sops -d --extract "['ssh_host_ed25519_key']" ./hosts/unstable/{{.arch}}-linux/{{.host}}/secrets.sops.yaml | ssh {{.host}} 'cat - | sudo tee /etc/ssh/ssh_host_ed25519_key'
- sops -d --extract "['ssh_host_ed25519_key_pub']" ./hosts/unstable/{{.arch}}-linux/{{.host}}/secrets.sops.yaml | ssh {{.host}} 'cat - | sudo tee /etc/ssh/ssh_host_ed25519_key.pub'
build:
desc: Build a configuration for a remote
summary: |
host: the hostname to build (required)
flake: the flake name if different from host (optional)
requires:
vars: ["host"]
#silent: true
cmds:
- task: nixos-rebuild-local
vars:
ACTION: build
TARGET_HOST: "{{.host}}"
FLAKE_URI: .#{{.flake | default "{{.host}}"}}
switch:
desc: Switch a configuration for a remote
summary: |
host: the hostname to build (required)
flake: the flake name if different from host (optional)
requires:
vars: ["host"]
#silent: true
cmds:
- task: nixos-rebuild-local
vars:
ACTION: switch
TARGET_HOST: "{{.host}}"
FLAKE_URI: .#{{.flake | default "{{.host}}"}}
test:
desc: Test a configuration for a remote
summary: |
host: the hostname to build (required)
flake: the flake name if different from host (optional)
requires:
vars: ["host"]
#silent: true
cmds:
- task: nixos-rebuild-local
vars:
ACTION: test
TARGET_HOST: "{{.host}}"
FLAKE_URI: .#{{.flake | default "{{.host}}"}}
switch-remote:
desc: Switch a configuration for a remote
summary: |
host: the hostname to build (required)
flake: the flake name if different from host (optional)
requires:
vars: ["host"]
#silent: true
cmds:
- task: nixos-rebuild-remote
vars:
ACTION: switch
BUILD_HOST: "{{.host}}"
TARGET_HOST: "{{.host}}"
FLAKE_URI: .#{{.flake | default "{{.host}}"}}
image:
desc: Build the SD Card image for a host
summary: |
host: the hostname to build (required)
requires:
vars: ["host"]
cmds:
- nix build .#images.{{.host}}
why-depends:
# source: https://discourse.nixos.org/t/better-why-depends-fill-in-the-gaps/31246/8
desc: Explain why a NixOS host's configuration depends on some package
summary: |
host: the NixOs host's system closure to check
pkg: the pkg name to investigate
requires:
vars: ["host", "pkg"]
cmds:
- nix why-depends .\#nixosConfigurations.{{.host}}.config.system.build.toplevel .\#nixosConfigurations.{{.host}}.pkgs.{{.pkg}} --derivation | cat
gen-host:
desc: Scaffold out a gen host
cmds:
- python ./scripts/gen-host.py