Persistent Build Error: Option hardware.graphics does not exist (Definition Mismatch?)

Hello NixOS Community,

I’m encountering a persistent and strange error while trying to configure my NixOS system. When running sudo nixos-rebuild switch, I consistently get the following error, even with a minimal configuration:

error: The option `hardware.graphics' does not exist. Definition values:
       - In `/etc/nixos/configuration.nix':  # (or previously /etc/nixos/hardware/nvidia.nix)
           {
             enable = true;
           }

The really confusing part is that the file mentioned in the error message (/etc/nixos/configuration.nix in the minimal test case below) actually contains the correct syntax hardware.graphics.enable = true; when I check it with cat immediately before running the build. The error message incorrectly reports the definition value as { enable = true; }.

System Information:

  • Channel: Currently set to nixos-24.05 (stable) after troubleshooting. Originally was on nixos-24.11.
$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-24.05
nixos-unstable https://nixos.org/channels/nixos-unstable # (Not currently used by 'nixos' channel)

IGNORE_WHEN_COPYING_START

content_copy download

Use code with caution.

IGNORE_WHEN_COPYING_END

  • system.stateVersion: Set to “24.05” in the current minimal test configuration.

What I’ve Tried (Error Persists After Each Step):

  1. Verified Syntax: Quadruple-checked that hardware.graphics.enable = true; is correctly written in the relevant .nix file.
  2. Checked File Contents: Used cat /etc/nixos/configuration.nix (or the module file previously) right before nixos-rebuild switch to confirm the correct syntax is present.
  3. Modular vs. Main Config: The error occurred both when the option was in a separate module (/etc/nixos/hardware/nvidia.nix) and when placed directly in the main /etc/nixos/configuration.nix.
  4. Minimal Configuration: Reduced /etc/nixos/configuration.nix to the absolute minimum (shown below), importing only hardware-configuration.nix. The error still occurs.
  5. Searched for Conflicts: Ran sudo grep -R --include=‘*.nix’ “hardware.graphics = {” /etc/nixos/ - this command found nothing.
  6. Channel Switching: The error occurred on nixos-24.11 (unstable branch) and persists after switching the nixos channel to nixos-24.05 (stable) and updating stateVersion.
  7. Nix Store Maintenance: Ran sudo nix-collect-garbage -d and sudo nix-store --optimise.
  8. Restarted Nix Daemon: Ran sudo systemctl restart nix-daemon.service.
  9. Verified Nix Store: Ran sudo nix-store --verify --check-contents - completed without reporting errors.

Minimal /etc/nixos/configuration.nix (Reproduces the Error):

# /etc/nixos/configuration.nix (MINIMAL TEST CONFIG)
{ config, pkgs, lib, ... }:

{
  imports = [ ./hardware-configuration.nix ];

  # --- MINIMAL SETTINGS ---
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  networking.hostName = "nixos-graphics-test";
  networking.networkmanager.enable = true;
  time.timeZone = "Europe/Warsaw";
  i18n.defaultLocale = "ru_RU.UTF-8";
  users.users.yakatze = {
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" "audio" "video" ];
    shell = pkgs.zsh;
  };
  programs.zsh.enable = true;
  nixpkgs.config.allowUnfree = true; # For NVIDIA drivers

  # --- GRAPHICS & NVIDIA (DIRECTLY HERE) ---
  hardware.graphics.enable = true; # Correct syntax is present here

  hardware.nvidia = {
    modesetting.enable = true;
    open = true;
    powerManagement.enable = true;
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };
  services.xserver.videoDrivers = [ "nvidia" ];
  boot.kernelParams = [ "nvidia-drm.modeset=1" ];
  # -------------------------------------

  # Using stable channel version
  system.stateVersion = "24.05";
}

IGNORE_WHEN_COPYING_START

content_copy download

Use code with caution. Nix

IGNORE_WHEN_COPYING_END

/etc/nixos/hardware-configuration.nix:
(This file seems standard, contains filesystems, boot modules, etc. - You might want to paste the content of your hardware-configuration.nix here if you think it’s relevant)

# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/843fb6cf-3a44-4262-a2ca-2c027cfc3098";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/6155-128D";
      fsType = "vfat";
      options = [ "fmask=0077" "dmask=0077" ];
    };

  swapDevices = [ ];

  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp42s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

IGNORE_WHEN_COPYING_START

content_copy download

Use code with caution. Nix

IGNORE_WHEN_COPYING_END

I’m running out of ideas. It seems like Nix is evaluating the file incorrectly or using some cached/corrupted state, despite nix-store --verify reporting no issues.

Does anyone have suggestions on what could be causing Nix to misread the definition value for hardware.graphics.enable or why the option might appear non-existent even on the stable channel with a minimal config? Any further diagnostic steps I could take?

Thanks in advance for any help!


hardware.graphics was added in NixOS 24.11. Which error did you get previously?

nixos-24.11 is the current stable version.

Stop using GC as a troubleshooting strategy (it’s not one).

This is irrelevant, leave it as is, don’t touch it.

What matters is your channel(s), i.e. output of sudo nix-channel --list. Set your channel to 24.11 for now, then run sudo nix-channel --update, then rebuild.

1 Like

same error on both 24.11 and 24.05

In any case 24.05 is not supported, please switch to 24.11 and update your channels.