1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-19 00:09:48 +01:00
home-manager/tests/modules/misc/xdg/portal.nix
Gabriel Fontes 1c2acec999
xdg-portal: align with NixOS module
Nixpkgs has recently made a few major changes to its
xdg-desktop-portal package, which silently breaks our module here:

- The NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR variable patch has been
  removed (in favor of putting portal configurations in /etc or
  XDG_CONFIG_HOME).

- A new variable, NIX_XDG_DESKTOP_PORTAL_DIR, was introduced in a
  patch to avoid setting XDG_DESKTOP_PORTAL_DIR (which also affected
  portal configuration reading, not only portal definitions)

I updated our module to match the changes, but this breakage also made
me revisit this module and look into some improvements.

Long story short, I think it's worth it to make it more similar to the
NixOS one, as it will make behavior more predictable and consistent.
The main change is relying on the upstream linked systemd
unit (instead of using systemd.user.services), and setting the
environment variables globally instead of scoping it to the unit, as
it's a very global thing anyway.
2024-03-20 23:41:55 +01:00

27 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
lib.mkIf config.test.enableBig {
xdg.portal = {
enable = true;
extraPortals =
[ pkgs.xdg-desktop-portal-hyprland pkgs.xdg-desktop-portal-wlr ];
configPackages = [ pkgs.hyprland ];
config = { sway.default = [ "wlr" "gtk" ]; };
};
nmt.script = ''
assertFileExists home-path/share/systemd/user/xdg-desktop-portal.service
assertFileExists home-path/share/systemd/user/xdg-desktop-portal-wlr.service
assertFileExists home-path/share/systemd/user/xdg-desktop-portal-hyprland.service
assertFileContent home-path/share/xdg-desktop-portal/portals/hyprland.portal \
${pkgs.xdg-desktop-portal-hyprland}/share/xdg-desktop-portal/portals/hyprland.portal
assertFileContent home-path/share/xdg-desktop-portal/portals/wlr.portal \
${pkgs.xdg-desktop-portal-wlr}/share/xdg-desktop-portal/portals/wlr.portal
assertFileContent home-path/share/xdg-desktop-portal/hyprland-portals.conf \
${pkgs.hyprland}/share/xdg-desktop-portal/hyprland-portals.conf
assertFileContent home-files/.config/xdg-desktop-portal/sway-portals.conf \
${./sway-portals-expected.conf}
'';
}