Change grub resolution

I have a Thinkpad p14s G2 (AMD) that has a 4k screen.

I tried to change the grub resolution like this:

  boot.loader.grub = {
    extraConfig = ''
      GRUB_CMDLINE_LINUX="amdgpu.backlight=0"
      GRUB_GFXMODE=1024x768x32
      GRUB_GFXPAYLOAD_LINUX=keep
      GRUB_TERMINAL_OUTPUT="gfxterm"
    '';
  };

But it has no effect. I am missing something?

I have this in one of my configuarations:

  boot.loader = {
    grub = {
      enable = true;
      efiSupport = true;
      device = "nodev";
      fsIdentifier = "label";
      efiInstallAsRemovable = true;
      gfxmodeEfi = "3440x1440";
      font = "${pkgs.hack-font}/share/fonts/hack/Hack-Regular.ttf";
      fontSize = 36;
    };
  };

Be sure to run sudo nixos-rebuild switch after making your changes.