Load language settings from the config

This commit is contained in:
Manuel Thalmann 2024-07-09 02:22:12 +02:00
parent 75c45473ac
commit 52384e532a
4 changed files with 22 additions and 7 deletions

View file

@ -47,6 +47,7 @@ irssi
iw iw
iwd iwd
jfsutils jfsutils
jq
kitty-terminfo kitty-terminfo
ldns ldns
less less

View file

@ -1,14 +1,14 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
. "$dir/../../Common/Scripts/config.fish"
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 ("$dir/../../eval-module.sh" "$CONFIG_MODULE" partition.rootDir --raw) set -q ARCH_MOUNT_ROOT || set -l ARCH_MOUNT_ROOT (getConfig partition.rootDir --raw)
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 -q LOCALE_PATTERN || set -l LOCALE_PATTERN "\(de_CH\|en_US\)"
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
@ -52,13 +52,17 @@ begin
and arch-chroot "$ARCH_MOUNT_ROOT" ln -sf "/usr/share/zoneinfo/$ARCH_TIMEZONE" /etc/localtime and arch-chroot "$ARCH_MOUNT_ROOT" ln -sf "/usr/share/zoneinfo/$ARCH_TIMEZONE" /etc/localtime
and arch-chroot "$ARCH_MOUNT_ROOT" hwclock --systohc and arch-chroot "$ARCH_MOUNT_ROOT" hwclock --systohc
and arch-chroot "$ARCH_MOUNT_ROOT" sed -i "s/^#\?\($LOCALE_PATTERN.*\)\$/\1/" /etc/locale.gen and begin
and arch-chroot "$ARCH_MOUNT_ROOT" locale-gen 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
and begin and begin
echo "LANG=de_CH.UTF-8" getConfig i18n.localeSettings --json | \
echo "LANGUAGE=en_US.UTF-8" jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")'
echo "LC_MESSAGES=en_US.UTF-8"
end | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/locale.conf > /dev/null 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 "KEYMAP=$ARCH_KEYMAP" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/vconsole.conf > /dev/null

View file

@ -0,0 +1,5 @@
#!/bin/env fish
function getConfig -S -a property
. "$(status dirname)/eval-module.fish"
evalModule "$CONFIG_MODULE" "$property" $argv[2..]
end

View file

@ -0,0 +1,5 @@
#!/bin/env fish
function evalModule --argument-names modulePath property
set -l nixPkgs 'import <nixpkgs> { config = {}; overlay = []; }'
nix eval --file "$modulePath" --apply "_: (($nixPkgs).lib.evalModules { modules = [ _ ]; }).config.$property" $argv[3..]
end