-
Notifications
You must be signed in to change notification settings - Fork 3
/
rebuild.nu
executable file
·41 lines (35 loc) · 922 Bytes
/
rebuild.nu
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
#!/usr/bin/env nu
def main --wrapped [
host: string = "" # The host to build.
...arguments # The arguments to pass to `nixos-rebuild switch`.
] {
let host = if ($host | is-not-empty) {
$host
} else {
(hostname)
}
let args_split = $arguments | split list "--"
let nh_flags = [
"--hostname" $host
] | append ($args_split | get --ignore-errors 0 | default [])
let nix_flags = [
"--option" "accept-flake-config" "true"
"--option" "eval-cache" "false"
] | append ($args_split | get --ignore-errors 1 | default [])
if $host == (hostname) {
nh os switch . ...$nh_flags -- ...$nix_flags
} else {
git ls-files | (
rsync
--rsh "ssh -q"
--delete-missing-args
--compress
--files-from -
./ ($host + ":ncc")
)
ssh -q -tt $host $"
cd ncc
./rebuild.nu ($host) ($arguments | str join ' ')
"
}
}