This now seems to be working. After lots of googling, looking at lots of journalctl logs, and lots of config changes and reboots, down below is what I have at this point in the configuration.nix.
The GUI environment does load and currently is extended to three external monitors, and it seems that things shut down and resume properly other than a brief flicker when initially booting.
This laptop has a newish CPU (Intel i7-12700H). After doing the stuff in the wiki trying to get Optimus/Prime working, it still wouldn’t boot to a graphical environment, which seemed to be related to the newish CPU with newish Intel integrated graphics. From the journalctl log:
i915 0000:00:02.0: Your graphics device 46a6 is not properly supported by the driver in this kernel version. To force driver probe anyway, use i915.force_probe=46a6 module parameter or CONFIG_DRM_I915_FORCE_PROBE=46a6 configuration option, or (recommended) check for kernel updates.
I tried adding this recommended modprobe option in boot.extraModprobeConfig. I also found some other posts from folks with various problems on other distros and other laptops with this same CPU, and I ended up with one extra kernel param. I’m not sure if that is needed, but it’s listed down below.
After all of this, I was quite relieved to see the graphical environment load on the laptop and 3 of the external monitors. I have two more external monitors that I was driving using DisplayLink on the old (Windows) laptop, but I think the new laptop can drive them just using Thunderbolt. Otherwise I’ll have to try to get DisplayLink working on NixOS.
Anyway, here are some excerpts from my current configuration.nix, in case anyone finds that helpful or notices something that doesn’t look right. Interestingly, I think that if I didn’t take out services.xserver.displayManager.sddm.enable out, then it did not work loading a graphical environment (I think that was in there from the installer’s default config, but can’t remember).
# configuration.nix
boot.kernelParams = [
"i915.enable_psr=0" "loglevel=3"
];
boot.extraModprobeConfig = ''
options i915 force_probe=46a6
'';
...
hardware.nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
powerManagement.enable = true;
prime = {
offload.enable = true;
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
...
services.xserver = {
enable = true;
videoDrivers = [ "nvidia" ];
desktopManager = {
plasma5.enable = true;
};
layout = "us";
xkbVariant = "";
dpi = 96;
};