Read mount root from nix config

This commit is contained in:
Manuel Thalmann 2024-07-11 20:24:24 +02:00
parent 7956df2e36
commit 1ae28ff60e
2 changed files with 23 additions and 21 deletions

View file

@ -1,6 +1,7 @@
#!/bin/env fish #!/bin/env fish
function installDrivers -S function installDrivers -S
pacstrap -K "$ARCH_MOUNT_ROOT" linux-firmware-marvell; . "(status dirname)/../../../scripts/Common/Scripts/config.fish"
pacstrap -K (getConfig valhalla.partition.rootDir) linux-firmware-marvell;
end end
CONFIG_MODULE="$(status dirname)/config.nix" \ CONFIG_MODULE="$(status dirname)/config.nix" \

View file

@ -6,11 +6,12 @@ begin
set -q CONFIG_MODULE || set -l CONFIG_MODULE "$dir/config.nix" set -q CONFIG_MODULE || set -l CONFIG_MODULE "$dir/config.nix"
set -q ARCH_TIMEZONE || set -l ARCH_TIMEZONE "Europe/Zurich" set -q ARCH_TIMEZONE || set -l ARCH_TIMEZONE "Europe/Zurich"
set -q ARCH_MOUNT_ROOT || set -l ARCH_MOUNT_ROOT (getConfig valhalla.partition.rootDir)
set -q ARCH_LANG || set -l ARCH_LANG en_US.UTF-8 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_KEYMAP || set -l ARCH_KEYMAP de_CH-latin1
set -q ARCH_X11_KEYMAP || set -l ARCH_X11_KEYMAP ch set -q ARCH_X11_KEYMAP || set -l ARCH_X11_KEYMAP ch
set -l mountDir (getConfig valhalla.partition.rootDir)
set -q USER_NAME || set -l USER_NAME manuel set -q USER_NAME || set -l USER_NAME manuel
set -q USER_DISPLAYNAME set -q USER_DISPLAYNAME
set -q USER_GROUPS || set -l USER_GROUPS "" set -q USER_GROUPS || set -l USER_GROUPS ""
@ -29,7 +30,7 @@ begin
and pacman-key --init and pacman-key --init
and pacman-key --populate and pacman-key --populate
and pacstrap -K "$ARCH_MOUNT_ROOT" \ and pacstrap -K "$mountDir" \
base \ base \
linux \ linux \
linux-firmware \ linux-firmware \
@ -40,46 +41,46 @@ begin
and runHook installDrivers "Installing drivers…" || true and runHook installDrivers "Installing drivers…" || true
and "$dir/../../copy-repo.fish" "$ARCH_MOUNT_ROOT$tempRoot" and "$dir/../../copy-repo.fish" "$mountDir$tempRoot"
and genfstab -U "$ARCH_MOUNT_ROOT" >> "$ARCH_MOUNT_ROOT/etc/fstab" and genfstab -U "$mountDir" >> "$mountDir/etc/fstab"
and arch-chroot "$ARCH_MOUNT_ROOT" systemctl enable NetworkManager and arch-chroot "$mountDir" systemctl enable NetworkManager
and arch-chroot "$ARCH_MOUNT_ROOT" ln -sf "/usr/share/zoneinfo/$ARCH_TIMEZONE" /etc/localtime and arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$ARCH_TIMEZONE" /etc/localtime
and arch-chroot "$ARCH_MOUNT_ROOT" hwclock --systohc and arch-chroot "$mountDir" hwclock --systohc
and begin and begin
getConfig valhalla.i18n.localeSettings --json | \ getConfig valhalla.i18n.localeSettings --json | \
jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")' jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")'
end | begin end | begin
read LOCALES read LOCALES
and arch-chroot "$ARCH_MOUNT_ROOT" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen and arch-chroot "$mountDir" sed -i "s/^#\?\(\($LOCALES\).*\)\$/\1/" /etc/locale.gen
end end
and begin and begin
getConfig valhalla.i18n.localeSettings --json | \ getConfig valhalla.i18n.localeSettings --json | \
jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")' jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")'
end | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/locale.conf > /dev/null end | arch-chroot "$mountDir" tee /etc/locale.conf > /dev/null
and echo "KEYMAP=$ARCH_KEYMAP" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/vconsole.conf > /dev/null and echo "KEYMAP=$ARCH_KEYMAP" | arch-chroot "$mountDir" tee /etc/vconsole.conf > /dev/null
and echo "$ARCH_HOSTNAME" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/hostname > /dev/null and echo "$ARCH_HOSTNAME" | arch-chroot "$mountDir" tee /etc/hostname > /dev/null
and arch-chroot "$ARCH_MOUNT_ROOT" mkinitcpio -P and arch-chroot "$mountDir" mkinitcpio -P
and arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/GRUB/install.sh" and arch-chroot "$mountDir" bash "$tempDir/../Software/GRUB/install.sh"
and arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/sudo/install.sh" and arch-chroot "$mountDir" bash "$tempDir/../Software/sudo/install.sh"
and pacstrap -K "$ARCH_MOUNT_ROOT" git and pacstrap -K "$mountDir" git
and USER_NAME="$USER_NAME" \ and USER_NAME="$USER_NAME" \
USER_DISPLAYNAME="$USER_DISPLAYNAME" \ USER_DISPLAYNAME="$USER_DISPLAYNAME" \
USER_GROUPS="$USER_GROUPS" \ USER_GROUPS="$USER_GROUPS" \
arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/user.sh" arch-chroot "$mountDir" bash "$tempDir/user.sh"
and set -l serviceName set-keymap.service and set -l serviceName set-keymap.service
and set -l serviceFile "$ARCH_MOUNT_ROOT/etc/systemd/system/$serviceName" and set -l serviceFile "$mountDir/etc/systemd/system/$serviceName"
and cp "$dir/$serviceName" "$serviceFile" and cp "$dir/$serviceName" "$serviceFile"
and systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl enable "$serviceName" and systemd-nspawn -D "$mountDir" systemctl enable "$serviceName"
and systemd-nspawn -bD "$ARCH_MOUNT_ROOT" -E "ARCH_X11_KEYMAP=$ARCH_X11_KEYMAP" and systemd-nspawn -bD "$mountDir" -E "ARCH_X11_KEYMAP=$ARCH_X11_KEYMAP"
and systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl disable "$serviceName" and systemd-nspawn -D "$mountDir" systemctl disable "$serviceName"
and rm "$serviceFile" and rm "$serviceFile"
end end
end end