add: desktop xdg integration
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
then "lightdm"
|
||||
else "none";
|
||||
in {
|
||||
imports = [./xdg.nix];
|
||||
|
||||
options.desktop = {
|
||||
displayManager = lib.mkOption {
|
||||
type = lib.types.enum ["auto" "none" "gdm" "lightdm" "ly"];
|
||||
@@ -141,6 +143,11 @@ in {
|
||||
enable = true;
|
||||
wrapperFeatures.gtk = true;
|
||||
extraPackages = cfg.sway.extraPackages;
|
||||
extraSessionCommands = ''
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
export XDG_SESSION_DESKTOP=sway
|
||||
export NIXOS_OZONE_WL=1
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.desktop;
|
||||
needsGtkPortal = cfg.xfce.enable || cfg.hyprland.enable;
|
||||
usesPortal = cfg.gnome.enable || cfg.xfce.enable || cfg.sway.enable || cfg.hyprland.enable;
|
||||
in {
|
||||
config = lib.mkMerge [
|
||||
# GNOME and Sway configure their own portals in NixOS. XFCE needs a
|
||||
# portal; Hyprland benefits from GTK as a fallback to its native one.
|
||||
(lib.mkIf needsGtkPortal {
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
extraPortals = [pkgs.xdg-desktop-portal-gtk];
|
||||
};
|
||||
})
|
||||
|
||||
(lib.mkIf (cfg.sway.enable || needsGtkPortal) {
|
||||
xdg.portal.config.common.default = ["gtk"];
|
||||
})
|
||||
|
||||
(lib.mkIf (usesPortal && config.services.gnome.gnome-keyring.enable) {
|
||||
xdg.portal.config.common."org.freedesktop.impl.portal.Secret" = ["gnome-keyring"];
|
||||
})
|
||||
|
||||
(lib.mkIf (cfg.sway.enable && config.services.gnome.gnome-keyring.enable) {
|
||||
xdg.portal.config.sway."org.freedesktop.impl.portal.Secret" = ["gnome-keyring"];
|
||||
})
|
||||
|
||||
# A per-desktop config takes precedence over Hyprland's packaged config,
|
||||
# so include its native portal whenever adding a Secret preference.
|
||||
(lib.mkIf (cfg.hyprland.enable && config.services.gnome.gnome-keyring.enable) {
|
||||
xdg.portal.config.hyprland = {
|
||||
default = ["hyprland" "gtk"];
|
||||
"org.freedesktop.impl.portal.Secret" = ["gnome-keyring"];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user