2016-12-16 11:20:28 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.time;
|
|
|
|
|
|
|
|
timeZone = optionalString (cfg.timeZone != null) ''
|
|
|
|
if [ -z $(systemsetup -listtimezones | grep "^ ${cfg.timeZone}$") ]; then
|
|
|
|
echo "${cfg.timeZone} is not a valid timezone. The command 'listtimezones' will show a list of valid time zones." >&2
|
|
|
|
false
|
|
|
|
fi
|
2023-09-15 19:55:46 +00:00
|
|
|
systemsetup -settimezone "${cfg.timeZone}" 2>/dev/null 1>&2
|
2016-12-16 11:20:28 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
|
|
|
time.timeZone = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "America/New_York";
|
2024-04-14 21:02:32 +00:00
|
|
|
description = ''
|
2023-06-22 11:21:32 +00:00
|
|
|
The time zone used when displaying times and dates. See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
|
|
|
|
or run {command}`sudo systemsetup -listtimezones`
|
2016-12-16 11:20:28 +00:00
|
|
|
for a comprehensive list of possible values for this setting.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2018-01-12 21:24:34 +00:00
|
|
|
system.activationScripts.time.text = mkIf (cfg.timeZone != null) ''
|
2016-12-16 11:20:28 +00:00
|
|
|
# Set defaults
|
|
|
|
echo "configuring time..." >&2
|
|
|
|
|
|
|
|
${timeZone}
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|