Similar issue: Missing Diagnostic For Invalid nullOr int NixOS Option Value
"great first issue" label is missing, i would've assigned it. "low priority" could probably also be a good label for this kind of nitpick, but everything that forces us to reevaluate through nix eval is just an unnecessary waste of time.
nixd can resolve enum-valued NixOS options and show the allowed values for hover/completion, but does not report a diagnostic when a literal string outside the enum is assigned.
For example, services.k3s.role is typed as:
Assigning another string does not produce an error diagnostic in the editor.
Expected Behavior
Given this NixOS module:
{ ... }:
{
services.k3s.role = "banana";
}
nixd should report a diagnostic for "banana", because the option type is:
Valid values would be:
services.k3s.role = "server";
services.k3s.role = "agent";
Actual Behavior
No diagnostic is shown in the editor, even though nixd can resolve the option type information.
The invalid value is rejected when the NixOS module system evaluates the configuration:
A definition for option `services.k3s.role' is not of type `one of "server", "agent"'.
Definition values:
- In `<unknown-file>': "banana"
Reproduction
flake.nix:
{
description = "nixd enum option value diagnostic reproduction";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
};
outputs =
{ nixpkgs, ... }:
{
nixosConfigurations.control = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
];
};
};
}
configuration.nix:
{ ... }:
{
services.k3s.role = "banana";
}
VS Code / Cursor nixd config:
{
"nix.enableLanguageServer": true,
"nix.serverPath": [
"nixd",
"--nixos-options-expr",
"(builtins.getFlake \"path:/absolute/path/to/repro\").nixosConfigurations.control.options"
]
}
Evaluation Verification
The NixOS module system rejects the value:
nix eval --impure --expr '
let
nixpkgs = builtins.getFlake "github:nixos/nixpkgs/nixos-25.11";
eval = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ ... }: {
services.k3s.role = "banana";
})
];
};
in
eval.config.services.k3s.role
'
Expected error:
A definition for option `services.k3s.role' is not of type `one of "server", "agent"'.
Environment
nixd version: 2.6.4
- Editor: VS Code / Cursor with
jnoortheen.nix-ide
nixpkgs: nixos-25.11
Similar issue: Missing Diagnostic For Invalid nullOr int NixOS Option Value
"great first issue" label is missing, i would've assigned it. "low priority" could probably also be a good label for this kind of nitpick, but everything that forces us to reevaluate through nix eval is just an unnecessary waste of time.
nixdcan resolve enum-valued NixOS options and show the allowed values for hover/completion, but does not report a diagnostic when a literal string outside the enum is assigned.For example,
services.k3s.roleis typed as:Assigning another string does not produce an error diagnostic in the editor.
Expected Behavior
Given this NixOS module:
nixdshould report a diagnostic for"banana", because the option type is:Valid values would be:
Actual Behavior
No diagnostic is shown in the editor, even though
nixdcan resolve the option type information.The invalid value is rejected when the NixOS module system evaluates the configuration:
Reproduction
flake.nix:configuration.nix:VS Code / Cursor
nixdconfig:{ "nix.enableLanguageServer": true, "nix.serverPath": [ "nixd", "--nixos-options-expr", "(builtins.getFlake \"path:/absolute/path/to/repro\").nixosConfigurations.control.options" ] }Evaluation Verification
The NixOS module system rejects the value:
Expected error:
Environment
nixdversion:2.6.4jnoortheen.nix-idenixpkgs:nixos-25.11