-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisko-install.sh
More file actions
executable file
·54 lines (46 loc) · 1.23 KB
/
Copy pathdisko-install.sh
File metadata and controls
executable file
·54 lines (46 loc) · 1.23 KB
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
#!/usr/bin/env bash
set -euo pipefail
host="$1"
disk_device="$2"
info() {
echo "$@" >&2
}
print_help() {
info "Usage: ./disko-install.sh <hostname> <disk_device_path>"
info " hostname:"
info " hostname of the host to install"
info " disk_device_path:"
info " Device path to disk to install on."
info " Example: /dev/sda"
}
if test -z "$host"; then
info "Missing host argument"
print_help
exit 1
fi
if test -z "$disk_device"; then
info "Missing disk_device_path argument"
print_help
exit 1
fi
key="/tmp/keys.txt"
mkdir -p "$(dirname -- "$key")"
if test ! -f "$key"; then
nix --extra-experimental-features 'flakes nix-command' shell "nixpkgs#age" -c age-keygen -o "$key"
fi
export SOPS_AGE_KEY_FILE="$key"
sudo chown root:root "$key"
sudo --preserve-env=SOPS_AGE_KEY_FILE nix \
--extra-experimental-features 'flakes nix-command' \
run 'github:nix-community/disko/latest#disko-install' \
-- \
--write-efi-boot-entries \
--flake ".#$host" \
--disk "main" \
"$disk_device"
mkdir -p /tmp/built-system
sudo mount "$disk_device" /tmp/built-system
dest_key="/tmp/built-system/home/gipphe/.config/sops/age/keys.txt"
mkdir -p "$(dirname -- "$dest_key")"
sudo cp "$key" "$dest_key"
sudo chown 1000:1000 "$dest_key"