From 6318a63307cd94fb2b7844501fb9bbc00f61067b Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 11 Jul 2024 21:58:46 +0200 Subject: [PATCH] Allow specifying the timezone --- lib/modules/valhalla.nix | 28 ++++++++++++++++++++++------ profiles/Generic/config.nix | 2 ++ scripts/Arch/OS/setup.fish | 15 ++++++++++++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/lib/modules/valhalla.nix b/lib/modules/valhalla.nix index df1e7ec3..7740500a 100644 --- a/lib/modules/valhalla.nix +++ b/lib/modules/valhalla.nix @@ -1,6 +1,22 @@ -{ ... }: { - imports = [ - ./i18n.nix - ./partition.nix - ]; -} +{ lib, ... }: + let + inherit (lib) + mkOption + types + ; + in { + imports = [ + ./i18n.nix + ./partition.nix + ]; + + options = { + valhalla = { + timeZone = mkOption { + type = types.nullOr types.str; + description = "The time zone of the system."; + default = null; + }; + }; + }; + } diff --git a/profiles/Generic/config.nix b/profiles/Generic/config.nix index 274f472a..afe1296d 100644 --- a/profiles/Generic/config.nix +++ b/profiles/Generic/config.nix @@ -34,6 +34,8 @@ }; }; + timeZone = "Europe/Zurich"; + i18n = { localeSettings = let defaultLocale = "en_US.UTF-8"; diff --git a/scripts/Arch/OS/setup.fish b/scripts/Arch/OS/setup.fish index 7c86cdf1..1e3bb19e 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_TIMEZONE || set -l ARCH_TIMEZONE "Europe/Zurich" 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_X11_KEYMAP || set -l ARCH_X11_KEYMAP ch @@ -23,7 +22,12 @@ begin set -l tempDir "$tempRoot/$relativeDir" loadkeys "$ARCH_KEYMAP" - and timedatectl set-timezone "$ARCH_TIMEZONE" + + and if set -l timezone (getConfig valhalla.timeZone) + timedatectl set-timezone "$timezone" + else + true + end and CONFIG_MODULE=$CONFIG_MODULE bash "$dir/../../Common/OS/partition.sh" @@ -46,7 +50,12 @@ begin and arch-chroot "$mountDir" systemctl enable NetworkManager - and arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$ARCH_TIMEZONE" /etc/localtime + and if set -q timezone + arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime + else + true + end + and arch-chroot "$mountDir" hwclock --systohc and begin