Wayland and xwayland application

Hello,

I’m trying to open non-wayland application from hyprland but I can’t make it work. There’s two thing :

  • I can’t make polkit work, but that’s not the most important
  • I get an error even with sudo, Authorization required, but no authorization protocol specified

Some application works, like opera, but some, like gparted, don’t.

I remembered that I had this issue on Arch but I don’t remember how I fixed it, but anyway Nixos works differently with its config file.

What can be the error ? My full config is here master branch, but here’s the most important part :
configuration.nix

{
  pkgs,
  inputs,
  ...
}: {


  config = {
    nix.settings = {
      substituters = ["https://hyprland.cachix.org"];
      trusted-public-keys = [
        "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
      ];
    };

    programs.hyprland = {
      enable = true;
      package = inputs.hyprland.packages.${pkgs.system}.hyprland;
      xwayland.enable = true;
      portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
    };

    environment.sessionVariables = {
      WLR_MO_HARDWARE_CURSOR = "1";
      NIXOS_OZONE_WL = "1";
    };

    xdg.portal = {
      enable = true;
      wlr.enable = true;
      extraPortals = with pkgs; [
        xdg-desktop-portal-gtk
      ];
    };

    services = {
      dbus.enable = true; # screen sharing
      xserver = {
        enable = true;
        displayManager = {
          sddm.enable = true;
        };
      };
      devmon.enable = true; # TODO : script wrapper for udisk2, need test
      udisks2.enable = true; # NOTE : daemon lib for mount/umount
      upower.enable = true; # NOTE : lib for power info
      power-profiles-daemon.enable = true; # TODO : choose the power manager
    };
  };
}

{
  config,
  ...
}: {
  # TODO : add dual gpu handling
  config = {
    hardware.opengl.enable = true;
    hardware.graphics.enable = true;

    hardware.nvidia = {
      modesetting.enable = true;

      powerManagement = {
        enable = true;
        # finegrained = true; # add nvidia opti
      };

      # TODO : remove ?
      open = true;

      nvidiaSettings = true;
      package = config.boot.kernelPackages.nvidiaPackages.latest;
    };
  };
}

I already search quite a lot on the web so my config is a mix of everything I found

Hi, did you try to open them with xwayland from the terminal? Using env -u WAYLAND_DISPLAY appname

For gparted, I think you need to run: sudo -E gparted

Oh yes it works, thank you !
Do you know how can I put that option by default ? To be able to use the .desktop for every app like that (once polkit is fixed)

Glad it works. I haven’t tried it but I think this is how you can override desktop entries: Partly overriding a .desktop entry

Sadly I already have that, both in my configuration.nix and home.nix. And from sudo env I can see that this variable is correctly set as sudo

$ env | find NIXOS                                                                                                                          at 14:40:02 
╭───┬──────────────────╮
│ 0 │ NIXOS_OZONE_WL=1 │
╰───┴──────────────────╯
$ sudo env | find NIXOS                                                                                                                     at 14:41:13 
╭───┬──────────────────╮
│ 0 │ NIXOS_OZONE_WL=1 │
╰───┴──────────────────╯

Something weird I saw, if I do the same as regular user directly on the host (without ssh), I get a variable __NIXOS_SET_ENVIRONMENT_DONE=1

No one with a possible answer ? :frowning:

For which app do you have this issue? I tried opera but it opened without issue from my launcher (rofi using NixOS unstable and latest hyprland)