-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
localtimed fails to set time zone #68489
Comments
This comment was marked as duplicate.
This comment was marked as duplicate.
I'm having the same issue. I've been told on IRC that the only way to set the timezone is by using the |
This comment was marked as duplicate.
This comment was marked as duplicate.
Same issue here. |
I marked this as stale due to inactivity. → More info |
Still happening, however, for me I get the following logs:
I need to run
However after running
|
For some unknown reason ([1] and [2]), `localtimed` is not setting the time zone correctly if no previous set value exists. Workaround this issue by forcing a base value, which may or may not be updated later by the service. There isn't much we can do other than wait for the issue to be resolved. [1]: NixOS/nixpkgs#67673 [2]: NixOS/nixpkgs#68489 Signed-off-by: Luis Holanda <[email protected]>
Not stale; still happens in 22.05. |
Is it possible that |
Also, is it possible that this only works with specific network interfaces or something? I'm only connecting to Wi-Fi. |
I've been using it successfully for a while now, you obviously need It can fail when geoclue doesn't provide a timezone, in which case you can just manually |
@lovesegfault Would you be willing to share the relevant configuration? GeoClue2 is already enabled as part of setting Relevant logs after simplifying the settings even more, applying, and rebooting: $ journalctl --boot --unit=geoclue.service
Nov 16 20:11:33 whenua systemd[1]: Starting Location Lookup Service...
Nov 16 20:11:34 whenua systemd[1]: Started Location Lookup Service.
$ journalctl --boot --unit=localtime.service
Nov 16 20:11:33 whenua systemd[1]: Started Timezone Updater Daemon.
$ timedatectl
Local time: Wed 2022-11-16 20:20:34 UTC
Universal time: Wed 2022-11-16 20:20:34 UTC
RTC time: Wed 2022-11-16 20:20:34
Time zone: UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no |
@l0b0 Out of curiosity, is this on |
@lovesegfault 22.05 channel. |
@lovesegfault Thank you, that's really useful! I'll leave this open until I have a chance to test on 22.11. |
@lovesegfault I just applied this change on 22.11, and it did not work. The relevant services just keep restarting: $ journalctl --follow --output=cat --unit geoclue.service
Starting Location Lookup Service...
Started Location Lookup Service.
Service not used for 60 seconds. Shutting down..
geoclue.service: Deactivated successfully.
Starting Location Lookup Service...
Started Location Lookup Service.
Service not used for 60 seconds. Shutting down..
geoclue.service: Deactivated successfully.
Starting Location Lookup Service...
Started Location Lookup Service. $ journalctl --follow --output=cat --unit localtimed-geoclue-agent.service
Starting localtimed-geoclue-agent.service...
Started localtimed-geoclue-agent.service.
Geolocation service not in use
Geolocation service not in use
[…] |
On Removing |
I'm not sure what you mean here. As you can see from my last comment I no longer have |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/localtimed-broken-since-2019/25039/1 |
Hi @l0b0
|
Based on the documentation it looks like localtimed and automatic-timezoned should be mutually exclusive, because both of them say they "[keep] the system timezone up-to-date based on the current location". Both of them set up geoclue2, so I don't understand why As a side note, all |
I tried switching to automatic-timezoned (
Setting |
I fixed my issues with {
services.geoclue2.enableDemoAgent = lib.mkForce true;
} Enabling GNOME or Pantheon disables the demo agent and removes it from the agent whitelist which is necessary for the NixOS |
@Enzime Can confirm your workaround on release-23.05, on two separate machines. @7c6f434c @mimame Would either of you be willing to look into this? |
I don't have any NixOS environment around (nor do I have any DE) to try this easily… (I have only ever cared about geoclue as a library dependency of a few things, I am not even sure I have ever checked whether the data coming from it is reasonable) |
I think I've at least partially figured out what's causing the "Failed to set timezone" error. It seems to be a permission error, or at least related to one.
When run as root, this call succeeds for me. But if I run it as Weirdly, though, this only happens on one of my systems. On the other one, running the command as |
While there are a few issues with the Finding an alternative to MLS could take a while so for those looking for a workaround and willing to incur some costs associated with the Geolocation API, override services.geoclue2.geoProviderUrl = "https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_KEY" edit: clarified that there are costs associated with using the Geolocation API |
Decided I'd rather not incur any costs either. The Archlinux Wiki mentioned a couple of providers here: https://wiki.archlinux.org/title/System_time#Setting_based_on_geolocation. Seems like all of them are commercial parties. Most offer free access either with or without creating an account and obtaining an API key. edit: https://beacondb.net seems like a worthy FOSS alternative |
FWIW, I've been using beacondb for a while with the following config:
|
Yeah that's what I settled on yesterday as well. It's important to note however that beacondb is still in it's infancy and the developer is working on scaling it. This URL actually points to his home server, not the VPS he is in the process of setting up. See: https://codeberg.org/beacondb/beacondb/issues/5#issuecomment-2182940 for more info on this. |
Probably the problem is that Mozilla shut down their geolocation service. But we use it:
I found this alternative:
It queries many endpoints, so it seems to work here. |
|
@99linesofcode, I am trying to consolidate the (for me) relevant information in this thread on using geoclue with beacondb. I think I have it correctly set up and the only reason why it is currently not working for me is that my area is currently not covered by the DB (I started uploading reports already) but I am not 100% sure. Also I am not sure whether I can still set a default timeZone with automatic-timezoned enabled. Maybe you (or someone else) could quickly confirm? My config: # Set default timeZone to home time
time.timeZone = lib.mkDefault "Europe/Berlin";
# Enable automatic timezone updates
services.automatic-timezoned.enable = true;
# Force enable required geoclue2 DemoAgent, since GNOME disables it: https://github.com/NixOS/nixpkgs/issues/68489#issuecomment-1484030107
services.geoclue2.enableDemoAgent = lib.mkForce true;
# Use beacondb.net since Mozilla Location Service is retired: https://github.com/NixOS/nixpkgs/issues/321121
services.geoclue2.geoProviderUrl = "https://beacondb.net/v1/geolocate"; The log output from geoclue:
|
@Jasper-Ben hi, since last reporting on this I've switched time zones and haven't been able to get it working either. I haven't spent much time debugging this yet. I've resorted to manually updating my timezone through
|
@Jasper-Ben |
See #361373 for making tzupdate actually work out of the box when enabled. |
The demo agent must be manually enabled because Gnome disables it. See: NixOS/nixpkgs#68489 (comment)
Describe the bug
Enabling the localtime service is not enough to make time zone setting work. After starting it I get unhelpful messages like this in the journal:
The time zone never changes.
To Reproduce
Steps to reproduce the behavior:
services.localtime.enable = true;
time.timeZone = "UTC";
to work around systemd-timedated can't start because of missing /etc/localtime #67673sudo nixos-rebuild switch
Expected behavior
systemd-timedated should Just Work™.
Additional context
Rebooting does not help.
Removing
time.timeZone = "UTC";
, rebuilding and rebooting also does not help.Contributors: @dschrempf @deviant @xaverdh @rnhmjoj @volth @worldofpeace @domenkozar @lovesegfault Is it working for any of you? Any tips on what might be different? I've tried this on a few machines a few times now.
Metadata
"x86_64-linux"
Linux 4.19.71, NixOS, 19.03.173481.8a30e242181 (Koi)
yes
yes
nix-env (Nix) 2.2.2
"nixos-19.03.173481.8a30e242181"
""
/nix/var/nix/profiles/per-user/root/channels/nixos
and
"x86_64-linux"
Linux 4.19.71, NixOS, 19.09pre192418.e19054ab3cd (Loris)
yes
yes
nix-env (Nix) 2.3
"nixos-19.09pre192418.e19054ab3cd"
"nixpkgs-20.03pre193309.c4196cca9ac"
/home/username/.nix-defexpr/channels/nixpkgs
The text was updated successfully, but these errors were encountered: