1 { config, lib, pkgs, ... }:
6 cfg = config.services.automatic-timezoned;
10 services.automatic-timezoned = {
15 Enable `automatic-timezoned`, simple daemon for keeping the system
16 timezone up-to-date based on the current location. It uses geoclue2 to
17 determine the current location and systemd-timedated to actually set
20 To avoid silent overriding by the service, if you have explicitly set a
21 timezone, either remove it or ensure that it is set with a lower priority
22 than the default value using `lib.mkDefault` or `lib.mkOverride`. This is
23 to make the choice deliberate. An error will be presented otherwise.
26 package = mkPackageOption pkgs "automatic-timezoned" { };
30 config = mkIf cfg.enable {
31 # This will give users an error if they have set an explicit time
32 # zone, rather than having the service silently override it.
35 security.polkit.extraConfig = ''
36 polkit.addRule(function(action, subject) {
37 if (action.id == "org.freedesktop.timedate1.set-timezone"
38 && subject.user == "automatic-timezoned") {
39 return polkit.Result.YES;
46 appConfig.automatic-timezoned = {
49 users = [ (toString config.ids.uids.automatic-timezoned) ];
55 automatic-timezoned = {
56 description = "Automatically update system timezone based on location";
57 requires = [ "automatic-timezoned-geoclue-agent.service" ];
58 after = [ "automatic-timezoned-geoclue-agent.service" ];
61 User = "automatic-timezoned";
62 ExecStart = "${cfg.package}/bin/automatic-timezoned";
64 wantedBy = [ "default.target" ];
67 automatic-timezoned-geoclue-agent = {
68 description = "Geoclue agent for automatic-timezoned";
69 requires = [ "geoclue.service" ];
70 after = [ "geoclue.service" ];
73 User = "automatic-timezoned";
74 ExecStart = "${pkgs.geoclue2-with-demo-agent}/libexec/geoclue-2.0/demos/agent";
75 Restart = "on-failure";
78 wantedBy = [ "default.target" ];
84 users.automatic-timezoned = {
85 description = "automatic-timezoned";
86 uid = config.ids.uids.automatic-timezoned;
87 group = "automatic-timezoned";
89 groups.automatic-timezoned = {
90 gid = config.ids.gids.automatic-timezoned;