Spotify not working

Hi guys!

I love NixOS, but have some troubles with running Spotify on it. I’ve declared it in my home-manager:

packages = [
      pkgs.spotify
    ];

When I run it and click “log in” button, first nothing happens, but when I click it the second time it says “Go to your browser to log in”, which it should do, but no browser window pops out…

Can anyone of you guys help me out?

With regards, Miro

spotify is the one package i instead use the flatpak version of, due to this exact issue

Hmmm, that’s strange… When I used Fedora it was the flatpak version that didn’t work. I’ll install it today.

Have you tried this yet?

  xdg.portal = {
    enable = true;
    xdgOpenUsePortal = true; 
  };
1 Like

I don’t know what that is, could you please provide alink to documentation about that? I did not find any…

https://search.nixos.org/options?channel=24.11&from=0&size=50&sort=relevance&type=packages&query=xdg.portal

Thank you!

I am trying to implement it into my configuration file, but am having some problems, this is by xdg block:

  xdg.portal = {
    enable = true;
    xdgOpenUsePortal = true;
    configPackages = with pkgs; [
      pkgs.xdg-desktop-portal-kde
    ];
  };

When I try to rebuild I get this error:

[root@dell-3:~]# nixos-rebuild switch --flake /etc/nixos#default
building the system configuration...
error:
       … while calling the 'head' builtin
         at /nix/store/8fwsiv0hd7nw1brkvka0jf1frk3m7qkr-source/lib/attrsets.nix:1574:11:
         1573|         || pred here (elemAt values 1) (head values) then
         1574|           head values
             |           ^
         1575|         else

       … while evaluating the attribute 'value'
         at /nix/store/8fwsiv0hd7nw1brkvka0jf1frk3m7qkr-source/lib/modules.nix:846:9:
          845|     in warnDeprecation opt //
          846|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          847|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/8fwsiv0hd7nw1brkvka0jf1frk3m7qkr-source/nixos/modules/system/activation/top-level.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error:
       Failed assertions:
       - Setting xdg.portal.enable to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.

[root@dell-3:~]# 

You need to add a portal implementation as the error message tells you.

Okay, but how? Doesn’t this implement it?

    configPackages = with pkgs; [
      pkgs.xdg-desktop-portal-kde
    ];

You need to set xdg.portal.extraPortals, just like the error message tells you to.

Okay, thank you, when I do this:

    enable = true;
    xdgOpenUsePortal = true;
    extraPortals = with pkgs; [
      pkgs.xdg-desktop-portal-kde
    ];
  };

I get this warning:

building the system configuration...
evaluation warning: xdg-desktop-portal 1.17 reworked how portal implementations are loaded, you
                    should either set `xdg.portal.config` or `xdg.portal.configPackages`
                    to specify which portal backend to use for the requested interface.

                    https://github.com/flatpak/xdg-desktop-portal/blob/37a6f7c8b8e08b9861f05e172cd4e0d07a832c4d/doc/portals.conf.rst.in

                    If you simply want to keep the behaviour in < 1.17, which uses the first
                    portal implementation found in lexicographical order, use the following:

                    xdg.portal.config.common.default = "*";

That is why I was trying to use configPackages. Is it possible?

Oh, my info and the error message are outdated then. Please do what this new error message instructs you to do instead.

Well, when I do what they ask I get an error, maybe I have to file it as a bug?

That’d be best at this point.

I was having a similar problem with the spotify package (no window popping out). Temporarily setting my default browser to firefox fixed? this issue for me for now. FYI i was using zen browser in flatpak before this

Hi, I temporarily installed Firefox from Flatpak and Spotify using nix-shell. After running Spotify and clicking “Log in” I get this error:

[jeansib@dell-1:~]$ export NIXPKGS_ALLOW_UNFREE=1

[jeansib@dell-1:~]$ nix-shell -p spotify

[nix-shell:~]$ spotify
/run/current-system/sw/bin/flatpak: /nix/store/g365mj7mxp4w5ig63fhwk0c9x0ji27vb-curl-8.11.0/lib/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by /run/current-system/sw/bin/flatpak)
/run/current-system/sw/bin/flatpak: /nix/store/g365mj7mxp4w5ig63fhwk0c9x0ji27vb-curl-8.11.0/lib/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by /nix/store/m7skd61h5dn0sj6jd148rxmpnva6fswf-appstream-1.0.3/lib/libappstream.so.5)
/run/current-system/sw/bin/flatpak: /nix/store/g365mj7mxp4w5ig63fhwk0c9x0ji27vb-curl-8.11.0/lib/libcurl.so.4: version `CURL_OPENSSL_4' not found (required by /nix/store/swncwmgsqqk7sxz21q96szgza3dd1i0x-ostree-2024.8/lib/libostree-1.so.1)

[nix-shell:~]$ 

Note that after typing “spotify” there is no output until I click the “Log in” button.

It appears to be attempting to run the flatpak version but that fails somehow? Not sure why actually. Does it work outside a Nix shell?

It shouldn’t be doing that in the first place though as the spotify package’s binary should take precedence. Could you show $PATH?

Okay, with Firefox installed as a nix package it works. But as Flatpak Spotify seems to be working I think I’ll stick to that. Thank you for your help!

1 Like