Skip to content

disabling a program that has settings set causes Nix eval error #419

@sellout

Description

@sellout

Describe the bug

If you disable a formatting program, but also define settings on it, Nix evaluation fails.

To Reproduce

nix-build the following treefmt-nix configuration:

{
  programs.prettier.enable = false;
  settings.formatter.prettier.excludes = ["*/docs/license-report.md"];
}

and you should see an error like “The option `settings.formatter.prettier.command' was accessed but has no value defined. Try setting the option.”

This happens with other programs and other settings as well (at least ormolu and includes, respectively), not sure if it’s universal or just a common pattern.

Expected behavior

Nix evaluation should succeed, and no formatter should be run.

System information

master as of writing this, on both i686-linux & aarch64-darwin

Additional context

My configuration looks like the above, except it has programs.prettier.enable = pkgs.system != "i686-linux", because prettier stopped compiling on i686-linux in Nixpkgs 25.05. On other systems, I stlil want prettier to run, and I don’t think I should have to conditionalize all the other settings just because enable is conditionalized (in my case, these attributes are set in different files in different repos, so propagating the fact that prettier doesn’t work on i686-linux any time I change a formatter setting anywhere is especially problematic).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions