PortValhalla/scripts/Arch/OS/setup.fish

86 lines
3.5 KiB
Fish
Raw Normal View History

2024-07-08 00:47:49 +00:00
#!/bin/env fish
begin
set -l dir (status dirname)
2024-07-09 00:22:12 +00:00
. "$dir/../../Common/Scripts/config.fish"
2024-07-09 01:57:03 +00:00
. "$dir/../../Common/Scripts/hooks.fish"
2024-07-08 00:47:49 +00:00
set -q CONFIG_MODULE || set -l CONFIG_MODULE "$dir/config.nix"
set -q ARCH_TIMEZONE || set -l ARCH_TIMEZONE "Europe/Zurich"
2024-07-09 00:22:12 +00:00
set -q ARCH_MOUNT_ROOT || set -l ARCH_MOUNT_ROOT (getConfig partition.rootDir --raw)
2024-07-08 00:47:49 +00:00
set -q ARCH_LANG || set -l ARCH_LANG en_US.UTF-8
set -q ARCH_KEYMAP || set -l ARCH_KEYMAP de_CH-latin1
set -q ARCH_X11_KEYMAP || set -l ARCH_X11_KEYMAP ch
set -q USER_NAME || set -l USER_NAME manuel
set -q USER_DISPLAYNAME
set -q USER_GROUPS || set -l USER_GROUPS ""
begin
2024-07-08 00:47:49 +00:00
set -l projectRoot (realpath "$dir/../../..")
set -l projectName (basename "$projectRoot")
set -l relativeDir (realpath --relative-to "$projectRoot" "$dir")
set -l tempRoot "/opt/$(basename "$projectName")"
set -l tempDir "$tempRoot/$relativeDir"
loadkeys "$ARCH_KEYMAP"
and timedatectl set-timezone "$ARCH_TIMEZONE"
and CONFIG_MODULE=$CONFIG_MODULE bash "$dir/../../Common/OS/partition.sh"
and pacman-key --init
and pacman-key --populate
and pacstrap -K "$ARCH_MOUNT_ROOT" \
base \
linux \
linux-firmware \
networkmanager \
man-db \
man-pages \
texinfo
2024-07-09 01:57:03 +00:00
and runHook installDrivers "Installing drivers…" || true
2024-07-08 00:47:49 +00:00
and "$dir/../../copy-repo.fish" "$ARCH_MOUNT_ROOT$tempRoot"
and genfstab -U "$ARCH_MOUNT_ROOT" >> "$ARCH_MOUNT_ROOT/etc/fstab"
and arch-chroot "$ARCH_MOUNT_ROOT" systemctl enable NetworkManager
and arch-chroot "$ARCH_MOUNT_ROOT" ln -sf "/usr/share/zoneinfo/$ARCH_TIMEZONE" /etc/localtime
and arch-chroot "$ARCH_MOUNT_ROOT" hwclock --systohc
2024-07-09 00:22:12 +00:00
and begin
getConfig i18n.localeSettings --json | \
jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")'
end | begin
read LOCALES
and arch-chroot "$ARCH_MOUNT_ROOT" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen
end
2024-07-08 00:47:49 +00:00
and begin
2024-07-09 00:22:12 +00:00
getConfig i18n.localeSettings --json | \
jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")'
2024-07-08 00:47:49 +00:00
end | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/locale.conf > /dev/null
and echo "KEYMAP=$ARCH_KEYMAP" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/vconsole.conf > /dev/null
and echo "$ARCH_HOSTNAME" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/hostname > /dev/null
and arch-chroot "$ARCH_MOUNT_ROOT" mkinitcpio -P
and arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/GRUB/install.sh"
and arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/sudo/install.sh"
and pacstrap -K "$ARCH_MOUNT_ROOT" git
and USER_NAME="$USER_NAME" \
USER_DISPLAYNAME="$USER_DISPLAYNAME" \
USER_GROUPS="$USER_GROUPS" \
arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/user.sh"
and set -l serviceName set-keymap.service
and set -l serviceFile "$ARCH_MOUNT_ROOT/etc/systemd/system/$serviceName"
and cp "$dir/$serviceName" "$serviceFile"
and systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl enable "$serviceName"
and systemd-nspawn -bD "$ARCH_MOUNT_ROOT" -E "ARCH_X11_KEYMAP=$ARCH_X11_KEYMAP"
and systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl disable "$serviceName"
and rm "$serviceFile"
end
end