Modules: Add desktopportal module
This commit is contained in:
57
system/modules/desktopportal/default.nix
Normal file
57
system/modules/desktopportal/default.nix
Normal 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
|
||||
])
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
9
system/modules/desktopportal/options.nix
Normal file
9
system/modules/desktopportal/options.nix
Normal 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";
|
||||
}
|
Reference in New Issue
Block a user