NixOS & Configuration

The Nix command requires a disabled experimental feature

Nix rejects flakes or the modern CLI before evaluation. Check the active binary and settings scope, then enable only the features the workflow needs.

On this page
  1. Symptoms & scope
  2. Possible causes
  3. Diagnose safely
  4. Evidence-guided next steps
  5. References & review
  6. Related problems

Symptoms & scope

  • The command says experimental Nix feature flakes or nix-command is disabled.
  • A privileged invocation behaves differently from the user's shell.

Relevant environment

Nix installations using feature-gated nix-command and flakes; defaults vary by installation.

Recognizable messages (synthetic examples)
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it

The failure precedes evaluation of the flake's outputs.

error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it

This can fail even before flakes are involved.

Possible causes

These are possible explanations, not a confirmed diagnosis. Several independent faults can coexist.

  • The required feature may not be enabled in the configuration read by that command.
  • Another Nix executable or a different user configuration can produce different effective settings.

Diagnose safely

Run one command at a time in the relevant session. Read the explanation first. Uppercase placeholders need your own values; tools and privileges vary by distribution. These commands are displayed here and never executed by the website.

Check 1

Reads the Nix version without building or evaluating a flake; run in the failing shell.

nix --version

Interpret the result: Compare the actual executable version with the installed manual. A tutorial's feature assumptions may not match this installation.

Check 2

Reads usual global and user settings; a missing user file is normal, and included files may require separate inspection.

rg -n 'experimental-features|include' /etc/nix/nix.conf ~/.config/nix/nix.conf

Interpret the result: Check whether nix-command and flakes are present in the relevant scope. Root commands do not necessarily read the user's file.

Evidence-guided next steps

Enable the required feature for one command

If this is an occasional flake workflow, add --extra-experimental-features 'nix-command flakes' to that Nix command where supported. This makes the requirement explicit without a permanent settings edit.

Precautions: Experimental interfaces can change. A feature flag does not make an arbitrary flake trusted; inspect its source before building.

Recovery / rollback: Remove the per-command flag to restore the original invocation; no persistent feature state was changed.

Did this solution help you?

Share this solution#

Declare the needed features persistently

If flakes are an intended part of the NixOS configuration, declare nix.settings.experimental-features with the needed nix-command and flakes values, preserving other intentionally enabled features. Build and activate through the existing working workflow.

Precautions: Do not edit generated /etc/nix/nix.conf as the long-term NixOS source. Keep a route that can rebuild the configuration after reverting.

Recovery / rollback: Restore the prior declarative feature list and generation or remove the user-level setting you added.

Did this solution help you?

Share this solution#

References & review

This guide was prepared from primary project or distribution sources and reviewed on the date shown. This is an editorial source check, not evidence that a fix was reproduced on your hardware. Diagnostic log examples are synthetic fixtures. Version-dependent details must be checked against your installed release.