I have a difficulty writing configuration.nix
which suppose to work with many NixOS releases, for example a test-driver which is suitable for bisecting a bug:
NixOS options appear and disappear with time.
And it is not easy to check if an option is available
For example, networking.networkmanager.dns
appeared approx. in NixOS 18.09
It works fine with release-18.09
but as we go back in time to release-18.03
it stops working.
-
networking.networkmanager.dns ="none";
fails with “there is no such option”. -
mkIf ... { networking.networkmanager.dns = "none"; }
fails too with “there is no such option” -
lib.optionalAttrs (config.options?networking.networkmanager.dns) { networking.networkmanager.dns = "none"; }
fails with infinite recursion -
lib.optionalAttrs (lib?bitXor) { networking.networkmanager.dns = "none"; }
finally works becauselib.bitXor
appeared approximately at the same time and accessinglib.
does not result in infinite recursion
But it is weird and unreliable, it might be good enough to distinguish release-18.03
and release-18.09
but config.options?networking.networkmanager.dns
and lib?bitXor
point to different moments in nixpkgs history and the problem will strike back if bisecting approach them