PortValhalla/scripts/Arch/OS/setup.sh

82 lines
2.7 KiB
Bash
Raw Normal View History

2024-03-24 23:26:12 +00:00
#!/bin/bash -e
CONFIG_MODULE="${CONFIG_MODULE:+"$(realpath "$CONFIG_MODULE")"}";
2023-04-01 11:01:39 +00:00
pushd "${BASH_SOURCE%/*}" > /dev/null;
CONFIG_MODULE="${CONFIG_MODULE:-"./config.nix"}";
2023-04-04 20:55:37 +00:00
ARCH_TIMEZONE="${ARCH_TIMEZONE:-"Europe/Zurich"}";
2023-04-01 11:01:39 +00:00
ARCH_HOSTNAME="${ARCH_HOSTNAME}";
2024-07-11 17:31:50 +00:00
ARCH_MOUNT_ROOT="${ARCH_MOUNT_ROOT:-"$(../../eval-module.sh "$CONFIG_MODULE" valhalla.partition.rootDir --raw)"}";
2023-04-03 21:33:24 +00:00
ARCH_LANG="${ARCH_LANG:-"en_US.UTF-8"}";
ARCH_KEYMAP="${ARCH_KEYMAP:-"de_CH-latin1"}";
2023-04-03 21:52:20 +00:00
ARCH_X11_KEYMAP="${ARCH_X11_KEYMAP:-"ch"}";
2023-04-04 21:41:44 +00:00
LOCALE_PATTERN="${LOCALE_PATTERN:-\(de_CH\|en_US\)}";
2023-04-01 11:01:39 +00:00
2023-04-04 20:55:37 +00:00
USER_NAME="${USER_NAME:-"manuel"}";
2023-04-03 08:35:01 +00:00
USER_DISPLAYNAME="${USER_DISPLAYNAME}";
USER_GROUPS="${USER_GROUPS}";
2023-04-03 08:21:27 +00:00
projectRoot="$(realpath ../../..)";
projectName="$(basename "$projectRoot")";
relativeDir="$(realpath --relative-to "$projectRoot" "$(pwd)")";
2024-07-07 18:12:46 +00:00
tempRoot="/opt/$(basename "$projectName")";
2023-04-03 08:21:27 +00:00
tempDir="$tempRoot/$relativeDir";
2023-04-01 11:01:39 +00:00
loadkeys "$ARCH_KEYMAP";
timedatectl set-timezone "$ARCH_TIMEZONE";
. "../../Common/OS/partition.sh";
2023-04-04 10:27:18 +00:00
2023-06-09 21:31:42 +00:00
pacman-key --init;
pacman-key --populate;
2023-04-04 10:27:18 +00:00
pacstrap -K "$ARCH_MOUNT_ROOT" \
base \
linux \
linux-firmware \
networkmanager \
man-db \
man-pages \
2023-05-24 05:13:45 +00:00
texinfo \
2024-03-07 18:15:46 +00:00
;
2023-04-04 10:27:18 +00:00
2024-07-07 20:33:01 +00:00
fish ../../copy-repo.fish "${ARCH_MOUNT_ROOT}$tempRoot";
2023-04-01 11:01:39 +00:00
genfstab -U "$ARCH_MOUNT_ROOT" >> "$ARCH_MOUNT_ROOT/etc/fstab";
2023-04-03 09:14:46 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" systemctl enable NetworkManager;
2023-04-01 11:13:52 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime;
arch-chroot "$ARCH_MOUNT_ROOT" hwclock --systohc;
2023-04-01 11:01:39 +00:00
2023-04-04 21:41:44 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" sed -i "s/^#\?\($LOCALE_PATTERN.*\)$/\1/" /etc/locale.gen;
2023-04-01 11:13:52 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" locale-gen;
2023-05-25 18:06:37 +00:00
{
echo "LANG=de_CH.UTF-8"
echo "LANGUAGE=en_US.UTF-8"
echo "LC_MESSAGES=en_US.UTF-8"
} | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/locale.conf > /dev/null;
2023-04-01 13:21:28 +00:00
echo "KEYMAP=$ARCH_KEYMAP" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/vconsole.conf > /dev/null;
2023-04-01 11:01:39 +00:00
2023-04-06 11:41:09 +00:00
echo "$ARCH_HOSTNAME" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/hostname;
2023-04-01 11:13:52 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" mkinitcpio -P;
2023-04-01 11:01:39 +00:00
2023-05-04 19:53:07 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" pacman -Syu;
2023-04-03 08:21:27 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/GRUB/install.sh";
2023-04-03 09:00:11 +00:00
arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/sudo/install.sh";
pacstrap -K "$ARCH_MOUNT_ROOT" git;
2023-04-01 11:01:39 +00:00
2023-04-03 08:35:01 +00:00
USER_NAME="${USER_NAME}" \
USER_DISPLAYNAME="${USER_DISPLAYNAME}" \
USER_GROUPS="${USER_GROUPS}" \
arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/user.sh";
2023-04-04 21:00:00 +00:00
cp ./set-keymap.service "$ARCH_MOUNT_ROOT/etc/systemd/system";
systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl enable set-keymap;
systemd-nspawn -bD "$ARCH_MOUNT_ROOT" -E "ARCH_X11_KEYMAP=${ARCH_X11_KEYMAP}";
systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl disable set-keymap;
rm "$ARCH_MOUNT_ROOT/etc/systemd/system/set-keymap.service";
2023-04-01 11:01:39 +00:00
popd > /dev/null;