NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.35k stars 13.58k forks source link

Enabling Geoclue2 should enable services.avahi #329522

Open SrTobi opened 1 month ago

SrTobi commented 1 month ago

Describe the bug

I noticed that redshift doesn't find the location via geoclue2 anymore. It seems that geoclue2 requires another service called avahi, which didn't run on my system.

Setting

location.provider = "geoclue2";

enables the geoclue2 service, but that one fails to provide location data. Asking for the status gives

[~]$ systemctl status geoclue

Jul 23 23:35:30 thinkjet systemd[1]: Starting Location Lookup Service...
Jul 23 23:35:30 thinkjet .geoclue-wrappe[86012]: Failed to open /etc/geoclue/conf.d/: Error opening directory “/etc/geoclue/conf.d/”: No such file or directory
Jul 23 23:35:30 thinkjet .geoclue-wrappe[86012]: Failed to connect to avahi service: Daemon not running
Jul 23 23:35:30 thinkjet systemd[1]: Started Location Lookup Service.

after manually enabling avahi via

services.avahi.enable = true;

Everything works fine...

Note: I think for many people the avahi service is automatically enabled by other settings. For example guix, gnome, and pulseaudio with hasZeroconf will enable avahi.

Expected behavior

I think when the geoclue2 service is enabled, the avahi service should be enabled too.

Notify maintainers

@davidak, @bobby285271

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.41, NixOS, 24.11 (Vicuna), 24.11pre655874.68c9ed8bbed9`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

bobby285271 commented 1 month ago

Hmmm yeah I guess we should do that when services.geoclue2.enableNmea is enabled.

stephen-huan commented 1 month ago

Since the fix is one line, I added it to https://github.com/NixOS/nixpkgs/pull/329654 although the PR is unrelated. Note that since enableNmea is enabled by default, this now pulls in avahi even though avahi isn't necessary for most of the providers (definitely not wifi and static, I haven't tested the others). I consider this minor since someone concerned with minimalism can always disable this with enableNmea = false. We don't have the granularity to know whether enableNmea was explicitly enabled anyways.

@SrTobi to be clear your provider is NMEA, correct?

SrTobi commented 1 month ago

Ok, please wait before merging this... today geoclue isn't working for me anymore even though the avahi service is enabled... I can therefore not be sure if my assessment above is correct... I have to investigate this further.

stephen-huan commented 1 month ago

Some steps that may help narrow the issue:

  1. How are you testing that geoclue works? Through redshift? What does the demo-agent show, e.g. /nix/store/fbs4f1xrx0bj3mggc0rqxx7p91z16ccm-geoclue-2.7.0/libexec/geoclue-2.0/demos/where-am-i (the path to geoclue can be found with ls /nix/store | grep geoclue-2.7.0, for example).

  2. What is your intended provider? (e.g. nmea, wifi, static-source). Does it work if you set your location statically like https://github.com/NixOS/nixpkgs/issues/311595#issuecomment-2247989491?

  3. What do systemctl status geoclue.service, journalctl -u geoclue.service, systemctl status --user geoclue-agent.service, journalctl --user-unit=geoclue-agent.service, systemctl status --user redshift.service, and journalctl --user-unit redshift.service show? If systemctl restart geoclue.service fixes the issue (i.e. the issue only happens at boot), the boot log journalctl -b can also be useful.

  4. Presumably redshift used to work and recently broke. Since the module hasn't been changed in months (https://github.com/NixOS/nixpkgs/commit/6afb255d976f85f3359e4929abd6f5149c323a02), what caused the change? did you upgrade recently? Otherwise, if your provider is wifi, I can think of https://github.com/NixOS/nixpkgs/issues/321121 as a possible culprit.

99linesofcode commented 1 week ago

Please refer to #321121 for more information on why geoclue2 is currently failing. That fact that it is no longer working probably has nothing to do with the changes proposed in https://github.com/NixOS/nixpkgs/pull/329654.

stephen-huan commented 1 week ago

The current working premise implied by https://github.com/NixOS/nixpkgs/issues/329522#issuecomment-2246679016 is that the author of the issue is using the nmea provider, which to the best of my knowledge is the only provider which requires the avahi service. If they were using the wifi provider (the only provider affected by the Mozilla Location Service (MLS) changes), avahi isn't relevant.

The PR https://github.com/NixOS/nixpkgs/pull/329654 adds the static (and compass) source(s), allowing one to circumvent the MLS issues with manual intervention. I initially included the unrelated fix to enable avahi when nmea is enabled since it was simple, but I've since removed it due to the concerns in https://github.com/NixOS/nixpkgs/issues/329522#issuecomment-2249569279.

Re: MLS I already mentioned this in my 4th point of https://github.com/NixOS/nixpkgs/issues/329522#issuecomment-2249622510.