PortValhalla/scripts/Arch/OS/setup.fish

96 lines
3.4 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 02:00:26 +00:00
source "$dir/../../Common/Scripts/config.fish"
source "$dir/../../Common/Scripts/hooks.fish"
2024-07-08 00:47:49 +00:00
set -q CONFIG_MODULE || set -l CONFIG_MODULE "$dir/config.nix"
2024-07-11 18:24:24 +00:00
set -l mountDir (getConfig valhalla.partition.rootDir)
2024-07-08 00:47:49 +00:00
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"
2024-07-11 20:05:36 +00:00
if set -l keyMap (getConfig valhalla.keyMap)
loadkeys "$keyMap"
end
2024-07-11 19:58:46 +00:00
and if set -l timezone (getConfig valhalla.timeZone)
timedatectl set-timezone "$timezone"
end
2024-07-08 00:47:49 +00:00
and CONFIG_MODULE=$CONFIG_MODULE bash "$dir/../../Common/OS/partition.sh"
and pacman-key --init
and pacman-key --populate
2024-07-11 18:24:24 +00:00
and pacstrap -K "$mountDir" \
2024-07-08 00:47:49 +00:00
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
2024-07-11 18:24:24 +00:00
and "$dir/../../copy-repo.fish" "$mountDir$tempRoot"
and genfstab -U "$mountDir" >> "$mountDir/etc/fstab"
2024-07-08 00:47:49 +00:00
2024-07-11 18:24:24 +00:00
and arch-chroot "$mountDir" systemctl enable NetworkManager
2024-07-08 00:47:49 +00:00
2024-07-11 19:58:46 +00:00
and if set -q timezone
arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime
end
2024-07-11 18:24:24 +00:00
and arch-chroot "$mountDir" hwclock --systohc
2024-07-08 00:47:49 +00:00
2024-07-09 00:22:12 +00:00
and begin
2024-07-11 17:31:50 +00:00
getConfig valhalla.i18n.localeSettings --json | \
2024-07-09 00:22:12 +00:00
jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")'
end | begin
read LOCALES
2024-07-11 18:24:24 +00:00
and arch-chroot "$mountDir" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen
2024-07-09 00:22:12 +00:00
end
2024-07-08 00:47:49 +00:00
and begin
2024-07-11 17:31:50 +00:00
getConfig valhalla.i18n.localeSettings --json | \
2024-07-09 00:22:12 +00:00
jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")'
2024-07-11 18:24:24 +00:00
end | arch-chroot "$mountDir" tee /etc/locale.conf > /dev/null
2024-07-08 00:47:49 +00:00
2024-07-11 20:05:36 +00:00
and if set -q keyMap
echo "KEYMAP=$keyMap" | arch-chroot "$mountDir" tee /etc/vconsole.conf > /dev/null
end
2024-07-11 18:24:24 +00:00
and echo "$ARCH_HOSTNAME" | arch-chroot "$mountDir" tee /etc/hostname > /dev/null
2024-07-08 00:47:49 +00:00
2024-07-11 18:24:24 +00:00
and arch-chroot "$mountDir" mkinitcpio -P
and arch-chroot "$mountDir" bash "$tempDir/../Software/GRUB/install.sh"
and arch-chroot "$mountDir" bash "$tempDir/../Software/sudo/install.sh"
and pacstrap -K "$mountDir" git
2024-07-08 00:47:49 +00:00
and USER_NAME="$USER_NAME" \
USER_DISPLAYNAME="$USER_DISPLAYNAME" \
USER_GROUPS="$USER_GROUPS" \
2024-07-11 18:24:24 +00:00
arch-chroot "$mountDir" bash "$tempDir/user.sh"
2024-07-08 00:47:49 +00:00
and if set -l keyLayout (getConfig valhalla.keyboardLayout)
set -l serviceName set-keymap.service
and set -l serviceFile "$mountDir/etc/systemd/system/$serviceName"
and cp "$dir/$serviceName" "$serviceFile"
and systemd-nspawn -D "$mountDir" systemctl enable "$serviceName"
and systemd-nspawn -bD "$mountDir" -E "ARCH_X11_KEYMAP=$keyLayout"
and systemd-nspawn -D "$mountDir" systemctl disable "$serviceName"
and rm "$serviceFile"
end
2024-07-08 00:47:49 +00:00
end
end