PortValhalla/scripts/Arch/OS/setup.fish

135 lines
4.4 KiB
Fish
Raw Normal View History

2024-07-08 00:47:49 +00:00
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../lib/dependencies.fish"
2024-07-16 13:22:15 +00:00
source "$dir/../../Common/OS/setup.fish"
2024-11-01 12:12:16 +00:00
source "$dir/../../lib/settings.fish"
2024-07-08 00:47:49 +00:00
function runChroot -S
arch-chroot $argv
end
function bootstrapSetup -S
2024-12-07 20:46:53 +00:00
pacstrap -K (getOSConfig fileSystems.rootDir) fish
2024-07-16 20:16:21 +00:00
end
2024-09-30 12:56:49 +00:00
function installDrivers -S
2024-09-22 15:50:05 +00:00
if isOSEnabled hardware.surfaceBook
2024-12-07 20:46:53 +00:00
pacstrap -K (getOSConfig fileSystems.rootDir) linux-firmware-marvell
2024-09-21 13:43:52 +00:00
end
end
function getInstallerScript -V dir -S
echo "$dir/install.fish"
end
2024-12-05 09:09:35 +00:00
function initOS -V dir
source "$dir/../lib/dependencies.fish"
2024-12-05 09:09:35 +00:00
source "$dir/../../lib/wait-network.fish"
2024-12-07 20:46:53 +00:00
set -l mountDir (getOSConfig fileSystems.rootDir)
2024-12-05 09:09:35 +00:00
waitNetwork
and pacman-key --init
and pacman-key --populate
and pacstrap -K "$mountDir" \
2024-12-05 09:09:35 +00:00
base \
linux \
linux-firmware \
man-db \
man-pages \
texinfo
installValhallaDeps "$mountDir"
2024-12-05 09:09:35 +00:00
end
2024-09-30 12:56:49 +00:00
function setupOS -S -V dir -S
2024-11-01 12:12:16 +00:00
source "$dir/../../lib/hooks.fish"
source "$dir/../../lib/wait-network.fish"
2024-12-07 20:46:53 +00:00
set -l mountDir (getOSConfig fileSystems.rootDir)
2024-07-13 07:52:30 +00:00
waitNetwork
2024-07-09 00:22:12 +00:00
and begin
set -l relativeDir (realpath --relative-to "$dir/../../.." "$dir")
set -l tempDir "$PROJECT_CLONE_ROOT/$relativeDir"
2024-07-13 07:52:30 +00:00
2024-09-22 15:50:05 +00:00
if set -l keyMap (getOSConfig keyMap)
2024-07-13 07:52:30 +00:00
loadkeys "$keyMap"
end
2024-09-22 15:50:05 +00:00
and if set -l timezone (getOSConfig timeZone)
2024-07-13 07:52:30 +00:00
timedatectl set-timezone "$timezone"
end
2024-10-06 19:25:34 +00:00
and genfstab -U "$mountDir" >>"$mountDir/etc/fstab"
and if isProgramEnabled "networkmanager"
and pacstrap -K "$mountDir" networkmanager
arch-chroot "$mountDir" systemctl enable NetworkManager
end
2024-07-13 07:52:30 +00:00
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
2024-11-29 00:13:58 +00:00
getOSConfig i18n.localeSettings --json |
2024-07-13 07:52:30 +00:00
jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")'
end | begin
read LOCALES
and arch-chroot "$mountDir" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen
2024-07-28 21:45:09 +00:00
and arch-chroot "$mountDir" locale-gen
2024-07-13 07:52:30 +00:00
end
and begin
2024-11-29 00:13:58 +00:00
getOSConfig i18n.localeSettings --json |
2024-07-13 07:52:30 +00:00
jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")'
2024-10-06 19:25:34 +00:00
end | arch-chroot "$mountDir" tee /etc/locale.conf >/dev/null
2024-07-13 07:52:30 +00:00
and if set -q keyMap
2024-10-06 19:25:34 +00:00
echo "KEYMAP=$keyMap" | arch-chroot "$mountDir" tee /etc/vconsole.conf >/dev/null
2024-07-13 07:52:30 +00:00
end
2024-10-06 19:25:34 +00:00
and echo (getOSConfig hostname) | arch-chroot "$mountDir" tee /etc/hostname >/dev/null
2024-07-13 07:52:30 +00:00
and runInOS fish "$tempDir/../Software/systemd-networkd/main.fish"
2024-12-07 20:14:36 +00:00
and runInOS fish "$tempDir/../Software/btrfs/main.fish"
2024-07-13 07:52:30 +00:00
and arch-chroot "$mountDir" mkinitcpio -P
2024-10-13 13:35:24 +00:00
and runInOS fish "$tempDir/../Software/grub/main.fish"
2024-07-13 07:52:30 +00:00
2024-09-22 15:50:05 +00:00
and if set -l keyLayout (getOSConfig keyboardLayout)
2024-07-13 07:52:30 +00:00
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-09 00:22:12 +00:00
end
2024-07-13 07:52:30 +00:00
end
2024-07-08 00:47:49 +00:00
2024-07-13 07:52:30 +00:00
function autologin -S
2024-12-07 20:46:53 +00:00
set -l mountDir (getOSConfig fileSystems.rootDir)
2024-07-13 07:52:30 +00:00
set -l file "/etc/systemd/system/getty@tty1.service.d/autologin.conf"
arch-chroot "$mountDir" mkdir -p (dirname "$file")
2024-07-11 20:05:36 +00:00
2024-09-12 16:52:03 +00:00
and begin
2024-07-13 07:52:30 +00:00
printf %s\n \
"[Service]" \
"ExecStart=" \
"ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root %I \$TERM"
2024-10-06 19:25:34 +00:00
end | arch-chroot "$mountDir" tee "$file" >/dev/null
2024-07-08 00:47:49 +00:00
end
2024-07-13 07:52:30 +00:00
if not type -q getInstallerScript
function getInstallerScript -S
echo "$dir/install.fish"
end
end
2024-07-16 13:22:15 +00:00
runSetup
2024-07-08 00:47:49 +00:00
end