8 cfg = config.services.automatic-timezoned;
12 services.automatic-timezoned = {
13 enable = lib.mkOption {
14 type = lib.types.bool;
17 Enable `automatic-timezoned`, simple daemon for keeping the system
18 timezone up-to-date based on the current location. It uses geoclue2 to
19 determine the current location and systemd-timedated to actually set
22 To avoid silent overriding by the service, if you have explicitly set a
23 timezone, either remove it or ensure that it is set with a lower priority
24 than the default value using `lib.mkDefault` or `lib.mkOverride`. This is
25 to make the choice deliberate. An error will be presented otherwise.
28 package = lib.mkPackageOption pkgs "automatic-timezoned" { };
32 config = lib.mkIf cfg.enable {
33 # This will give users an error if they have set an explicit time
34 # zone, rather than having the service silently override it.
37 security.polkit.extraConfig = ''
38 polkit.addRule(function(action, subject) {
39 if (action.id == "org.freedesktop.timedate1.set-timezone"
40 && subject.user == "automatic-timezoned") {
41 return polkit.Result.YES;
48 appConfig.automatic-timezoned = {
51 users = [ (toString config.ids.uids.automatic-timezoned) ];
57 automatic-timezoned = {
58 description = "Automatically update system timezone based on location";
59 requires = [ "automatic-timezoned-geoclue-agent.service" ];
60 after = [ "automatic-timezoned-geoclue-agent.service" ];
63 User = "automatic-timezoned";
64 ExecStart = "${cfg.package}/bin/automatic-timezoned";
66 wantedBy = [ "default.target" ];
69 automatic-timezoned-geoclue-agent = {
70 description = "Geoclue agent for automatic-timezoned";
71 requires = [ "geoclue.service" ];
72 after = [ "geoclue.service" ];
75 User = "automatic-timezoned";
76 ExecStart = "${pkgs.geoclue2-with-demo-agent}/libexec/geoclue-2.0/demos/agent";
77 Restart = "on-failure";
80 wantedBy = [ "default.target" ];
86 users.automatic-timezoned = {
87 description = "automatic-timezoned";
88 uid = config.ids.uids.automatic-timezoned;
89 group = "automatic-timezoned";
91 groups.automatic-timezoned = {
92 gid = config.ids.gids.automatic-timezoned;