Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/wayland: add gtk portal to all applicable compositors #342646

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

Frontear
Copy link
Member

@Frontear Frontear commented Sep 17, 2024

Description of changes

Most standalone wayland compositors lack a sufficient xdg-desktop-portal implementation. More often than not, their portal contains only screen capture protocols but completely lacks file picker functionality (see: archwiki/xdg_desktop_portal).

Most of the nixos modules used lib.mkDefault [ "wlr" "gtk" ]; as the solution to this, but never actually provided the gtk portal. This PR adds the gtk portal as an entry in the common wayland-session.nix file, enabling support for all compatible compositors.

PS: if this constitutes a release change let me know !

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@JohnRTitor
Copy link
Contributor

JohnRTitor commented Sep 30, 2024

Perhaps this should be added to the generic Wayland module, @wineee @fufexan thoughts?

@JohnRTitor JohnRTitor changed the title nixos/modules: add xdg-desktop-portal-gtk to sway nixos/sway: add xdg-desktop-portal-gtk Sep 30, 2024
@wineee
Copy link
Member

wineee commented Sep 30, 2024

If enableWlrPortal is true, setting xdg.portal.extraPortals may conflict

xdg.portal.wlr.enable = enableWlrPortal;

xdg.portal = {
enable = true;
extraPortals = [ package ];
};

@fufexan
Copy link
Contributor

fufexan commented Sep 30, 2024

@JohnRTitor I agree, it would be best to add xdpg for all standalone compositors, which are less likely to come with a complete portal implementation.

@Frontear
Copy link
Member Author

Frontear commented Sep 30, 2024

If enableWlrPortal is true, setting xdg.portal.extraPortals may conflict

xdg.portal.wlr.enable = enableWlrPortal;

xdg.portal = {
enable = true;
extraPortals = [ package ];
};

It won't conflict because list types merge. They will just merge with one another.

@Frontear
Copy link
Member Author

@JohnRTitor I agree, it would be best to add xdpg for all standalone compositors, which are less likely to come with a complete portal implementation.

I don't mind going about implementing this, it definitely makes a lot more sense imo.

@Frontear
Copy link
Member Author

Frontear commented Sep 30, 2024

I've rebased and included the new push. Let me know if this is acceptable and if it is I will remove the sway commit. I've only left it at the moment in case changing my PR isn't desirable.

All modules tested as below:

let
  # file exists in root of nixpkgs repo
  self = builtins.getFlake (toString ./.);

  config = {
    programs = {
      # each one tested one at a time, this is here for completion sake
      sway.enable = true;
      wayfire.enable = true;
      wayland.miracle-wm.enable = true;
      cardboard.enable = true;
      river.enable = true;
      hyprland.enable = true;
      labwc.enable = true;
    };
  };
in (self.lib.nixosSystem {
  modules = [
    ({
      nixpkgs.hostPlatform = "x86_64-linux";
      nixpkgs.config.allowUnfree = true;
      nixpkgs.config.allowBroken = true; # needed for cardboard package

      fileSystems."/".device = "nodev";
      boot.loader.grub.devices = [ "nodev" ];
    })
  ];
}).config.xdg.portal.extraPortals

@Frontear Frontear changed the title nixos/sway: add xdg-desktop-portal-gtk nixos/wayland: add gtk portal to all applicable compositors Sep 30, 2024
Copy link
Contributor

@fufexan fufexan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, you can remove the sway-specific commit.

@Frontear
Copy link
Member Author

Done, ready for review and merge.

@JohnRTitor JohnRTitor merged commit afab97c into NixOS:master Sep 30, 2024
23 checks passed
@Frontear Frontear deleted the add-gtk-portal-sway branch September 30, 2024 20:28
@gallexme
Copy link

gallexme commented Oct 2, 2024

having both gnome + hyprland enabled causes

outputs.nixosConfigurations.moot-pc.config.xdg.portal.extraPortals
[
  «derivation /nix/store/v04z3wqji8na8vdb749glh944jwcw1s7-xdg-desktop-portal-gnome-46.2.drv»
  «derivation /nix/store/jiv5f9bcv5qgchr8k3ykppwvlb9r10ix-xdg-desktop-portal-gtk-1.15.1.drv»
  «derivation /nix/store/x5pbssd6a9dxn2yj3m8vf3nhgyfjn9z3-gnome-keyring-46.2.drv»
  «derivation /nix/store/4kcmjgvs32lshmr57fgmrjkwy8yx1hin-xdg-desktop-portal-hyprland-1.3.6+date=2024-09-28_7e500e6.drv»
  «derivation /nix/store/q3diw8lfynliqwh3ji68fkh05vkdf40r-xdg-desktop-portal-gtk-1.15.1.drv»
]

and thereby breaking current builds

error: builder for '/nix/store/0winblydr01ml98jiivsp6izbmvhi2ds-user-units.drv' failed with exit code 1;
       last 1 log lines:
       > ln: failed to create symbolic link '/nix/store/f7i38bxf8fwwc111sh3c129p8l1z53j4-user-units/xdg-desktop-portal-gtk.service': File exists

perhaps it should make sure that it won't add existing portals

@JohnRTitor
Copy link
Contributor

JohnRTitor commented Oct 2, 2024

Tracked in #345733, the root cause here is GNOME uses a different build of gtk portal, causing it to conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants