programs.gnupg.agent: boolean flags in settings render as invalid gpg-agent.conf
Nobody has claimed this yet.
- Dominant language
- Nix
- Stars
- 26.2k
- Forks
- 20.1k
- PR merge metrics
- PR metrics pending
Description
Nixpkgs version
Unstable (26.05)
Describe the bug
programs.gnupg.agent.settings accepts boolean values but renders them incorrectly for gpg-agent.conf. Flag-style options like disable-scdaemon must appear as bare keywords with no argument, but the module renders disable-scdaemon = true; as disable-scdaemon true, which gpg-agent rejects on startup.
The root cause is in the settings format definition in nixos/modules/programs/gnupg.nix:
agentSettingsFormat = pkgs.formats.keyValue {
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
};
mkKeyValueDefault stringifies booleans, producing disable-scdaemon true instead of bare disable-scdaemon.
Steps to reproduce
- Add to NixOS configuration:
programs.gnupg.agent = {
enable = true;
settings = {
disable-scdaemon = true;
};
};
- Rebuild (
nixos-rebuild switch) - Observe
/etc/gnupg/gpg-agent.confcontainsdisable-scdaemon true - gpg-agent crashes on startup
Expected behaviour
disable-scdaemon = true; should render as bare disable-scdaemon in gpg-agent.conf, or the type system should reject boolean values if they can't be rendered correctly.
Relevant log output
gpg-agent[48772]: /etc/gnupg/gpg-agent.conf:2: argument not expected
systemd[2147]: gpg-agent.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
systemd[2147]: gpg-agent.service: Failed with result 'exit-code'.
Additional context
Workaround: disable-scdaemon = ""; renders as bare disable-scdaemon and works.
Related: #271436 (filed as a docs issue for the same underlying problem)
System metadata
- system:
"x86_64-linux" - host os:
Linux 6.12.68, NixOS, 26.05 (Yarara), 26.05.20260204.00c21e4 - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.31.3 - channels(root):
"nixos-24.05" - nixpkgs:
/nix/store/hiyg9ihp2i3ncldhcjm2vv81zn8gnb2i-nixpkgs/nixpkgs
Notify maintainers
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in nixos/modules/programs/gnupg.nix at the agentSettingsFormat definition and reproduce the boolean rendering described in the issue. Determine whether boolean flags should render as bare keywords or be rejected by the settings type, then verify that the generated gpg-agent.conf is accepted by gpg-agent and add regression coverage wherever the module's existing tests belong.
Written by the indexing model from the issue text.
Assessment
- Domain
- operating-systems, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100