#
# Fixes mattermost's wrapper so one can log in.
#
# vim: et:ts=2:sw=2:
#
{ ... }:
let
  overlay = final': prev': {
    mattermost-desktop = prev'.mattermost-desktop.overrideAttrs (
      final: prev: {

        postInstall = ''
          makeWrapper '${prev'.lib.getExe prev'.electron_28}' $out/bin/${prev.pname} \
            --set-default ELECTRON_IS_DEV 0 \
            --add-flags $out/share/${prev.pname}/app.asar \
            --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
        '';

      }
    );
  };
in
{
  nixpkgs.overlays = [ overlay ];
}
