With nvidia drivers computer shutdowns after seconds

My PC is with AMD+nvidia 4080 and enabled nvidia drivers as NixOS 23.11 manual | Nix & NixOS after a fresh install with gnome (but after installing from CD I was not in a graphical UI, but on a stcuk UI and after some ALT+F4 on a terminal prompt)

services.xserver.videoDrivers = [ "nvidia" ];

Here is configuration.nix https://termbin.com/ixuj

And was able to enter to gnome (which I wasn before this), but after some seconds of logging to system and me doing simple things or doing nothing the computer shutdowns and the fan goes up like mad!

How can I troubleshot this?

I don’t spot anything obviously wrong; note that modern gnome is wayland and this interacts badly with nvidia’s drivers because nvidia’s drivers suck. YMMV, you might fare better if you choose the X11 session from the session drop down on the login screen.

You might also want to have a peek at my nvidia config, I’ve not yet sat down to update the nvidia wiki page/nixos-hardware: https://github.com/TLATER/dotfiles/blob/128f6b3165d53afbaa5743fc0c5d71c698e3aa6c/nixos-config/yui/nvidia.nix

In particular, you will probably want to set:

hardware.nvidia = {
  modesetting.enable = true;
  # Power management is required to get nvidia GPUs to behave on
  # suspend, due to firmware bugs. Aren't nvidia great?
  powerManagement.enable = true;
};

You may also want to look at the nixos-hardware modules for your CPU and GPU vendor: https://github.com/NixOS/nixos-hardware/tree/master/common.

With that said, I’m not convinced your issue is software related. Sounds like something overheating.

To debug, can you trigger the issue and then get the last boot’s logs (perhaps from a tty) by running:

journalctl --boot -1

What to look on that output? for ERR?? messages?

Also, it seems that I needed to update BIOS and things like that which I did and also been changing some settings on BIOS after that, seems more stable now.

One extra question on download Download Nix / NixOS | Nix & NixOS

It doesnt say that you need to configure anything to log to GNOME, but after some restarts and not going to GNOME, I need to configure configuration.nix to make it show the GNOME screen, is this expected? or just after installing on first reboot should I see GNOME?

If the later is the case, how can I troubleshot that or report that after clean install it is not working as expected???

Don’t know exactly, that’s why you need the logs. ERR messages are a good start, but they’re often caused by something else going wrong earlier. If you share the logs someone here may be able to interpret them.

NixOS doesn’t come with GNOME preinstalled, that’s only the graphical installer, so yes, this is expected.

If you want GNOME to show up on first boot, edit configuration.nix before triggering the install. This is explained in the installation manual, sadly using the graphical installer completely skips over this, often resulting in confusion for new users.

NixOS in general is designed to be a “clean install” every time you boot, by the way. This is often true (though some things do end up stored “imperatively”, such as GNOME settings - to prevent this some people use “impermanence”).

I’d recommend using the non-graphical installer, and following the manual if you have the stomach for some manual partitioning and want to understand NixOS better.