{
  config,
  pkgs,
  lib,
  ...
}: let
  cfg = config.alqueva.wms.niri;
in {
  options.alqueva.wms.niri = {
    enable = lib.mkEnableOption "niri";
    package = lib.mkPackageOption pkgs "niri" {};
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [
      cfg.package
    ];

    xdg.portal = {
      config = {
        niri = {
          "org.freedesktop.impl.portal.Secret" = [
            "gnome-keyring"
          ];
          default = [
            "gnome"
            "gtk"
          ];
        };
      };
      configPackages = [cfg.package];
      extraPortals = [
        pkgs.xdg-desktop-portal-gnome
        pkgs.xdg-desktop-portal-gtk
      ];
    };

    services = {
      displayManager.sessionPackages = [cfg.package];
      gnome.gnome-keyring.enable = true;
    };

    alqueva.support.wayland = true;
  };
}
