mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-10 04:02:55 +00:00
39 lines
1.1 KiB
Nix
39 lines
1.1 KiB
Nix
{ pkgs, ... }: {
|
|
|
|
# Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix
|
|
# This will partition and format drives; use at your own risk.
|
|
|
|
type = "app";
|
|
|
|
program = pkgs.writeShellScriptBin "installer" ''
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
set -e
|
|
|
|
DISK=$1
|
|
FLAKE=$2
|
|
|
|
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
|
|
echo "Missing required parameter."
|
|
echo "Usage: installer -- <disk> <host>"
|
|
echo "Example: installer -- nvme0n1 desktop"
|
|
echo "Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 desktop"
|
|
exit 1
|
|
fi
|
|
|
|
parted /dev/''${DISK} -- mklabel gpt
|
|
parted /dev/''${DISK} -- mkpart primary 512MiB 100%
|
|
parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
|
|
parted /dev/''${DISK} -- set 3 esp on
|
|
mkfs.ext4 -L nixos /dev/''${DISK}p1
|
|
mkfs.fat -F 32 -n boot /dev/''${DISK}p2
|
|
|
|
mount /dev/disk/by-label/nixos /mnt
|
|
mkdir --parents /mnt/boot
|
|
mount /dev/disk/by-label/boot /mnt/boot
|
|
|
|
nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
|
|
'';
|
|
|
|
}
|