1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.localtime;
7in {
8 options = {
9 services.localtime = {
10 enable = mkOption {
11 type = types.bool;
12 default = false;
13 description = ''
14 Enable <literal>localtime</literal>, simple daemon for keeping the system
15 timezone up-to-date based on the current location. It uses geoclue2 to
16 determine the current location and systemd-timedated to actually set
17 the timezone.
18 '';
19 };
20 };
21 };
22
23 config = mkIf cfg.enable {
24 services.geoclue2 = {
25 enable = true;
26 appConfig.localtime = {
27 isAllowed = true;
28 isSystem = true;
29 };
30 };
31
32 # Install the polkit rules.
33 environment.systemPackages = [ pkgs.localtime ];
34 # Install the systemd unit.
35 systemd.packages = [ pkgs.localtime ];
36
37 users.users.localtimed = {
38 description = "localtime daemon";
39 isSystemUser = true;
40 };
41
42 systemd.services.localtime = {
43 wantedBy = [ "multi-user.target" ];
44 serviceConfig.Restart = "on-failure";
45 };
46 };
47}