1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-24 06:31:02 +00:00
nixpkgs/nixos/modules/services/system/localtime.nix
Domen Kožar d64ba1c060
Add localtime package and nixos module
Simple daemon for keeping system timezone up-to-date via geoclue2.

Sadly i3 status needs to be restarted for timezone changes.
2017-12-03 11:42:51 +01:00

61 lines
1.6 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.localtime;
in {
options = {
services.localtime = {
enable = mkOption {
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 {
services.geoclue2.enable = true;
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.timedate1.set-timezone"
&& subject.user == "localtimed") {
return polkit.Result.YES;
}
});
'';
users.users = [{
name = "localtimed";
description = "Taskserver user";
}];
systemd.services.localtime = {
description = "localtime service";
wantedBy = [ "multi-user.target" ];
partOf = [ "geoclue.service "];
serviceConfig = {
Restart = "on-failure";
# TODO: make it work with dbus
#DynamicUser = true;
Nice = 10;
User = "localtimed";
PrivateTmp = "yes";
PrivateDevices = true;
PrivateNetwork = "yes";
NoNewPrivileges = "yes";
ProtectSystem = "strict";
ProtectHome = true;
ExecStart = "${pkgs.localtime}/bin/localtimed";
};
};
};
}