diff --git a/build.sh b/build.sh index 6295570..7bae7d8 100755 --- a/build.sh +++ b/build.sh @@ -1,25 +1,29 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail MOUNT="$(mktemp --directory)" +HOSTNAME="archlinux" +KEYMAP="us" +LOCALE="C.UTF-8" +TIMEZONE="UTC" + IMG_SIZE="2G" IMG_FILE="image.img" QCOW_FILE="image.qcow2" -ROOT_LABEL="Arch Linux" -ROOT_SUBVOL="@arch" -ROOT_FLAGS="compress=zstd,noatime,subvol=$ROOT_SUBVOL" -ROOT_GPT_TYPE="4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709" # Linux root (x86-64) - ESP_LABEL="ESP" ESP_SIZE="100M" ESP_DIR="efi" ESP_GPT_TYPE="C12A7328-F81F-11D2-BA4B-00A0C93EC93B" # EFI System +ROOT_LABEL="Arch Linux" +ROOT_SUBVOL="@arch" +ROOT_FLAGS="compress=zstd,noatime,subvol=$ROOT_SUBVOL" +ROOT_GPT_TYPE="4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709" # Linux root (x86-64) + PACKAGES=( base - base-devel btrfs-progs cloud-init cloud-guest-utils @@ -27,13 +31,14 @@ PACKAGES=( grml-zsh-config htop iptables-nft - linux man-db + mkinitcpio neovim openssh pacman-contrib polkit reflector + sudo systemd-ukify zsh zsh-autosuggestions @@ -53,11 +58,11 @@ SERVICES=( systemd-timesyncd systemd-time-wait-sync + btrfs-scrub@-.timer paccache.timer ) MASK=( - systemd-nsresourced.socket - systemd-userdbd.socket + systemd-homed ) # Cleanup @@ -108,18 +113,16 @@ CMDLINE="rootflags=$ROOT_FLAGS rw" systemd-firstboot \ --root="$MOUNT" \ --force \ - --keymap=us \ - --locale=C.UTF-8 \ - --timezone=UTC \ + --keymap="$KEYMAP" \ + --locale="$LOCALE" \ + --hostname="$HOSTNAME" \ + --timezone="$TIMEZONE" \ --root-shell=/usr/bin/zsh \ --kernel-command-line="$CMDLINE" \ ; # Bootloader bootctl install --root "$MOUNT" --no-variables - -rm -f "$MOUNT"/boot/initramfs-linux{,-fallback}.img -mv "$MOUNT/etc/mkinitcpio.d/linux."{preset,original} cat <"$MOUNT/etc/mkinitcpio.conf.d/custom.conf" MODULES=(btrfs) HOOKS=(systemd autodetect microcode modconf keyboard block) @@ -127,10 +130,12 @@ EOF cat <"$MOUNT/etc/mkinitcpio.d/linux.preset" PRESETS=('default') default_kver="/boot/vmlinuz-linux" -default_uki="/efi/EFI/Linux/arch.efi" +default_uki="/$ESP_DIR/EFI/Linux/arch.efi" default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp -S autodetect" EOF -arch-chroot "$MOUNT" mkinitcpio --allpresets + +# Kernel +pacstrap -cGM "$MOUNT" linux sed -i "s/ -S autodetect//" "$MOUNT/etc/mkinitcpio.d/linux.preset" # https://systemd.io/BUILDING_IMAGES/