-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (40 loc) · 1.35 KB
/
Makefile
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
# Connectivity info for Linux VM
NIXADDR ?= unset
NIXPORT ?= 22
NIXUSER ?= root
# Get the path to this Makefile and directory
MAKEFILE_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
# The name of the nixosConfiguration in the flake
NIXNAME ?= vm-intel
# SSH options that are used. These aren't meant to be overridden but are
# reused a lot so we just store them up here.
SSH_OPTIONS=-o PubkeyAuthentication=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
# bootstrap the vm. only run again on macos if the secrets change
vm/bootstrap:
NIXUSER=root $(MAKE) vm/copy
NIXUSER=root $(MAKE) vm/install
$(MAKE) vm/secrets
# copy our secrets into the VM
vm/secrets:
# SSH keys
rsync -av -e 'ssh $(SSH_OPTIONS)' \
--exclude='environment' \
$(HOME)/.ssh/ $(NIXUSER)@$(NIXADDR):~/.ssh
# copy the Nix configurations into the VM.
vm/copy:
rsync -av -e 'ssh $(SSH_OPTIONS) -p$(NIXPORT)' \
--exclude='.git/' \
--rsync-path="sudo rsync" \
$(MAKEFILE_DIR)/ $(NIXUSER)@$(NIXADDR):/nix-config
# run the nixos-install command. This does NOT copy files so you
# have to run vm/copy before.
vm/install:
ssh $(SSH_OPTIONS) -p$(NIXPORT) $(NIXUSER)@$(NIXADDR) " \
sudo nix-shell \
--argstr systemName $(NIXNAME) \
/nix-config/bootstrap \
"
vm/reboot:
ssh $(SSH_OPTIONS) -p$(NIXPORT) $(NIXUSER)@$(NIXADDR) " \
sudo reboot; \
"