Files
nix-config/modules/nixos/desktop/xdg.nix
T
Ryan Yin 3789a2a282 chore(nixos): guard the nix and xdg-desktop-portal-wlr pins at eval time
WA-023 warns once nixVersions.stable reaches 2.35; WA-046 fails the build
once nixpkgs' xdg-desktop-portal-wlr is no longer the broken 0.8.4, so both
pins get revisited instead of lingering.

Assisted-by: Claude Code (claude-opus-5-5)
2026-11-01 11:55:14 -06:00

90 lines
3.0 KiB
Nix

{
lib,
pkgs,
pkgs-stable,
...
}:
{
xdg.terminal-exec = {
enable = true;
package = pkgs.xdg-terminal-exec;
settings =
let
my_terminal_desktop = [
# NOTE: We have add these packages at user level
"com.mitchellh.ghostty.desktop"
"kitty.desktop"
];
in
{
GNOME = my_terminal_desktop ++ [
"com.raggesilver.BlackBox.desktop"
"org.gnome.Terminal.desktop"
];
niri = my_terminal_desktop;
default = my_terminal_desktop;
};
};
xdg = {
autostart.enable = lib.mkDefault true;
menus.enable = lib.mkDefault true;
mime.enable = lib.mkDefault true;
icons.enable = lib.mkDefault true;
};
xdg.portal = {
enable = true;
config = {
common = {
# Prefer the GTK portal for interfaces it implements.
default = [
"gtk"
"gnome"
];
};
niri."org.freedesktop.impl.portal.ScreenCast" = "wlr";
};
# Sets environment variable NIXOS_XDG_OPEN_USE_PORTAL to 1
# This will make xdg-open use the portal to open programs,
# which resolves bugs involving programs opening inside FHS envs or with unexpected env vars set from wrappers.
# xdg-open is used by almost all programs to open a unknown file/uri
# a terminal emulator as an example, it uses xdg-open as default, but you can also customize this behavior
xdgOpenUsePortal = true;
# ls /run/current-system/sw/share/xdg-desktop-portal/portals/
extraPortals = with pkgs; [
xdg-desktop-portal-gtk # file picker and OpenURI
xdg-desktop-portal-gnome # screenshot and remaining GNOME services
# xdg-desktop-portal-wlr 0.8.4 regresses Zoom; 0.8.2 works with niri.
pkgs-stable.xdg-desktop-portal-wlr
];
};
assertions = [
{
assertion = pkgs.xdg-desktop-portal-wlr.version == "0.8.4";
message = "nixpkgs moved xdg-desktop-portal-wlr past 0.8.4: retest Zoom with it and drop the 0.8.2 pin (WA-046)";
}
];
# The xdg-autostart-generator starts every autostart app (including nixpak
# sandboxes like firefox/telegram) right at graphical-session.target, while
# the portal user services come up around the same time (xdg-desktop-portal-gtk
# is even ordered after graphical-session.target). This template drop-in makes
# every `app-*@autostart.service` wait for the portal stack, so portal-dependent
# features (FileChooser upload/save dialogs, OpenURI) work on first launch
# instead of needing a manual app restart after login.
systemd.user.units."app-@autostart.service" = {
# Template drop-in: applies to every `app-*.desktop` instance generated by
# systemd-xdg-autostart-generator, current and future.
overrideStrategy = "asDropin";
text = ''
[Unit]
After=xdg-desktop-portal.service xdg-desktop-portal-gtk.service xdg-desktop-portal-gnome.service xdg-desktop-portal-wlr.service
Wants=xdg-desktop-portal.service xdg-desktop-portal-gtk.service xdg-desktop-portal-gnome.service xdg-desktop-portal-wlr.service
'';
};
}