xdg-desktop-portal(s): dont install globally

This commit is contained in:
Colin 2024-02-12 01:16:17 +00:00
parent 87050a0500
commit db7a414030
5 changed files with 57 additions and 15 deletions

View File

@ -91,6 +91,8 @@
./wireshark.nix
./wob.nix
./xarchiver.nix
./xdg-desktop-portal.nix
./xdg-desktop-portal-gtk.nix
./xdg-utils.nix
./zeal.nix
./zecwallet-lite.nix

View File

@ -0,0 +1,24 @@
{ config, ... }:
let
cfg = config.sane.programs.xdg-desktop-portal-gtk;
in
{
sane.programs.xdg-desktop-portal-gtk = {
# the portal handles things like file/app open requests, so it needs access to everything
# any installed app might require.
sandbox.enable = false;
services.xdg-desktop-portal-gtk = {
# xdg-desktop-portal-gtk provides the service/dbus file, but doesn't link the right `wantedBy`
# so have to recreate it here :(
description = "Portal service (GTK/GNOME implementation)";
wantedBy = [ "xdg-desktop-portal.service" ];
before = [ "xdg-desktop-portal.service" ];
serviceConfig = {
ExecStart = "${cfg.package}/libexec/xdg-desktop-portal-gtk";
Type = "dbus";
BusName = "org.freedesktop.impl.portal.desktop.gtk";
};
};
};
}

View File

@ -0,0 +1,26 @@
{ config, lib, ... }:
let
cfg = config.sane.programs.xdg-desktop-portal;
in
{
sane.programs.xdg-desktop-portal = {
services.xdg-desktop-portal = {
description = "Portal service";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart="${cfg.package}/libexec/xdg-desktop-portal";
Type = "dbus";
BusName = "org.freedesktop.portal.Desktop";
};
# xdg-desktop-portal needs to know where to find xdg-desktop-portal-gtk, etc, for some reason (???).
# otherwise, it won't expose stuff like the OpenURI endpoint, even if a suitable AppChooser is available on dbus.
environment.XDG_DESKTOP_PORTAL_DIR = "/etc/profiles/per-user/%u/share/xdg-desktop-portal/portals";
};
};
environment.pathsToLink = lib.mkIf cfg.enabled [
"/share/xdg-desktop-portal/portals"
];
}

View File

@ -179,6 +179,9 @@ in
"wdisplays" # like xrandr
"wl-clipboard"
"wob" # render volume changes on-screen
"xdg-desktop-portal"
"xdg-desktop-portal-gtk"
"xdg-desktop-portal-wlr"
"xdg-terminal-exec" # used by sway config
];
@ -336,10 +339,6 @@ in
# # })
# ];
# portals: i manage them myself
environment.systemPackages = [ pkgs.xdg-desktop-portal-gtk ];
services.dbus.packages = [ pkgs.xdg-desktop-portal-gtk ];
environment.etc."xdg/xdg-desktop-portal/sway-portals.conf".text = ''
[preferred]
default=wlr;gtk

View File

@ -1,16 +1,7 @@
{ lib, pkgs, ... }:
# TODO: fold into sway
{ ... }:
{
# otherwise /share/applications gets linked into the system and complicates things (sandboxing)
xdg.portal.enable = false;
xdg.menus.enable = false; #< links /share/applications, and a bunch of other empty (i.e. unused) dirs
environment.pathsToLink = [
"/share/xdg-desktop-portal/portals"
];
# TODO: probably not needed?
environment.sessionVariables.XDG_DESKTOP_PORTAL_DIR = "/run/current-system/sw/share/xdg-desktop-portal/portals";
# TODO: use `sane.programs`, and move into gui package sets so this doesn't appear on servo
environment.systemPackages = [ pkgs.xdg-desktop-portal ];
services.dbus.packages = [ pkgs.xdg-desktop-portal ];
}