Setting `xdg-open` default apps

Hey! With sudo works right. It could mean I need to set the apps at user level but not in configuration.nix.

I tried with ~/.config/mimeapps.list:

[Default Aplications]
x-scheme-handler/http = librewolf.desktop
x-scheme-handler/https = librewolf.desktop
x-scheme-handler/about = librewolf.desktop
x-scheme-handler/unknown = librewolf.desktop
image/png = pix.desktop
image/jpg = pix.desktop
image/webp = pix.desktop
image/jpeg = pix.desktop
image/svg = pix.desktop

But I got “No available applications”. How I can set the default apps at user level?

Usually like that, but you can also use the xdg.mimeApps.* and xdg.mime.enable options in home-manager to handle them declaratively (and also immutable, which is useful here because some apps like to mess with your mimeapps.list)

Also I think it doesn’t help if you set xdg.portal.xdgOpenUsePortal, because then you bypass the actual xdg-open script. Also, you shouldn’t have both the GTK and KDE portals available, they are known to collide.

(post deleted by author)

Yay! Home Manager fix it.

In my case I prefer set it in configuration.nix:


  home-manager.users.nix = {

   home.stateVersion = "25.11";  

    xdg = { 
   
     mime.enable = true;

     mimeApps = {

      enable = true;
 
      defaultApplications = {

        "x-scheme-handler/http" = ["librewolf.desktop"];
        "x-scheme-handler/https" = ["librewolf.desktop"];
        "x-scheme-handler/about" = ["librewolf.desktop"];
        "x-scheme-handler/unknown" = ["librewolf.desktop"];
        "images/png" = ["pix.desktop"];
        "images/jpg" = ["pix.desktop"];
        "images/webp" = ["pix.desktop"];
        "images/svg+xml" = ["pix.desktop"];
        "images/jpeg" = ["pix.desktop"];

       };

     }; 

    };

   };

Thank you guys! Specially dtomvan