forked from Defelo/sandkasten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-vm.sh
31 lines (22 loc) · 996 Bytes
/
install-vm.sh
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
#!/usr/bin/env bash
set -ex
FLAKE=${FLAKE:-github:Defelo/sandkasten/latest#vm}
DISK=${1:-/dev/sda}
ROOT=${2:-${DISK}1}
mkdir -p ~/.config/nix
cat << EOF > ~/.config/nix/nix.conf
extra-experimental-features = nix-command flakes
extra-substituters = https://sandkasten.cachix.org
extra-trusted-public-keys = sandkasten.cachix.org-1:Pa7qfdlx7bZkko+ojaaEG9pyziZkaru9v4TfcioqNZw=
EOF
nix profile install nixpkgs#git
echo -ne 'o\nn\n\n\n\n\na\nw\n' | fdisk $DISK
mkfs.ext4 $ROOT
mount $ROOT /mnt
mkdir /mnt/root
nix flake new --template "$FLAKE" /mnt/root/sandkasten
sed -i -E "s|github:Defelo/sandkasten/latest|${FLAKE%#*}|" /mnt/root/sandkasten/flake.nix
nixos-generate-config --root /mnt --show-hardware-config > /mnt/root/sandkasten/hardware-configuration.nix
sed -i -E "s#boot.loader.grub.device = \"/dev/sda\";#boot.loader.grub.device = \"$DISK\";#" /mnt/root/sandkasten/configuration.nix
nixos-install --flake /mnt/root/sandkasten#sandkasten --no-channel-copy --no-root-password
reboot