My NixOS laptop often freezes

I have a newish laptop, only about one year old, that’s dual-booting NixOS and Windows. For some reason, on NixOS, it will routinely freeze, becoming unresponsive to keyboard, touchpad, touch screen, and everything. The mouse pointer stops moving. I also can’t do Ctrl+Alt+F1 to switch to a TTY. The only thing I can do is hard-poweroff my system by holding down the power button for ten seconds. This can’t be good.

It seems to happen a few times a day, at random times. That is, not only while I’m doing something compute-intensive.

I don’t think it could be the HD failing, since I just upgraded the SSD to a new one recently. (And this was happening before the upgrade, too.) I also don’t think it can be overheating, since this seems to happen when the computer’s cold, too.

Here’s my configuration.nix, if it helps.

I’ve tried looking through my log files, using the Log File Viewer, but I don’t see anything relevant, as far as I can tell. Maybe I don’t know what to look for, or am looking in the wrong files?

1 Like

What’s the model of the laptop? Check out https://github.com/NixOS/nixos-hardware - perhaps someone already published tweaks specific to that model.

If it’s very new it’s worth trying the latest Linux kernel version (instead of the default LTS), by setting boot.kernelPackages = pkgs.linuxPackages_latest;.

You should be able to view the complete log from the previous boot using journalctl -b -1, there might me relevant information at the end.

Have you tried updating BIOS/firmware to the latest version? Helped me last time I had similar problem.

Do you happen to use Linux 5.x and have an Intel GPU? There is a known bug in the in the i915 driver. I had to revert to 4.19 to get rid of the freezes.

https://linuxreviews.org/Linux_Kernel_5.5_Will_Not_Fix_The_Frequent_Intel_GPU_Hangs_In_Recent_Kernels

You can find out whether this bug affects you by logging in on the machine with SSH (after a hang) and using journalctl or dmesg to hunt for a message along the lines of:

hsw iommu i915 0000:00:02.0: GPU HANG: ecode 7:0:0x00000000, hang on rcs0 (446)
1 Like

It’s a Lenovo Yoga C930. I think it does have Intel graphics. I’m using whatever the default kernel is on unstable. Maybe I should try upgrading it or downgrading it.

I have

boot.kernelPackages = pkgs.linuxPackages_4_19;

In the configuration.nix of that machine, until it is fixed upstream.

I found nixOS to be extra IO-intensive by having installed it on a cheap USB key.
The pauses I had appeared to be exactly like your description.
Once I moved to an actual SSD the problem was gone.
I think it might depend on what SSD you are using.
When your input devices freeze it may also be the USB bus clogged.

I have the same problem, laptop (1 year old) crashes - using power button is the only way to reboot.
the thing is, I already have

boot.kernelPackages = pkgs.linuxPackages_4_19;

in my configuration.nix
Laptop: Asus Zenbook UX430UA-GV265T

I figured out that Firefox hardware acceleration was the culprit. I haven’t had any freezes yet, since disabling hardware acceleration on Firefox. See the discussion here at Mozilla.

That said, I wonder where I can find NixOS’s graphics driver settings. Is something disabled in the graphics driver that makes Firefox crash? Mozilla’s discussion recommends updating one’s graphics driver to one that supports WebGL. Does anyone know how to do that?