[SOLVED] Permission denied starting snapserver service

I’m completely new to NixOS so I apologise in advance if I’ve made a very basic error.

I’m trying to enable the snapserver service so I can cast a spotify stream around my house.

My configuration.nix file includes the following:

  services.snapserver.enable = true;
  services.snapserver.openFirewall = true;
  services.snapserver.streams = {
      spotify = {
          type = "librespot";
          query = {
              devicename = "SpotifyCast";
          };
          location = "${pkgs.librespot}";
      };
  };

However, when I rebuild the configuration, I get the following error message:

warning: the following units failed: snapserver.service

× snapserver.service - Snapserver
     Loaded: loaded (/etc/systemd/system/snapserver.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sun 2024-09-08 11:03:09 BST; 110ms ago
   Duration: 1ms
    Process: 3756 ExecStart=/nix/store/f8f1jwcc9q7vx8rdzd4rg38yap962hy0-snapcast-0.28.0/bin/snapserver --daemon --stream.stream=librespot:///nix/store/wqdijd4cxnvkdh6vy2pbdjvdks383zf0-librespot-0.4.2?name=spotify&devicename=SpotifyCast --stream.bind_to_address=:: --stream.port=1704 --tcp.enabled=1 --tcp.bind_to_address=:: --tcp.port=1705 --http.enabled=1 --http.bind_to_address=:: --http.port=1780 (code=exited, status=0/SUCCESS)
   Main PID: 3770 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 22ms

Sep 08 11:03:09 minihtpc snapserver[3770]: Using HTTP host name: minihtpc
Sep 08 11:03:09 minihtpc snapserver[3770]: PcmStream: spotify, sampleFormat: 44100:16:2
Sep 08 11:03:09 minihtpc snapserver[3770]: Stream: {"fragment":"","host":"","path":"/nix/store/wqdijd4cxnvkdh6vy2pbdjvdks383zf0-librespot-0.4.2","query":{"chunk_ms":"20","codec":"flac","devicename":"SpotifyCast","name":"spotify","sampleformat":"44100:16:2"},"raw":"librespot:////nix/store/wqdijd4cxnvkdh6vy2pbdjvdks383zf0-librespot-0.4.2?chunk_ms=20&codec=flac&devicename=SpotifyCast&name=spotify&sampleformat=44100:16:2","scheme":"librespot"}
Sep 08 11:03:09 minihtpc snapserver[3770]: Init - compression level: 2
Sep 08 11:03:09 minihtpc systemd[1]: Started Snapserver.
Sep 08 11:03:09 minihtpc snapserver[3770]: Server::start: execve failed: Permission denied
Sep 08 11:03:09 minihtpc snapserver[3770]: Exception: execve failed: Permission denied
Sep 08 11:03:09 minihtpc snapserver[3770]: Snapserver terminated.
Sep 08 11:03:09 minihtpc systemd[1]: snapserver.service: Main process exited, code=exited, status=1/FAILURE
Sep 08 11:03:09 minihtpc systemd[1]: snapserver.service: Failed with result 'exit-code'.
warning: error(s) occurred while switching to the new configuration

I’m at a loss here as to how to proceed so would welcome any advice from other users.

Thanks.

Solved.

Two issues:

  1. location should be
"${pkgs.librespot}/bin/librespot";
  1. needed to enable avahi
  services.avahi = {
    enable = true;
    openFirewall = true;
    reflector = true;
    publish = {
      enable = true;
      userServices = true;
    };
  };