2017-12-03 11:41:22 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.localtime;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.localtime = {
|
|
|
|
enable = mkOption {
|
2020-04-20 20:05:26 +02:00
|
|
|
type = types.bool;
|
2017-12-03 11:41:22 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable <literal>localtime</literal>, simple daemon for keeping the system
|
|
|
|
timezone up-to-date based on the current location. It uses geoclue2 to
|
|
|
|
determine the current location and systemd-timedated to actually set
|
|
|
|
the timezone.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-06-03 19:01:30 +02:00
|
|
|
services.geoclue2 = {
|
|
|
|
enable = true;
|
2019-08-13 23:52:01 +02:00
|
|
|
appConfig.localtime = {
|
2019-06-03 19:01:30 +02:00
|
|
|
isAllowed = true;
|
|
|
|
isSystem = true;
|
|
|
|
};
|
|
|
|
};
|
2017-12-03 11:41:22 +01:00
|
|
|
|
2019-06-16 13:21:20 +02:00
|
|
|
# Install the polkit rules.
|
2021-02-09 18:21:14 +01:00
|
|
|
environment.systemPackages = [ pkgs.localtime ];
|
2019-06-16 13:21:20 +02:00
|
|
|
# Install the systemd unit.
|
2021-02-09 18:21:14 +01:00
|
|
|
systemd.packages = [ pkgs.localtime ];
|
2017-12-03 11:41:22 +01:00
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
users.users.localtimed = {
|
2021-02-09 18:21:14 +01:00
|
|
|
description = "localtime daemon";
|
|
|
|
isSystemUser = true;
|
2021-09-20 22:16:09 +02:00
|
|
|
group = "localtimed";
|
2019-09-14 19:51:29 +02:00
|
|
|
};
|
2021-09-20 22:16:09 +02:00
|
|
|
users.groups.localtimed = {};
|
2019-09-14 19:51:29 +02:00
|
|
|
|
2017-12-03 11:41:22 +01:00
|
|
|
systemd.services.localtime = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-06-16 13:21:20 +02:00
|
|
|
serviceConfig.Restart = "on-failure";
|
2017-12-03 11:41:22 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|