1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.localtime;
7in {
8 options = {
9 services.localtime = {
10 enable = mkOption {
11 default = false;
12 description = ''
13 Enable <literal>localtime</literal>, simple daemon for keeping the system
14 timezone up-to-date based on the current location. It uses geoclue2 to
15 determine the current location and systemd-timedated to actually set
16 the timezone.
17 '';
18 };
19 };
20 };
21
22 config = mkIf cfg.enable {
23 services.geoclue2.enable = true;
24
25 # so polkit will pick up the rules
26 environment.systemPackages = [ pkgs.localtime ];
27
28 users.users = [{
29 name = "localtimed";
30 description = "Taskserver user";
31 }];
32
33 systemd.services.localtime = {
34 description = "localtime service";
35 wantedBy = [ "multi-user.target" ];
36 partOf = [ "geoclue.service "];
37
38 serviceConfig = {
39 Restart = "on-failure";
40 # TODO: make it work with dbus
41 #DynamicUser = true;
42 Nice = 10;
43 User = "localtimed";
44 PrivateTmp = "yes";
45 PrivateDevices = true;
46 PrivateNetwork = "yes";
47 NoNewPrivileges = "yes";
48 ProtectSystem = "strict";
49 ProtectHome = true;
50 ExecStart = "${pkgs.localtime}/bin/localtimed";
51 };
52 };
53 };
54}