blob: 5f7a5f56bbe175dfcf2818dfea9dcd9fc3b621d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
{ 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
systemsetup -settimezone "${cfg.timeZone}" > /dev/null
'';
in
{
options = {
time.timeZone = mkOption {
type = types.nullOr types.str;
default = null;
example = "America/New_York";
description = ''
The time zone used when displaying times and dates. See <link
xlink:href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"/>
or run <command>sudo systemsetup -listtimezones</command>
for a comprehensive list of possible values for this setting.
'';
};
};
config = {
system.activationScripts.time.text = ''
# Set defaults
echo "configuring time..." >&2
${timeZone}
'';
};
}
|