{ self, inputs, ... }:
{
  flake.nixosModules.niri = { pkgs, lib, ... }: {
    programs.niri = {
      enable = true;
      package = self.packages.${pkgs.stdenv.hostPlatform.system}.myNiri;
    };
    environment = {
      systemPackages = with pkgs; [
        wofi
        firefox
      ];
    };
  };

  perSystem = { pkgs, lib, self', ...}:
  let
    noctaliaPath = lib.getExe self'.packages.myNoctalia
  in {
    packages.myNiri = inputs.wrapper-modules.wrappers.niri.wrap {
      inherit pkgs;
      settings = {
        spawn-at-startup = [
          noctaliaPath
        ];
        screenshot-path = "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png";
        prefer-no-csd = {};
        input = {
          focus-follows-mouse = {};
          keyboard = {
            xkb.layout = "fr";
            numlock = {};
          };
          touchpad = {
            tap = {};
            natural-scroll = {};
          };
        };

        layout = {
          gaps = 5;
        };

        binds = {
          "Mod+Return".spawn-sh = lib.getExe pkgs.kitty;
          "Mod+Space".spawn = [ "wofi" "--show" "drun"];
          "Mod+Shift+R".spawn = [ "zen" ];
          "Mod".spawn-sh = "${noctaliaPath} ipc call controlCenter toggle";
          "Mod+L".spawn-sh = "${noctaliaPath} ipc call sessionMenu lock";

          # Default binds
          # Fullscreen managment
          "Mod+F".maximize-column = {};
          "Mod+Shift+F".fullscreen-window = {};
          "Mod+Ctrl+F".maximize-window-to-edges = {}; # Same effect as double clicking the titlebar
          # Floating
          "Mod+V".toggle-window-floating = {};
          "Mod+Shift+V".switch-focus-between-floating-and-tiling = {};

          # Media managment
          "XF86AudioPlay".spawn-sh = "playerctl play-pause";
          "XF86AudioPause".spawn-sh = "playerctl play-pause";
          "XF86AudioStop".spawn-sh = "playerctl stop";
          "XF86AudioPrev".spawn-sh = "playerctl previous";
          "XF86AudioNext".spawn-sh = "playerctl next";

          # Audio managment
          "XF86AudioRaiseVolume".spawn-sh = "wpctl set-volume -l 1.4 @DEFAULT_SINK@ 5%+";
          "XF86AudioLowerVolume".spawn-sh = "wpctl set-volume -l 1.4 @DEFAULT_SINK@ 5%-";
          "XF86AudioMute".spawn-sh = "wpctl set-mute @DEFAULT_SINK@ toggle";

          # Misc
          "Mod+Shift+L".show-hotkey-overlay = {};
          "Mod+Q".close-window = {};
          "Mod+O".toggle-overview = {};

          # Window management
          # It uses the arrow keys to navigate
          "Mod+Left".focus-column-left = {};
          "Mod+Down".focus-window-or-workspace-down = {};
          "Mod+Up".focus-window-or-workspace-up = {};
          "Mod+Right".focus-column-right = {};
          # Uses the arrow key with a modifier to move windows
          "Mod+Ctrl+Left".move-column-left = {};
          "Mod+Ctrl+Down".move-window-down-or-to-workspace-down = {};
          "Mod+Ctrl+Up".move-window-up-or-to-workspace-up = {};
          "Mod+Ctrl+Right".move-column-right = {};
          # Uses the Shift modifier
          "Mod+Shift+Left".focus-monitor-left = {};
          "Mod+Shift+Down".focus-monitor-down = {};
          "Mod+Shift+Up".focus-monitor-up = {};
          "Mod+Shift+Right".focus-monitor-right = {};
          # Uses the <home/end> keys to focus extremumns
          "Mod+Home".focus-column-first = {};
          "Mod+End".focus-column-last = {};
          "Mod+Ctrl+Home".move-column-to-first = {};
          "Mod+Ctrl+End".move-column-to-last = {};

          # Sceenshots
          "Mod+Print".screenshot = {};
          "Mod+Ctrl+Print".screenshot-screen = {};
          "Mod+Alt+Print".screenshot-window = {};

          # Monitor power
          "Mod+Shift+P".power-off-monitors = {};
        };

        xwayland-satellite.path = lib.getExe pkgs.xwayland-satellite;
      };
    };
  };
}
