Skip to content

Instantly share code, notes, and snippets.

@JucaRei
Forked from kanashimia/nixos-install.sh
Created February 3, 2024 04:13
Show Gist options
  • Save JucaRei/897af78e4c2e287086e7f276ca65414b to your computer and use it in GitHub Desktop.
Save JucaRei/897af78e4c2e287086e7f276ca65414b to your computer and use it in GitHub Desktop.
nixos unstable flake installation from nixos 20.09
#!/bin/sh
set -x
DEVICE=/dev/vda
SWAP_SIZE=2GiB
URI=github:kanashimia/nixos/module-refactor#personal-server
TYPE=legacy
trap "swapoff $DEVICE; umount /mnt/boot; umount /mnt; exit" INT
if [ $TYPE = legacy ]; then
parted $DEVICE -- mklabel msdos
parted $DEVICE -- mkpart primary 1MiB -$SWAP_SIZE
parted $DEVICE -- mkpart primary linux-swap -$SWAP_SIZE 100%
else
parted $DEVICE -- mklabel gpt
parted $DEVICE -- mkpart primary 512MiB -$SWAP_SIZE
parted $DEVICE -- mkpart primary linux-swap -$SWAP_SIZE 100%
parted $DEVICE -- mkpart ESP fat32 1MiB 512MiB
parted $DEVICE -- set 3 esp on
fi
mkfs.ext4 -L nixos ${DEVICE}1
mkswap -L swap ${DEVICE}2
swapon ${DEVICE}2
mount /dev/disk/by-label/nixos /mnt
if [ $TYPE != legacy ]; then
mkfs.fat -F 32 -n boot ${DEVICE}3
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
fi
nix-shell -p nixFlakes --run "nixos-install --flake $URI"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment