2024-01-31 20:03:00 +01:00
|
|
|
#!/usr/bin/env nix-shellge
|
2024-01-18 02:28:17 +01:00
|
|
|
#!nix-shell ../devshells/bootstrap/shell.nix
|
2024-01-18 02:27:38 +01:00
|
|
|
#!nix-shell -i bash
|
|
|
|
|
2024-01-18 02:24:34 +01:00
|
|
|
# Check if at least one argument is provided
|
|
|
|
if [ "$#" -eq 0 ]; then
|
|
|
|
echo "Usage: $0 <disko-mode> [action]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure correct first argument type
|
|
|
|
if [ "$1" != "disko" ] && [ "$1" != "mount" ]; then
|
|
|
|
echo "Disko action must be either 'disko' or 'mount'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure correct second argument type
|
|
|
|
if [ "$#" != "1" ] && [ "$2" != "install" ] && [ "$2" != "enter" ]; then
|
|
|
|
echo "Action must either be empty, 'install' or 'enter'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-18 02:37:01 +01:00
|
|
|
if mountpoint -q /hermes; then
|
|
|
|
echo "Keys already mounted"
|
|
|
|
else
|
|
|
|
echo "Mounting keys"
|
|
|
|
mkdir -p /hermes
|
|
|
|
mount /dev/disk/by-uuid/7FE7-CA68 /hermes
|
|
|
|
fi
|
2024-01-18 02:24:34 +01:00
|
|
|
|
|
|
|
echo "Running disko"
|
|
|
|
|
2024-01-18 02:32:21 +01:00
|
|
|
if [ "$1" = "mount" ]; then
|
|
|
|
zpool import -lfR /mnt zroot
|
2024-01-18 02:24:34 +01:00
|
|
|
fi
|
|
|
|
|
2024-01-18 02:34:41 +01:00
|
|
|
nix run disko -- --mode $1 ./hosts/nixos/lapetus/filesystems/partitions.nix
|
2024-01-18 02:24:34 +01:00
|
|
|
|
|
|
|
if [ "$2" = "install" ]; then
|
|
|
|
echo "Installing nixos"
|
2024-01-18 02:32:21 +01:00
|
|
|
nixos-install --flake ".#lapetus"
|
2024-01-18 02:24:34 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$2" = "enter" ]; then
|
|
|
|
echo "Entering nixos"
|
2024-01-18 02:32:21 +01:00
|
|
|
nixos-enter --root /mnt
|
2024-01-18 02:24:34 +01:00
|
|
|
fi
|
|
|
|
|
2024-01-18 01:56:50 +01:00
|
|
|
echo "All done!"
|