-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
160 lines (129 loc) · 3.82 KB
/
Justfile
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
# just is a command runner, Justfile is very similar to Makefile, but simpler.
# Use nushell for shell commands
# To usage this justfile, you need to enter a shell with just & nushell installed:
#
# nix shell nixpkgs#just nixpkgs#nushell
set shell := ["nu", "-c"]
utils_nu := absolute_path("utils.nu")
############################################################################
#
# Common commands(suitable for all machines)
#
############################################################################
# List all the just commands
default:
@just --list
# Run eval tests
[group('nix')]
test:
nix eval .#evalTests --show-trace --print-build-logs --verbose
# Update all the flake inputs
[group('nix')]
up:
nix flake update
# Update specific input
# Usage: just upp nixpkgs
[group('nix')]
upp input:
nix flake update {{input}}
# List all generations of the system profile
[group('nix')]
history:
nix profile history --profile /nix/var/nix/profiles/system
# Open a nix shell with the flake
[group('nix')]
repl:
nix repl -f flake:nixpkgs
# remove all generations older than 7 days
# on darwin, you may need to switch to root user to run this command
[group('nix')]
clean:
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d
# Garbage collect all unused nix store entries
[group('nix')]
gc:
# garbage collect all unused nix store entries(system-wide)
sudo nix-collect-garbage --delete-older-than 7d
# garbage collect all unused nix store entries(for the user - home-manager)
# https://github.com/LnL7/nix-darwin/issues/237
nix-collect-garbage --delete-older-than 7d
# Enter a shell session which has all the necessary tools for this flake
[linux]
[group('nix')]
shell:
nix shell nixpkgs#git nixpkgs#neovim nixpkgs#colmena
# Enter a shell session which has all the necessary tools for this flake
[macos]
[group('nix')]
shell:
nix shell nixpkgs#git nixpkgs#neovim
[group('nix')]
fmt:
# format the nix files in this repo
nix fmt
# Show all the auto gc roots in the nix store
[group('nix')]
gcroot:
ls -al /nix/var/nix/gcroots/auto/
# Remote deployment via colmena
[linux]
[group('homelab')]
col tag:
colmena apply --on '@{{tag}}' --verbose --show-trace
[linux]
[group('homelab')]
vm hostname:
# build the vm on the host
nix run .#nixosConfigurations.{{hostname}}.config.microvm.deploy.installOnHost root@suzu
# update the vm via restart it on the host
# ssh root@suzu systemctl restart microvm@{{hostname}}
# or switch to the new version in the vm
nix run .#nixosConfigurations.{{hostname}}.config.microvm.deploy.sshSwitch root@{{hostname}} switch
############################################################################
#
# RISC-V related commands
#
############################################################################
[linux]
[group('homelab')]
riscv:
colmena apply --on '@riscv' --verbose --show-trace
[linux]
[group('homelab')]
nozomi:
colmena apply --on '@nozomi' --verbose --show-trace
[linux]
[group('homelab')]
yukina:
colmena apply --on '@yukina' --verbose --show-trace
############################################################################
#
# Aarch64 related commands
#
############################################################################
[linux]
[group('homelab')]
rakushun:
colmena apply --on '@rakushun' --build-on-target --verbose --show-trace
[linux]
[group('homelab')]
rakushun-local mode="default":
#!/usr/bin/env nu
use {{utils_nu}} *;
nixos-switch rakushun {{mode}}
[linux]
[group('homelab')]
suzu-set-proxy:
ip route del default via 192.168.5.1
ip route add default via 192.168.5.178
[linux]
[group('homelab')]
suzu-unset-proxy:
ip route del default via 192.168.5.178
ip route add default via 192.168.5.1
[linux]
[group('homelab')]
suzu-local mode="default":
#!/usr/bin/env nu
use {{utils_nu}} *;
nixos-switch suzu {{mode}}