Chrony: Consider always online
sudo in hook thinks NoNewPrivleges flag is stil active. I don't have it in me to try to fix this, all my computers are more or less always online, and it doesn't sync time often enough to be noticeable on battery (proabably).
This commit is contained in:
parent
a4978d6c12
commit
12c176de22
2 changed files with 1 additions and 36 deletions
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
@ -9,39 +8,8 @@
|
|||
services.chrony.enable = true;
|
||||
|
||||
networking = {
|
||||
# Using community provided service
|
||||
# Using european servers
|
||||
timeServers = map (n: "${toString n}.europe.pool.ntp.org") (lib.lists.range 0 3);
|
||||
|
||||
# Only try to sync time when we have internet connection
|
||||
dhcpcd.runHook = ''
|
||||
if $if_up
|
||||
then
|
||||
/run/wrappers/bin/sudo ${config.services.chrony.package}/bin/chronyc online
|
||||
elif $if_down
|
||||
then
|
||||
/run/wrappers/bin/sudo ${config.services.chrony.package}/bin/chronyc offline
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
# Allow dhcpcd to control chrony
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = [ "dhcpcd" ];
|
||||
commands =
|
||||
builtins.map
|
||||
(arg: {
|
||||
command = "${config.services.chrony.package}/bin/chronyc ${arg}";
|
||||
options = [ "NOPASSWD" ];
|
||||
|
||||
})
|
||||
[
|
||||
"online"
|
||||
"offline"
|
||||
];
|
||||
}
|
||||
];
|
||||
systemd.services.dhcpcd.serviceConfig.NoNewPrivileges = false;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -90,9 +90,6 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# Wait until there's a connection to fetch time
|
||||
services.chrony.serverOption = "offline";
|
||||
|
||||
systemd.services.wifi_apply = {
|
||||
after = [ "wpa_supplicant.service" ];
|
||||
wantedBy = [ "wpa_supplicant.service" ];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue