From ce1b74352642c4de3ce94a6dcf10c057b6989f6a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 11 Jul 2024 22:10:57 +0200 Subject: [PATCH] Allow setting the keyboard layout from the config file --- lib/modules/valhalla.nix | 6 ++++++ profiles/Generic/config.nix | 1 + scripts/Arch/OS/setup.fish | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/modules/valhalla.nix b/lib/modules/valhalla.nix index abab8a39..f308fc6e 100644 --- a/lib/modules/valhalla.nix +++ b/lib/modules/valhalla.nix @@ -23,6 +23,12 @@ description = "The console key map of the system."; default = null; }; + + keyboardLayout = mkOption { + type = types.nullOr types.str; + description = "The X11 keyboard layout of the system."; + default = null; + }; }; }; } diff --git a/profiles/Generic/config.nix b/profiles/Generic/config.nix index 4f0b5bbd..537e6bef 100644 --- a/profiles/Generic/config.nix +++ b/profiles/Generic/config.nix @@ -36,6 +36,7 @@ timeZone = "Europe/Zurich"; keyMap = "de_CH-latin1"; + keyboardLayout = "ch"; i18n = { localeSettings = diff --git a/scripts/Arch/OS/setup.fish b/scripts/Arch/OS/setup.fish index d3e8e5ce..c9f01642 100644 --- a/scripts/Arch/OS/setup.fish +++ b/scripts/Arch/OS/setup.fish @@ -5,7 +5,6 @@ begin source "$dir/../../Common/Scripts/hooks.fish" set -q CONFIG_MODULE || set -l CONFIG_MODULE "$dir/config.nix" - set -q ARCH_X11_KEYMAP || set -l ARCH_X11_KEYMAP ch set -l mountDir (getConfig valhalla.partition.rootDir) @@ -91,12 +90,16 @@ begin USER_GROUPS="$USER_GROUPS" \ arch-chroot "$mountDir" bash "$tempDir/user.sh" - and 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=$ARCH_X11_KEYMAP" - and systemd-nspawn -D "$mountDir" systemctl disable "$serviceName" - and rm "$serviceFile" + 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" + else + true + end end end