Repository navigation
Description
Nixpkgs version
- Unstable (26.05)
Describe the bug
Setting a Kconfig string option to the empty string via structuredExtraConfig (or boot.kernelPatches[].extraStructuredConfig) using lib.kernel.freeform "" does not produce an empty value in the generated .config. The resulting line contains the literal two-character string "" instead.
Steps to reproduce
-
Add a kernel patch entry that clears
CONFIG_LOCALVERSION:boot.kernelPatches = [{ name = "empty-localversion"; patch = null; extraStructuredConfig.LOCALVERSION = lib.kernel.freeform ""; }];
-
Build the kernel and inspect the generated
.config.
Expected behaviour
CONFIG_LOCALVERSION=""
And modDirVersion equal to the kernel version with no suffix.
Screenshots
No response
Relevant log output
$ grep LOCALVERSION $out
CONFIG_LOCALVERSION="\"\""
When this value flows through to `Makefile`'s `KERNELRELEASE`, `modDirVersion` becomes e.g. `6.12.75""`, which trips the nixpkgs sanity check:
Error: modDirVersion 6.12.75 specified in the Nix expression is wrong, it should be: 6.12.75""Additional context
Cause is in nixos/modules/system/boot/kernel_config.nix:
mkValue = val:
if (val == "") then "\"\""
else if val == "y" || val == "m" || val == "n" then val
...
else val; # FIXME: fix quoting one dayEvery other branch returns val unquoted. The intermediate format consumed by pkgs/os-specific/linux/kernel/generate-config.pl is unquoted; kconfig itself adds quotes when writing .config. The empty-string branch emits "" into the intermediate file, the perl regex captures the two " chars as the answer, and kconfig stores them as the string value.
Side issue: the perl regex ^\s*([A-Za-z0-9_]+)(\?)?\s+(.*\S)\s*$ requires at least one non-space char after the key, so simply changing mkValue "" to return "" would silently drop the line. A real fix probably needs mkValue "" to emit a recognisable token plus a post-make config rewrite of .config for empty freeform values.
freeform "" looks usable but never has worked. The most common case is clearing CONFIG_LOCALVERSION for vendor kernels (Raspberry Pi, etc.). Today's workaround is a postConfigure sed on .config, used by pkgs/os-specific/linux/kernel/linux-rpi.nix and recently re-introduced in nixos-hardware (NixOS/nixos-hardware#1860, fixes NixOS/nixos-hardware#1859).
System metadata
- system:
"x86_64-linux" - host os:
Linux 6.6.87.2-microsoft-standard-WSL2, Arch Linux, noversion, rolling - multi-user?:
yes - sandbox:
yes - version:
nix-env (Determinate Nix 3.17.3) 2.33.3 - nixpkgs:
/nix/store/ps8fhbglachs62pf47aw3rzx8zfij8sp-source
Notify maintainers
cc @teto @alyssais @lheckemann
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- I assert that this is a bug and not a support request.
- I assert that this is not a duplicate of an existing issue.
- I assert that I have read the NixOS Code of Conduct and agree to abide by it.
Is this issue important to you?
Add a 👍 reaction to issues you find important.
Activity
alyssais commentedon May 6, 2026
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
JamieMagee commentedon May 6, 2026
@alyssais #517382
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""
linux/kernel: support empty-string values via lib.kernel.freeform ""