NixOS & Configuration

Two modules define incompatible option values

Evaluation cannot merge a scalar option defined in several modules. Trace definition locations and priorities before applying a force override.

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 evaluator lists conflicting values and source files.
  • A newly imported profile duplicates a host-specific setting.

Relevant environment

NixOS module merging, especially scalar options with multiple same-priority definitions.

Recognizable messages (synthetic examples)
error: The option `networking.hostName' has conflicting definition values:

Read all listed definition locations before introducing an override.

error: Cannot merge definitions of `example.option'. Definition values:

The option type and source definitions determine the correct fix.

Possible causes

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

  • Two normal-priority definitions may disagree for a non-mergeable scalar option.
  • A shared profile may use a hard setting where an overridable default was intended.

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

Replace example.option with the failing option and use the real configuration directory.

rg -n 'example\.option|mkDefault|mkForce|mkOverride' /etc/nixos

Interpret the result: Compare the error's source files with definitions and explicit priorities. List ordering does not make a scalar definition win.

Check 2

Read the import declarations in the same configuration tree; adapt the directory for flakes.

rg -n 'imports|disabledModules' /etc/nixos

Interpret the result: Identify which host and common profiles both contribute the option. A repeated import is not equivalent to two different modules defining it.

Evidence-guided next steps

Remove the accidental competing value

If one definition is obsolete or unintended, remove it or move host-specific data out of the common profile. Keep the one intended source of the scalar value.

Precautions: The same common profile may serve several machines. Check their intended defaults before changing it.

Recovery / rollback: Restore the removed definition or profile change and its associated host configuration if another machine regresses.

Did this solution help you?

Share this solution#

Declare the intended default or override

If the shared value is a fallback, use lib.mkDefault there so a host's normal value wins. Use lib.mkForce only when intentionally discarding all weaker definitions; document why that policy is required.

Precautions: Lower numeric override priority wins; mkForce is not a universal repair. Lists and mergeable types need their own merge semantics.

Recovery / rollback: Restore previous priorities and build the old configuration; keep a prior bootable generation before activation.

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.