mkRemovedOptionModule: assert on removed options
We don't want to ignore config that can mess up machines. In general
this should always fail evaluation, as you think you are changing
behaviour and don't, which can easily create run-time errors we can
catch early.
commitb08b0bcbbec77046e5a7082177cedc12fbf1dc6c
authorRobin Gloster <mail@glob.in>
dateWed 25 Sep 2019, 17:13 (7 years ago)
parentd4212d6
lib/modules.nix+7−4
@@ -592,11 +592,14 @@ rec {
592592 { options = setAttrByPath optionName (mkOption {
593593 visible = false;
594594 });
595− config.warnings =
596− let opt = getAttrFromPath optionName options; in
597− optional opt.isDefined ''
595+ config.assertions =
596+ let opt = getAttrFromPath optionName options; in [{
597+ assertion = !opt.isDefined;
598+ message = ''
598599 The option definition `${showOption optionName}' in ${showFiles opt.files} no longer has any effect; please remove it.
599− ${replacementInstructions}'';
600+ ${replacementInstructions}
601+ '';
602+ }];
600603 };
601604
602605 /* Return a module that causes a warning to be shown if the
nixos/modules/services/monitoring/prometheus/exporters/nginx.nix+1−1
@@ -49,6 +49,6 @@ in
4949 (mkRemovedOptionModule [ "insecure" ] ''
5050 This option was replaced by 'prometheus.exporters.nginx.sslVerify'.
5151 '')
52− ({ options.warnings = options.warnings; })
52+ ({ options.warnings = options.warnings; options.assertions = options.assertions; })
5353 ];
5454}
nixos/modules/tasks/network-interfaces.nix+1−1
@@ -305,7 +305,7 @@ let
305305 optional (defined ipv6Address && defined ipv6PrefixLength)
306306 { address = ipv6Address; prefixLength = ipv6PrefixLength; }))
307307
308− ({ options.warnings = options.warnings; })
308+ ({ options.warnings = options.warnings; options.assertions = options.assertions; })
309309 ];
310310
311311 };