Publishing additional services with avahi

Hi,

I’m trying to publish some custom avahi service, however populating /etc/avahi/services has no effect, the daemon publish only the ssh and sftp-ssh services configured in /nix/store/cah5…/avahi-0.7/etc/avahi/services

Can someone point me in the right direction?

thank you
walter

Hi,

Did you try to set some of these options? NixOS Search Typically a service is configured from the nixos module, I don’t know how you generated the /etc/avahi/services file.

Yes I’ve set various options but the only thing I’ve been able to obtain is to publishing the bundled ssh and sftp-ssh services.

The /etc/avahi/services/ file is symlinked from /nix/store/… in the preStart command of the avahi-daemon.service

Looking at the nixos/test/avahi.nix file it seems a viable, even if suboptimal, solution may be to use the avahi-publish command

It does not symlink /etc/avahi/services on my system. Did you enabled something special feature for that?
This is the only directory created by avahi: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/avahi-daemon.nix#L223

Yes, I’m writing a custom module that, when enabled, set the avahi-daemon.preStart property.

I was expecting something like the following fragment to work, however avahi-daemon does not peek up the custom.service file

let 
     customXML = pkgs.writeText "custom.xml" ''
     <?xml>
         <service-group>
              <name replace-wildcards="no">Custom Service</name>
              <service>
              <type>...</type>
              <port>...</port>
              </service>
         </service-group>'';
in
{
    # other stuff removed since unrelated

    config = mkIf program.custom.enable {
         systemd.services.avahi-daemon.preStart = ''
                mkdir -p /etc/avahi/services
                ln -sf ${customXML} /etc/avahi/services/custom.service
         '';
}

The preStart fragment in my module is appended to the default mkdir -p /var/run/avahi-daemon.

Looking at the binary it seems that it read service files from $out/etc/avahi instead
of /etc/avahi. This is a packaging bug in nixpkgs and needs to be fixed.

$ strings /run/current-system/sw/bin/avahi-daemon | grep  /etc/avahi
/nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/services
/nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi
/nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/avahi-daemon.conf
                       /nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/avahi-daemon.conf
/nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/services/*.service
Not enough memory to read service directory /nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/services.
No service file found in /nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/services.
Failed to read /nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/services.
/nix/store/3dzww250xrxn81kl56v3f5r8122x3pmj-avahi-0.7/etc/avahi/hosts

It seems --syconfdir=/etc is missing from configureFlags.Should I open a issue on github?

yes. Maybe you can also manage to fix it. The configure flag alone will not be sufficient because the build system will try to install into /etc then. This must be patched in the build system or installation will fail

Ok, I’ll give it a try in the weekend