{
  mainUser,
  inputs,
  getFlakePkg',
  lib,
  config,
  ...
}:
let
  niri = (getFlakePkg' inputs.niri "niri-unstable");
  xwayland-satellite = (getFlakePkg' inputs.niri "xwayland-satellite-unstable");
  inherit (config) rice;
in
{
  imports = [
    inputs.niri.nixosModules.niri
    inputs.niri-tag.nixosModules.niri-tag
  ];
  user.desktops.niri = {
    enable = true;
    config =
      let
        template = builtins.readFile ./niri.kdl;
        baseConfig =
          with rice;
          lib.replaceStrings
            [
              "%CURSOR%"
              "%ROUNDING%"
              "%GAPS%"
              "%BORDER%"
              "%ACTIVE%"
              "%INACTIVE%"
              "%SATELLITE%"
            ]
            [
              cursor.name
              (toString borders.rounding)
              (toString borders.gaps)
              (toString borders.thickness)
              palette.shortHex.bright.yellow
              palette.shortHex.normal.yellow
              (lib.getExe xwayland-satellite)
            ]
            template;
      in
      baseConfig;
  };
  user.packages = [
    niri
    xwayland-satellite
  ];
  services.greetd = {
    enable = true;
    restart = false;
    settings =
      let
        session = {
          command = "niri-session";
          user = "${mainUser}";
        };
      in
      {
        default_session = session;
        initial_session = session;
      };
  };
  programs.niri = {
    enable = true;
    package = niri;
  };
  services.niri-tag.enable = true;

}
