Xdg-desktop-portal-gtk.desktop collision

I’m a NixOS (very) newbie. I’ve enabled flakes and home manager following the ‘NixOs & Flakes Book’.
I’m trying to enable Sway system-wide rather than in home manager following the
wiki topic . (I originally tried the home-manager method first,
but the Sway session did not show up in the gdm greeter, and I gave up on that and thought I would
try the other method, backing out the changes for sway in home.nix.)

I get the following collision error:

[dlkrejsa@squirrel:/etc/nixos]$ sudo nixos-rebuild switch
building the system configuration...
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
[2 copied (150.9 MiB), 24.5 MiB DL] downloading 'https://github.com/yusdacra/nix-cargo-integration/archive/ed27173cd1b223f598343ea3c15aacb1d140feac.tar.gz'
error: builder for '/nix/store/c4kqnv2fwnsgh6hl6jgc13732f729w98-xdg-portals.drv' failed with exit code 255;
       last 1 log lines:
       > error: collision between `/nix/store/ihzzkps46yh0npxqbic4i1p1zk96h1nd-xdg-desktop-portal-gtk-1.14.1/share/applications/xdg-desktop-portal-gtk.desktop' and `/nix/store/f74fx3mm8bwcphr5p6cqyslvlql96p3j-xdg-desktop-portal-gtk-1.14.1/share/applications/xdg-desktop-portal-gtk.desktop'
       For full logs, run 'nix log /nix/store/c4kqnv2fwnsgh6hl6jgc13732f729w98-xdg-portals.drv'.
error: 1 dependencies of derivation '/nix/store/6y4v0dyrzy6y4d4phn7v10p23qismyj6-etc-pam-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/0iysns8m1cxlmz6750qhs9xal9bjxkar-set-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/0yq9df3lkh5yhgsf4nnwk5n00bzsnw45-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/n5q92d41ig3253wdajp3c6xizgdhcpgh-nixos-system-squirrel-23.11.20231104.85f1ba3.drv' failed to build

Here are possibly relevant bits of my configuration.nix:

  services.dbus.enable = true;
  xdg.portal = {
    enable = true;
    wlr.enable = true;
    # gtk portal needed to make gtk apps happy
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
  };

  programs.sway = {
    enable = true;
    wrapperFeatures.gtk = true;
  };

Note, my configuration.nix also contains the ‘dbus-sway-environment’ and ‘configure-gtk’ hacks
shown in the wiki Sway topic.

Any advice about what is going wrong and how to get past this would be appreciated.
Thanks!

Do you perhaps have Pantheon, Budgie, Cinnamon, GNOME or Deepin also enabled? Those already install xdg-desktop-portal-gtk overridden to not contain some portals provided by those respective desktop environments.

Hi,
Yes, I have GNOME already installed (from the graphical installer).
What should I do to be able to use both GNOME and Sway sessions?
Should I just try removing the xdg.portal.extraPortals definition from
my configuration.nix?
Thanks for your help!

I just tried commenting out the

    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];

line from my configuration.nix. That allowed the nixos-rebuild switch command
to go through successfully. However, no ‘Sway’ session appeared in the gdm greeter.
But this is progress, anyhow…

Adding

services.xserver.displayManager.sessionPackages = [ pkgs.sway ];

to configuration.nix, running ‘sudo nixos-rebuild switch’ and rebooting, sway now appears as a choice in the gdm greeter.
Thanks very much for the hints!

That should be enabled out of the box by the sway module:

Defining it again explicitly with pkgs.sway might mean the wrapper features will not work.

Sorry for the late reply. I removed the

services.xserver.displayManager.sessionPackages = [ pkgs.sway ];

line from configuration.nix, and sway still appears in the gdm greeter. The only problem I’m still running into is that programs like firefox or evince take a long time (20 to 30 seconds) to start. But that’s a topic for another thread. Thanks!