1

Modules: Add desktopportal module

This commit is contained in:
2025-07-08 20:14:20 +02:00
parent 02bf4eb02e
commit df41b0a572
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,57 @@
{
config,
lib,
mylib,
pkgs,
...
}: let
inherit (config.modules) desktopportal;
in {
options.modules.desktopportal = import ./options.nix {inherit lib mylib;};
config = lib.mkIf desktopportal.enable {
xdg = {
portal = {
enable = true;
xdgOpenUsePortal = true;
wlr.enable = false;
# TODO: Replace lib.optional(s) throughout the config with mkMerge
config = lib.mkMerge [
{
# https://discourse.nixos.org/t/clicked-links-in-desktop-apps-not-opening-browers/29114/26
common.default = ["*"];
}
(lib.mkIf desktopportal.termfilechooser.enable {
common."org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"];
})
(lib.mkIf desktopportal.hyprland.enable {
hyprland.default = ["hyprland"];
})
(lib.mkIf
(desktopportal.hyprland.enable && desktopportal.termfilechooser.enable) {
hyprland."org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"];
})
];
extraPortals = with pkgs;
lib.mkMerge [
[
xdg-desktop-portal-gtk # Fallback
]
(lib.mkIf desktopportal.hyprland.enable [
xdg-desktop-portal-hyprland
])
(lib.mkIf desktopportal.termfilechooser.enable [
xdg-desktop-portal-termfilechooser # Filechooser using yazi
])
];
};
};
};
}

View File

@ -0,0 +1,9 @@
{
lib,
mylib,
...
}: {
enable = lib.mkEnableOption "Enable XDG desktop portals";
termfilechooser.enable = lib.mkEnableOption "Enable xdg-desktop-portal-termfilechooser";
hyprland.enable = lib.mkEnableOption "Configure portals for Hyprland";
}