-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
57 lines (48 loc) · 1.79 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
host := `hostname`
SSH_OPTIONS := '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=600'
# list recipes
default:
just --list
# Reformat all sources (nix & lua)
format:
nix fmt
# rebuild NixOS config and switch; mode='light'|'dark'
[linux]
nixos-switch mode='dark':
sudo nix run .#rebuild-{{ host }}-{{ mode }}
# rebuild nix-darwin config and switch; mode='light'|'dark'
[macos]
nix-darwin-switch mode='dark':
nix run .#rebuild-{{ host }}-{{ mode }}
# rebuild Home Manager config and switch; mode='light'|'dark'
[unix]
hm-switch mode='dark':
nix run .#hm-switch-{{ host }}-{{ mode }}
# reload tmux config
tmux source-file ~/.config/tmux/tmux.conf
# reload fish config
fish -c 'reload_all_fish_instances'
# clean up nix store by removing old generations etc.
[unix]
collect-garbage:
nix-collect-garbage -d
# install NixOS & HM on fresh VM (see README.md)
[private]
bootstrap-vm ip attr user:
nix run github:nix-community/nixos-anywhere -- \
--flake '.#{{ attr }}' \
--ssh-option 'UserKnownHostsFile=/dev/null' \
--ssh-option 'StrictHostKeyChecking=no' \
--build-on-remote \
--generate-hardware-config nixos-generate-config ./system/hardware-configuration.nix \
--target-host nixos@{{ ip }}
# copy ssh keys
rsync -av -e 'ssh {{ SSH_OPTIONS }}' ~/.ssh/ {{ user }}@{{ ip }}:~/.ssh
# copy this repo - this conveniently gives us the generated hardware config
rsync -av -e 'ssh {{ SSH_OPTIONS }}' . {{ user }}@{{ ip }}:~/nix-config
# build and activate Home Manager config
ssh {{ SSH_OPTIONS }} -v {{ user }}@{{ ip }} 'cd nix-config; just hm-switch'
[macos]
bootstrap-mbp-vmw ip: (bootstrap-vm ip 'macbook-pro-m1-vmw' 'buntec')
[macos]
bootstrap-mbp-utm ip: (bootstrap-vm ip 'macbook-pro-m1-utm' 'buntec')