-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
utils.nu
74 lines (61 loc) · 1.92 KB
/
utils.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
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
# ================= NixOS related =========================
export def nixos-switch [
name: string
mode: string
] {
if "debug" == $mode {
# show details via nix-output-monitor
nom build $".#nixosConfigurations.($name).config.system.build.toplevel" --show-trace --verbose
nixos-rebuild switch --use-remote-sudo --flake $".#($name)" --show-trace --verbose
} else {
nixos-rebuild switch --use-remote-sudo --flake $".#($name)"
}
}
# ====================== Misc =============================
export def make-editable [
path: string
] {
let tmpdir = (mktemp -d)
rsync -avz --copy-links $"($path)/" $tmpdir
rsync -avz --copy-links --chmod=D2755,F744 $"($tmpdir)/" $path
}
# ================= macOS related =========================
export def darwin-build [
name: string
mode: string
] {
let target = $".#darwinConfigurations.($name).system"
if "debug" == $mode {
nom build $target --extra-experimental-features "nix-command flakes" --show-trace --verbose
} else {
nix build $target --extra-experimental-features "nix-command flakes"
}
}
export def darwin-switch [
name: string
mode: string
] {
if "debug" == $mode {
./result/sw/bin/darwin-rebuild switch --flake $".#($name)" --show-trace --verbose
} else {
./result/sw/bin/darwin-rebuild switch --flake $".#($name)"
}
}
export def darwin-rollback [] {
./result/sw/bin/darwin-rebuild --rollback
}
# ==================== Virtual Machines related =====================
# Build and upload a VM image
export def upload-vm [
name: string
mode: string
] {
let target = $".#($name)"
if "debug" == $mode {
nom build $target --show-trace --verbose
} else {
nix build $target
}
let remote = $"ryan@rakushun:/data/caddy/fileserver/vms/kubevirt-($name).qcow2"
rsync -avz --progress --copy-links --checksum result $remote
}