{ host, pkgs, inputs, ... }:
let
  vars = import ../../hosts/${host}/variables.nix;
  desktopEnvironment = vars.desktopEnvironment or "niri";
in
{
  programs.niri = {
    enable = desktopEnvironment == "niri";
    package = inputs.niri.packages.${pkgs.system}.niri-stable;
  };

  environment.systemPackages = with pkgs; [
    xwayland
    xdg-utils
  ];

  xdg.portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-gtk
    ] ++ (if desktopEnvironment == "niri" then [
      xdg-desktop-portal-gnome
    ] else []);

    config = if desktopEnvironment == "niri" then {
      common.default = "*";
      niri.default = [ "gnome" "gtk" ];
    } else {};
  };

  security.polkit.enable = true;
}
