1 { config, lib, pkgs, ... }:
6 cfg = config.services.localtimed;
8 imports = [ (lib.mkRenamedOptionModule [ "services" "localtime" ] [ "services" "localtimed" ]) ];
11 services.localtimed = {
16 Enable `localtimed`, a simple daemon for keeping the
17 system timezone up-to-date based on the current location. It uses
18 geoclue2 to determine the current location.
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 "localtime" { };
27 geoclue2Package = mkPackageOption pkgs "geoclue2-with-demo-agent" { };
31 config = mkIf cfg.enable {
32 # This will give users an error if they have set an explicit time
33 # zone, rather than having the service silently override it.
36 services.geoclue2.appConfig.localtimed = {
39 users = [ (toString config.ids.uids.localtimed) ];
42 # Install the polkit rules.
43 environment.systemPackages = [ cfg.package ];
45 systemd.services.localtimed = {
46 wantedBy = [ "multi-user.target" ];
47 partOf = [ "localtimed-geoclue-agent.service" ];
48 after = [ "localtimed-geoclue-agent.service" ];
50 ExecStart = "${cfg.package}/bin/localtimed";
51 Restart = "on-failure";
57 systemd.services.localtimed-geoclue-agent = {
58 wantedBy = [ "multi-user.target" ];
59 partOf = [ "geoclue.service" ];
60 after = [ "geoclue.service" ];
62 ExecStart = "${cfg.geoclue2Package}/libexec/geoclue-2.0/demos/agent";
63 Restart = "on-failure";
71 uid = config.ids.uids.localtimed;
74 groups.localtimed.gid = config.ids.gids.localtimed;