mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-23 04:35:38 +00:00
add more flexibility to installer script
This commit is contained in:
parent
f4786156de
commit
9a21db7165
@ -1,7 +1,7 @@
|
|||||||
{ pkgs, ... }: {
|
{ pkgs, ... }: {
|
||||||
|
|
||||||
# Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix
|
# Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix
|
||||||
# This will partition and format drives; use at your own risk.
|
# This script will partition and format drives; use at your own risk!
|
||||||
|
|
||||||
type = "app";
|
type = "app";
|
||||||
|
|
||||||
@ -12,21 +12,27 @@
|
|||||||
|
|
||||||
DISK=$1
|
DISK=$1
|
||||||
FLAKE=$2
|
FLAKE=$2
|
||||||
|
PARTITION_PREFIX=""
|
||||||
|
|
||||||
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
|
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
|
||||||
echo "Missing required parameter."
|
echo "Missing required parameter."
|
||||||
echo "Usage: installer -- <disk> <host>"
|
echo "Usage: installer -- <disk> <host>"
|
||||||
echo "Example: installer -- nvme0n1 desktop"
|
echo "Example: installer -- nvme0n1 desktop"
|
||||||
echo "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
|
echo "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
|
||||||
|
echo "(exiting)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case "$DISK" in nvme*)
|
||||||
|
PARTITION_PREFIX="p"
|
||||||
|
esac
|
||||||
|
|
||||||
parted /dev/''${DISK} -- mklabel gpt
|
parted /dev/''${DISK} -- mklabel gpt
|
||||||
parted /dev/''${DISK} -- mkpart primary 512MiB 100%
|
parted /dev/''${DISK} -- mkpart primary 512MiB 100%
|
||||||
parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
|
parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
|
||||||
parted /dev/''${DISK} -- set 3 esp on
|
parted /dev/''${DISK} -- set 3 esp on
|
||||||
mkfs.ext4 -L nixos /dev/''${DISK}p1
|
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
|
||||||
mkfs.fat -F 32 -n boot /dev/''${DISK}p2
|
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
|
||||||
|
|
||||||
mount /dev/disk/by-label/nixos /mnt
|
mount /dev/disk/by-label/nixos /mnt
|
||||||
mkdir --parents /mnt/boot
|
mkdir --parents /mnt/boot
|
||||||
|
Loading…
Reference in New Issue
Block a user