2017-12-03 10:41:22 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.localtime;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.localtime = {
|
|
|
|
enable = mkOption {
|
2020-04-20 18:05:26 +00:00
|
|
|
type = types.bool;
|
2017-12-03 10:41:22 +00: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 17:01:30 +00:00
|
|
|
services.geoclue2 = {
|
|
|
|
enable = true;
|
2019-08-13 21:52:01 +00:00
|
|
|
appConfig.localtime = {
|
2019-06-03 17:01:30 +00:00
|
|
|
isAllowed = true;
|
|
|
|
isSystem = true;
|
|
|
|
};
|
|
|
|
};
|
2017-12-03 10:41:22 +00:00
|
|
|
|
2019-06-16 11:21:20 +00:00
|
|
|
# Install the polkit rules.
|
2021-02-09 17:21:14 +00:00
|
|
|
environment.systemPackages = [ pkgs.localtime ];
|
2019-06-16 11:21:20 +00:00
|
|
|
# Install the systemd unit.
|
2021-02-09 17:21:14 +00:00
|
|
|
systemd.packages = [ pkgs.localtime ];
|
2017-12-03 10:41:22 +00:00
|
|
|
|
2019-09-14 17:51:29 +00:00
|
|
|
users.users.localtimed = {
|
2021-02-09 17:21:14 +00:00
|
|
|
description = "localtime daemon";
|
|
|
|
isSystemUser = true;
|
2021-09-20 20:16:09 +00:00
|
|
|
group = "localtimed";
|
2019-09-14 17:51:29 +00:00
|
|
|
};
|
2021-09-20 20:16:09 +00:00
|
|
|
users.groups.localtimed = {};
|
2019-09-14 17:51:29 +00:00
|
|
|
|
2017-12-03 10:41:22 +00:00
|
|
|
systemd.services.localtime = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-06-16 11:21:20 +00:00
|
|
|
serviceConfig.Restart = "on-failure";
|
2017-12-03 10:41:22 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|