NVIDIA: Difference between revisions

Joshbuker (talk | contribs)
Add the fix that solved both graphical corruption and wake/suspend loops (Works on my machine™)
Line 243: Line 243:


[https://discourse.nixos.org/t/suspend-resume-cycling-on-system-resume/32322/12 A potential fix] that Interrupts the gnome-shell in time so it’s not trying to access the graphics hardware. <ref>https://discourse.nixos.org/t/suspend-resume-cycling-on-system-resume/32322/12</ref> The entire purpose is to manually "pause" the GNOME Shell process just before the system sleeps and "un-pause" it just after the system wakes up.
[https://discourse.nixos.org/t/suspend-resume-cycling-on-system-resume/32322/12 A potential fix] that Interrupts the gnome-shell in time so it’s not trying to access the graphics hardware. <ref>https://discourse.nixos.org/t/suspend-resume-cycling-on-system-resume/32322/12</ref> The entire purpose is to manually "pause" the GNOME Shell process just before the system sleeps and "un-pause" it just after the system wakes up.
<hr>
If you have graphical corruption upon waking from suspend, and the above causes the system to go back to sleep ~20-30 seconds after wakeup, the following may solve both issues:
{{File|3={
  # https://discourse.nixos.org/t/black-screen-after-suspend-hibernate-with-nvidia/54341/6
  # https://discourse.nixos.org/t/suspend-problem/54033/28
  systemd = {
    # Uncertain if this is still required or not.
    services.systemd-suspend.environment.SYSTEMD_SLEEP_FREEZE_USER_SESSIONS = "false";
    services."gnome-suspend" = {
      description = "suspend gnome shell";
      before = [
        "systemd-suspend.service"
        "systemd-hibernate.service"
        "nvidia-suspend.service"
        "nvidia-hibernate.service"
      ];
      wantedBy = [
        "systemd-suspend.service"
        "systemd-hibernate.service"
      ];
      serviceConfig = {
        Type = "oneshot";
        ExecStart = ''${pkgs.procps}/bin/pkill -f -STOP ${pkgs.gnome-shell}/bin/gnome-shell'';
      };
    };
    services."gnome-resume" = {
      description = "resume gnome shell";
      after = [
        "systemd-suspend.service"
        "systemd-hibernate.service"
        "nvidia-resume.service"
      ];
      wantedBy = [
        "systemd-suspend.service"
        "systemd-hibernate.service"
      ];
      serviceConfig = {
        Type = "oneshot";
        ExecStart = ''${pkgs.procps}/bin/pkill -f -CONT ${pkgs.gnome-shell}/bin/gnome-shell'';
      };
    };
  };
  # https://discourse.nixos.org/t/black-screen-after-suspend-hibernate-with-nvidia/54341/23
  hardware.nvidia.powerManagement.enable = true;
}|name=configuration.nix|lang=nix}}


=== Black screen or 'nothing works' on laptops ===
=== Black screen or 'nothing works' on laptops ===