Configuring xdg-desktop-portal with Home Manager on Ubuntu (Hyprland via nixGL)

Hello everyone,

Nix noob here, I’m running into issues getting xdg-desktop-portal working via Home Manager on Ubuntu (I’m locked to Ubuntu due to work computer). I’m using Home Manager to set up Hyprland through nixGL, and everything else is working well so far, except screen sharing via xdg-desktop-portal. I’d greatly appreciate any guidance on how to properly configure this.


1. Environment & Goal

  • OS: Ubuntu (version ≈ 24.04 LTS)

  • Window manager: Hyprland via home-manager and nixGL

  • Goal: Enable screen sharing (and other portal functionality) by installing and configuring xdg-desktop-portal-hyprland (or an appropriate portal backend) entirely through my Home Manager setup.

  • Gist that I initially used to set up hyprland on ubuntu: AntonFriberg gist


2. Background & References

I believe it’s possible because of:

I’d like to follow the “Home Manager way” instead of manually hacking scripts, so that all my config remains declarative and reproducible.


3. What I Have Tried

  1. Added xdg.portal.enable = true; and included xdg-desktop-portal-hyprland / xdg-desktop-portal-gtk in extraPortals.
    My xdg.portal block currently looks like this:

    xdg.portal = {
      enable = true;
      extraPortals = with pkgs; [
        xdg-desktop-portal-hyprland  
        # (config.lib.nixGL.wrap xdg-desktop-portal-hyprland)
        # xdg-desktop-portal-wlr
        xdg-desktop-portal-gtk
      ];
       configPackages = [ /* pkgs.hyprland */ ];
       config = {
         hyprland.default = [ "hyprland" "gtk" ];
       };
    };
    

    However, I get the following collision error:

    error: collision between
    `/nix/store/kryxh2frhdr8kv97ximfnn3gl9rw040w-xdg-desktop-portal-hyprland-1.3.9/bin/hyprland-share-picker`
    and
    `/nix/store/kzc3zkpg19s9rz681sa90ajkc08c3cqn-xdg-desktop-portal-hyprland-1.3.9/bin/hyprland-share-picker`
    

    (I suspect this is caused by the nixGL wrapper wrapping Hyprland itself?)
    If i do not specify the package i do not get it to work either, not even using wlr i get it to work. So i must be doing something wrong, but i can not figure it out.

  2. Tried alternative portal backends
    I’ve experimented with only xdg-desktop-portal-wlr or only xdg-desktop-portal-gtk, but neither seems to provide the proper Hyprland integration for screen sharing. In particular, Hyprland requires the specialized xdg-desktop-portal-hyprland binary to handle the share picker.

  3. Checked the Hyprland portal repository’s caution
    The hyprwm/xdg-desktop-portal-hyprland README mentions a caution about not using the portal directly without wrapping or additional environment variables. I’m not sure how to translate that advice into a Home Manager expression.


4. Links to My Configs


5. Questions & Request for Help

  1. Recommended Expression:
    What is the correct way to declare and enable xdg-desktop-portal-hyprland entirely via Home Manager? Is there an example snippet that I can adapt?

  2. Resolving the Collision:
    How do I avoid the “collision” between two identical hyprland-share-picker binaries in the store? Should I:

    • Wrap the portal package with nixGL.wrap?
    • Mask one of the binaries using config.xdg.porters.blacklist or a similar Home Manager option?
    • Use a different attribute name or override?
  3. Fallback / Alternative:
    If xdg-desktop-portal-hyprland is not feasible via Home Manager, is there a reliable way to configure Hyprland’s portal manually in conjunction with Home Manager—without losing the reproducibility and “single source of truth” benefits of Home Manager?

I’m grateful for any pointers, example configs, or patch suggestions. Thank you in advance!


Thanks again,
Drakkir