summary refs log tree commit diff
path: root/nixos/modules/services/system/localtime.nix
blob: 6383e454e76ba4d0672e8dfa02cc63770066b21a (plain) (blame)
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
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.localtimed;
in {
  options = {
    services.localtimed = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Enable <literal>localtimed</literal>, a simple daemon for keeping the
          system timezone up-to-date based on the current location. It uses
          geoclue2 to determine the current location.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    services.geoclue2.appConfig.localtimed = {
      isAllowed = true;
      isSystem = true;
    };

    # Install the polkit rules.
    environment.systemPackages = [ pkgs.localtime ];
    # Install the systemd unit.
    systemd.packages = [ pkgs.localtime ];

    systemd.services.localtime.wantedBy = [ "multi-user.target" ];
  };
}