barnacle partition script

Changed files
+53 -8
hosts
+10 -8
hosts/barnacle/default.nix
···
...
}:
+
# build with:
+
# nix build /etc/nixos#nixosConfigurations.barnacle.config.system.build.isoImage
+
{
imports = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-base.nix"
···
homeManager.enable = true;
username = "nixos";
};
-
users.users.nixos.hashedPassword = lib.mkForce null;
+
users.users.${config.custom.username}.hashedPassword = lib.mkForce null;
users.users.root.hashedPassword = lib.mkForce null;
services.openssh.settings.PermitRootLogin = lib.mkForce "no";
···
# networks = { "SSID" = { psk = "password"; }; };
};
-
# build with:
-
# nix build /etc/nixos#nixosConfigurations.barnacle.config.system.build.isoImage
-
isoImage.contents = [
-
{
+
home-manager.users.${config.custom.username}.config.home.file = {
+
"partition.sh".source = ./partition.sh;
+
"nixos" = {
+
recursive = true;
source = ../..;
-
target = "nixos";
-
}
-
];
+
};
+
};
# comment this out to make a smaller image
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
+43
hosts/barnacle/partition.sh
···
+
#!/usr/bin/env bash
+
+
if [ -z "$1" ]; then
+
echo "Usage: $0 <disk>"
+
exit 1
+
fi
+
+
DISK=$1
+
PART_SUFFIX=""
+
+
if [[ "$DISK" == *nvme* ]]; then
+
PART_SUFFIX="p"
+
fi
+
+
echo "Partitioning $DISK..."
+
parted "$DISK" -- mklabel gpt
+
parted "$DISK" -- mkpart ESP fat32 1MB 512MB
+
parted "$DISK" -- mkpart primary 512MiB 100%
+
parted "$DISK" -- set 1 esp on
+
+
echo "Making file systems..."
+
mkfs.fat -F 32 -n boot "${DISK}${PART_SUFFIX}1"
+
mkfs.ext4 -L nixos "${DISK}${PART_SUFFIX}2"
+
+
echo "Mounting partitions..."
+
mount "${DISK}${PART_SUFFIX}2" /mnt
+
mkdir -p /mnt/boot
+
mount "${DISK}${PART_SUFFIX}1" /mnt/boot
+
+
# then...
+
+
# mkdir -p /mnt/etc/nixos
+
# git clone https://github.com/RyanGibb/nixos.git /mnt/etc/nixos
+
# OR
+
# cp -R /home/nixos/nixos /mnt/etc/nixos/
+
+
# echo "Generating NixOS configuration..."
+
# nixos-generate-config --root /mnt
+
+
# ...
+
+
# nixos-install --root /mnt/ --flake /mnt/etc/nixos#host
+