Troubleshooting - Failed Display Manager (any X11 DM or WM + LightDM + NVIDIA)
Summary
- The initial problem was a failure of the
display-manager.serviceto start on a NixOS system configured with i3, LightDM, and an NVIDIA GPU. - The troubleshooting process revealed a series of issues, starting with minor configuration errors and culminating in the discovery of a fundamental mismatch between the hardware and its NixOS configuration.
- The root cause was the presence of a
hardware.nvidia.primeblock, which is meant for dual-GPU laptops, on a single-GPU desktop system. - Removing this block resolved all issues.
Problem Timeline & Diagnosis
Initial State: Display Manager Fails to Start
- Symptom: On boot, the system would display "Failed to start Display Manager" and halt before the graphical login screen.
- Initial Config: Standard i3 and LightDM setup.
services.xserver = { enable = true; displayManager.lightdm.enable = true; windowManager.i3.enable = true; };
Investigation: Red Herrings
A series of errors were investigated that were symptoms of the deeper issue, but not the root cause.
plymouth-quit.service not found Diagnosis: LightDM was trying to communicate with the Plymouth boot splash screen, which wasn't enabled.
Fix: Added boot.plymouth.enable = true; to configuration.nix.
Main process exited, code=exited, status=1/FAILURE Diagnosis: LightDM was crashing instantly. This is often caused by a missing greeter (the login screen GUI).
Fix: Explicitly enabled the GTK greeter with services.xserver.displayManager.lightdm.greeters.gtk.enable = true;.
The True Root Cause: Xorg Driver Failure
Even after fixing the above, the service failed. The Xorg log provided the critical clue.
/var/log/Xorg.0.log
(EE) no devices detected
(EE) no screens found
Diagnosis: This is a fatal X server error. It means the kernel driver for the graphics card was not loaded or not functioning, so Xorg could not find any hardware to use.
The Turning Point: A Misleading Configuration
The investigation then focused on the NVIDIA driver configuration. A provided screenshot of hardware.nix contained the definitive, albeit misleading, clue.
The configuration included a hardware.nvidia.prime block:
hardware.nvidia.prime = {
offload.enable = true;
# ...
};
This block is exclusively for dual-GPU systems (e.g., Optimus laptops) to manage switching between an integrated and a dedicated GPU. Its presence incorrectly led to the assumption that the hardware was a dual-GPU laptop.
Resolution
The actual hardware was a standard single-GPU desktop. The prime configuration was fundamentally incorrect for the machine.
- The Fix: The entire
hardware.nvidia.primeblock was removed from the configuration. - The Result: With the incorrect
primesetting gone, NixOS generated a standard single-GPU configuration. This matched the actual hardware, allowing the NVIDIA kernel module to load correctly, the X server to detect the device and screen, and LightDM to start successfully.
Final Correct Configuration for Single-GPU NVIDIA Desktop
# /etc/nixos/configuration.nix
{ config, pkgs, ... }:
{
# 1. Allow the proprietary NVIDIA driver to be installed
nixpkgs.config.allowUnfree = true;
# 2. Configure the X server to use the driver
services.xserver = {
enable = true;
videoDrivers = [ "nvidia" ];
displayManager.lightdm.enable = true;
windowManager.i3.enable = true;
# ... any other X server settings
};
# 3. Configure the NVIDIA kernel module itself
hardware.nvidia = {
# This enables the kernel module and is crucial for modern displays
modesetting.enable = true;
# Use the proprietary closed-source driver
open = false;
# Recommended for performance and power management
powerManagement.enable = true;
};
}