My laptop has always had an issue on linux in which after closing the lid and reopening it, the keyboard or touchpad will stop working. The behavior on lid close is currently “sleep.” I’ve seen this answer, but it didn’t work in Ubuntu or Pop!_OS, and I’m not sure how I’d configure the GRUB_CMDLINE_LINUX equivalent on NixOS anyway. I’ve also tried configuring/reinstalling Wayland and X11 (again, while using Ubuntu and Pop!_OS) but I’ve never had any luck.
I’m thinking maybe just resetting the USB controller on wake (if that’s a good idea) or something might do it, but I don’t know where to start.
I believe you can set the kernel command line through boot.kernelParams NixOS option. However, I have the same issue (Sony Vaio laptop) and adding atkdb.reset there did not fix it for me either.
I have observed that external mouse still works so I can start the onboard on-screen-keyboard and toggle Num Lock there, which seems to jump start the keyboard. Alternately, I can run numlockx toggle to do the same.
On Wayland, none of the methods works to toggle Num Lock, though. I recently learned about sudo -- bash -c 'evemu-event /dev/input/event0 --type EV_KEY --code KEY_NUMLOCK --value 1 --sync; evemu-event /dev/input/event0 --type EV_KEY --code KEY_NUMLOCK --value 0 --sync', which might do it, but did not test it yet.
Yup, I have a Sony Vaio laptop too. The keyboard stops working 100% of the time, but the touchpad is much less frequent so I can still log in and use the virtual keyboard if something needs to be saved, but I haven’t tried Num Lock. I’ll give that a shot, at least it’s a workaround for now.
Solved on my machine by adding the line powerManagement.powerUpCommands = "sudo rmmod atkbd; sudo modprobe atkbd reset=1";
to configuration.nix.
Thanks to mich41 on this Arch Linux forum post for the idea.
cc @jtojnar