#!/bin/env fish begin set -l dir (status dirname) source "$dir/../../Common/OS/setup.fish" source "$dir/../../lib/settings.fish" function runChroot -S arch-chroot $argv end function installValhallaDeps -S pacstrap -K "$mountDir" fish git jq nix sudo tmux end function installDrivers -S if isOSEnabled hardware.surfaceBook pacstrap -K "$mountDir" linux-firmware-marvell end end function getInstallerScript -V dir -S echo "$dir/install.fish" end function setupOS -S -V dir -S source "$dir/../../lib/hooks.fish" source "$dir/../../lib/wait-network.fish" waitNetwork and begin set -l relativeDir (realpath --relative-to "$dir/../../.." "$dir") set -l tempDir "$PROJECT_CLONE_ROOT/$relativeDir" if set -l keyMap (getOSConfig keyMap) loadkeys "$keyMap" end and if set -l timezone (getOSConfig timeZone) timedatectl set-timezone "$timezone" end and pacman-key --init and pacman-key --populate and pacstrap -K "$mountDir" \ base \ linux \ linux-firmware \ networkmanager \ man-db \ man-pages \ texinfo and genfstab -U "$mountDir" >>"$mountDir/etc/fstab" and arch-chroot "$mountDir" systemctl enable NetworkManager and if set -q timezone arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime end and arch-chroot "$mountDir" hwclock --systohc and begin getOSConfig i18n.localeSettings --json | jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")' end | begin read LOCALES and arch-chroot "$mountDir" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen and arch-chroot "$mountDir" locale-gen end and begin getOSConfig i18n.localeSettings --json | jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")' end | arch-chroot "$mountDir" tee /etc/locale.conf >/dev/null and if set -q keyMap echo "KEYMAP=$keyMap" | arch-chroot "$mountDir" tee /etc/vconsole.conf >/dev/null end and echo (getOSConfig hostname) | arch-chroot "$mountDir" tee /etc/hostname >/dev/null and arch-chroot "$mountDir" mkinitcpio -P and runInOS fish "$tempDir/../Software/grub/main.fish" and if set -l keyLayout (getOSConfig 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 end end function autologin -S set -l file "/etc/systemd/system/getty@tty1.service.d/autologin.conf" arch-chroot "$mountDir" mkdir -p (dirname "$file") and begin printf %s\n \ "[Service]" \ "ExecStart=" \ "ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root %I \$TERM" end | arch-chroot "$mountDir" tee "$file" >/dev/null end if not type -q getInstallerScript function getInstallerScript -S echo "$dir/install.fish" end end runSetup end