Occasionally, NixOS changes config options in a way that is not entirely backwards compatible. For example, nixos 19.09 did not have a programs.gnupg.agent.pinentryFlavor
option, but in nixos unstable (soon 20.03) I need to set it to a non-default value in order to get the right pinentry variant.
I share my configuration across machines, some of which run nixos-19.09 and some nixos-unstable, so I want my configuration to be compatible with both. (even without multiple machines, it would be nice to be able to switch nixos channels without breakage)
Setting programs.gnupg.agent.pinentryFlavor = "gtk2";
as needed for nixos-unstable causes nixos-rebuild
to fail on nixos-19.09:
error: The option `programs.gnupg.agent.pinentryFlavor' defined in `[...]/desktop.nix' does not exist.
(use '--show-trace' to show detailed location information)
Is there a way to check if an option is valid?
Essentially, I'm looking for what to write in place of ???(pinentryFlavor)
) here, so as to not set a nonexistent option:
programs.gnupg.agent = { enable = true;} // (
if ???(pinentryFlavor)
then { pinentryFlavor = "gtk2"; }
else {});