Show time
Ok no actually I meant Fix time but Show time sounds good so that's officially the commit's name now.
This commit is contained in:
parent
13eeeabc92
commit
0229cab124
4 changed files with 49 additions and 16 deletions
47
os/time/default.nix
Normal file
47
os/time/default.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
config = {
|
||||
# Apparently better than reference implementation
|
||||
services.chrony.enable = true;
|
||||
|
||||
networking = {
|
||||
# Using community provided service
|
||||
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;
|
||||
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue