2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-05-27 23:14:38 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2009-05-27 23:14:38 +00:00
|
|
|
|
2014-05-21 16:26:13 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
tzdir = "${pkgs.tzdata}/share/zoneinfo";
|
2017-10-09 18:52:25 +00:00
|
|
|
nospace = str: filter (c: c == " ") (stringToCharacters str) == [];
|
|
|
|
timezone = types.nullOr (types.addCheck types.str nospace)
|
|
|
|
// { description = "null or string without spaces"; };
|
2014-05-21 16:26:13 +00:00
|
|
|
|
2019-07-16 20:21:55 +00:00
|
|
|
lcfg = config.location;
|
|
|
|
|
2014-05-21 16:26:13 +00:00
|
|
|
in
|
|
|
|
|
2011-10-27 19:36:03 +00:00
|
|
|
{
|
2009-05-27 23:14:38 +00:00
|
|
|
options = {
|
|
|
|
|
2012-07-02 19:34:27 +00:00
|
|
|
time = {
|
2013-04-22 16:56:19 +00:00
|
|
|
|
2012-07-02 19:34:27 +00:00
|
|
|
timeZone = mkOption {
|
2017-07-31 14:55:24 +00:00
|
|
|
default = null;
|
2017-10-09 18:52:25 +00:00
|
|
|
type = timezone;
|
2012-07-02 19:34:27 +00:00
|
|
|
example = "America/New_York";
|
2022-07-19 13:05:45 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
The time zone used when displaying times and dates. See <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
|
2014-12-15 15:28:40 +00:00
|
|
|
for a comprehensive list of possible values for this setting.
|
2017-07-31 14:55:24 +00:00
|
|
|
|
|
|
|
If null, the timezone will default to UTC and can be set imperatively
|
|
|
|
using timedatectl.
|
2014-12-15 15:28:40 +00:00
|
|
|
'';
|
2012-07-02 19:34:27 +00:00
|
|
|
};
|
2009-05-27 23:14:38 +00:00
|
|
|
|
2012-07-11 19:33:34 +00:00
|
|
|
hardwareClockInLocalTime = mkOption {
|
2012-07-02 19:34:27 +00:00
|
|
|
default = false;
|
2015-07-19 16:49:23 +00:00
|
|
|
type = types.bool;
|
2022-07-19 13:05:45 +00:00
|
|
|
description = lib.mdDoc "If set, keep the hardware clock in local time instead of UTC.";
|
2012-07-02 19:34:27 +00:00
|
|
|
};
|
2013-04-22 16:56:19 +00:00
|
|
|
|
2012-07-02 19:34:27 +00:00
|
|
|
};
|
2019-07-16 20:21:55 +00:00
|
|
|
|
|
|
|
location = {
|
|
|
|
|
|
|
|
latitude = mkOption {
|
|
|
|
type = types.float;
|
2022-07-19 13:05:45 +00:00
|
|
|
description = lib.mdDoc ''
|
2019-07-16 20:21:55 +00:00
|
|
|
Your current latitude, between
|
2022-07-19 13:05:45 +00:00
|
|
|
`-90.0` and `90.0`. Must be provided
|
2019-07-16 20:21:55 +00:00
|
|
|
along with longitude.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
longitude = mkOption {
|
|
|
|
type = types.float;
|
2022-07-19 13:05:45 +00:00
|
|
|
description = lib.mdDoc ''
|
2019-07-16 20:21:55 +00:00
|
|
|
Your current longitude, between
|
2022-07-19 13:05:45 +00:00
|
|
|
between `-180.0` and `180.0`. Must be
|
2019-07-16 20:21:55 +00:00
|
|
|
provided along with latitude.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
provider = mkOption {
|
|
|
|
type = types.enum [ "manual" "geoclue2" ];
|
|
|
|
default = "manual";
|
2022-07-19 13:05:45 +00:00
|
|
|
description = lib.mdDoc ''
|
2019-07-16 20:21:55 +00:00
|
|
|
The location provider to use for determining your location. If set to
|
2022-07-19 13:05:45 +00:00
|
|
|
`manual` you must also provide latitude/longitude.
|
2019-07-16 20:21:55 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2009-05-27 23:14:38 +00:00
|
|
|
};
|
|
|
|
|
2011-10-27 19:36:03 +00:00
|
|
|
config = {
|
2009-05-27 23:14:38 +00:00
|
|
|
|
2014-06-13 15:56:46 +00:00
|
|
|
environment.sessionVariables.TZDIR = "/etc/zoneinfo";
|
2009-05-27 23:14:38 +00:00
|
|
|
|
2019-07-16 20:21:55 +00:00
|
|
|
services.geoclue2.enable = mkIf (lcfg.provider == "geoclue2") true;
|
|
|
|
|
2016-10-11 11:49:38 +00:00
|
|
|
# This way services are restarted when tzdata changes.
|
2014-05-21 16:26:13 +00:00
|
|
|
systemd.globalEnvironment.TZDIR = tzdir;
|
|
|
|
|
2017-07-31 14:55:24 +00:00
|
|
|
systemd.services.systemd-timedated.environment = lib.optionalAttrs (config.time.timeZone != null) { NIXOS_STATIC_TIMEZONE = "1"; };
|
2013-04-22 16:56:19 +00:00
|
|
|
|
2017-07-31 14:55:24 +00:00
|
|
|
environment.etc = {
|
|
|
|
zoneinfo.source = tzdir;
|
2017-07-31 15:12:53 +00:00
|
|
|
} // lib.optionalAttrs (config.time.timeZone != null) {
|
2017-07-31 14:55:24 +00:00
|
|
|
localtime.source = "/etc/zoneinfo/${config.time.timeZone}";
|
|
|
|
localtime.mode = "direct-symlink";
|
|
|
|
};
|
2011-10-27 19:36:03 +00:00
|
|
|
};
|
2013-04-22 16:56:19 +00:00
|
|
|
|
2009-05-27 23:14:38 +00:00
|
|
|
}
|