forked from jnsgruk/nixos-config
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-with-disko
44 lines (32 loc) · 1.02 KB
/
install-with-disko
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
#!/usr/bin/env bash
set -euo pipefail
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TARGET_HOST="${1:-}"
if [ "$(id -u)" -eq 0 ]; then
echo "ERROR! $(basename "${0}") should be run as a regular user"
exit 1
fi
if [[ -z "$TARGET_HOST" ]]; then
echo "ERROR! $(basename "${0}") requires a username as the first argument"
exit 1
fi
if [ ! -e "./host/${TARGET_HOST}/disks.nix" ]; then
echo "ERROR! $(basename "${0}") could not find the required file disko-config.nix"
exit 1
fi
echo "WARNING! The disks in ${TARGET_HOST} are about to get wiped"
echo " NixOS will be re-installed"
echo " This is a destructive operation"
echo
read -p "Are you sure? [y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo true
sudo nix run github:nix-community/disko \
--extra-experimental-features "nix-command flakes" \
--no-write-lock-file \
-- \
--mode zap_create_mount \
"./host/${TARGET_HOST}/disks.nix"
sudo nixos-install --flake ".#${TARGET_HOST}"
fi