-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (44 loc) · 1.51 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
49
50
NIXADDR ?= unknown
NIXPORT ?= 22
NIXUSER ?= nickt
NIXBLOCKDEVICE ?= sda
MAKEFILE_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
.PHONY: ssh
ssh:
ssh $(NIXUSER)@$(NIXADDR)
.PHONY: bootstrap
bootstrap:
ssh root@$(NIXADDR) " \
parted /dev/$(NIXBLOCKDEVICE) -- mklabel gpt; \
parted /dev/$(NIXBLOCKDEVICE) -- mkpart primary 512MiB -8GiB; \
parted /dev/$(NIXBLOCKDEVICE) -- mkpart primary linux-swap -8GiB 100\%; \
parted /dev/$(NIXBLOCKDEVICE) -- mkpart ESP fat32 1MiB 512MiB; \
parted /dev/$(NIXBLOCKDEVICE) -- set 3 esp on; \
mkfs.ext4 -L nixos /dev/$(NIXBLOCKDEVICE)1; \
mkswap -L swap /dev/$(NIXBLOCKDEVICE)2; \
mkfs.fat -F 32 -n boot /dev/$(NIXBLOCKDEVICE)3; \
mount /dev/disk/by-label/nixos /mnt; \
mkdir -p /mnt/boot; \
mount /dev/disk/by-label/boot /mnt/boot; \
nixos-generate-config --root /mnt; \
sed --in-place '/system\.stateVersion = .*/a \
nix.package = pkgs.nixUnstable;\n \
nix.extraOptions = \"experimental-features = nix-command flakes\";\n \
services.openssh.enable = true;\n \
services.openssh.passwordAuthentication = true;\n \
services.openssh.permitRootLogin = \"yes\";\n \
users.users.root.initialPassword = \"root\";\n \
' /mnt/etc/nixos/configuration.nix; \
nixos-install --no-root-passwd; \
reboot; \
"
.PHONY: setup
setup:
NIXUSER=root $(MAKE) vm/copy
.PHONY: copy
copy:
rsync -av -e 'ssh -p$(NIXPORT)' \
--exclude='.git/' \
--exclude='*.swp' \
--rsync-path="sudo rsync" \
$(MAKEFILE_DIR)/ $(NIXUSER)@$(NIXADDR):/nix-config