1 { config, lib, pkgs, ... }:
4 tzdir = "${pkgs.tzdata}/share/zoneinfo";
5 nospace = str: lib.filter (c: c == " ") (lib.stringToCharacters str) == [];
6 timezone = lib.types.nullOr (lib.types.addCheck lib.types.str nospace)
7 // { description = "null or string without spaces"; };
9 lcfg = config.location;
18 timeZone = lib.mkOption {
21 example = "America/New_York";
23 The time zone used when displaying times and dates. See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
24 for a comprehensive list of possible values for this setting.
26 If null, the timezone will default to UTC and can be set imperatively
31 hardwareClockInLocalTime = lib.mkOption {
33 type = lib.types.bool;
34 description = "If set, keep the hardware clock in local time instead of UTC.";
41 latitude = lib.mkOption {
42 type = lib.types.float;
44 Your current latitude, between
45 `-90.0` and `90.0`. Must be provided
50 longitude = lib.mkOption {
51 type = lib.types.float;
53 Your current longitude, between
54 between `-180.0` and `180.0`. Must be
55 provided along with latitude.
59 provider = lib.mkOption {
60 type = lib.types.enum [ "manual" "geoclue2" ];
63 The location provider to use for determining your location. If set to
64 `manual` you must also provide latitude/longitude.
73 environment.sessionVariables.TZDIR = "/etc/zoneinfo";
75 services.geoclue2.enable = lib.mkIf (lcfg.provider == "geoclue2") true;
77 # This way services are restarted when tzdata changes.
78 systemd.globalEnvironment.TZDIR = tzdir;
80 systemd.services.systemd-timedated.environment = lib.optionalAttrs (config.time.timeZone != null) { NIXOS_STATIC_TIMEZONE = "1"; };
83 zoneinfo.source = tzdir;
84 } // lib.optionalAttrs (config.time.timeZone != null) {
85 localtime.source = "/etc/zoneinfo/${config.time.timeZone}";
86 localtime.mode = "direct-symlink";