#!/usr/bin/env bash

# Select system timezone declaratively for Nomarchy NixOS.

STATE_FILE="/etc/nixos/state.json"

timezone=$(timedatectl list-timezones | gum filter --height 20 --header "Set timezone") || exit 1

sudo jq --arg tz "$timezone" '.timezone = $tz' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"

echo "Timezone is now set to $timezone. Applying changes..."
sudo nomarchy-sys-update
