git.iko.soy/typeable/nixpkgs
on master help sign in
mkRemovedOptionModule: assert on removed options (#69419)

mkRemovedOptionModule: assert on removed options

commitc75a18fea6f25dd5dfcc7d76c91cf49e3c53c6c5 authorSilvan Mosberger <contact@infinisil.com> dateMon 30 Sep 2019, 16:39 (7 years ago) parent1857783b08b0bc
3 files changed+9−6
lib/modules.nix+7−4 nixos/modules/services/monitoring/prometheus/exporters/nginx.nix+1−1 nixos/modules/tasks/network-interfaces.nix+1−1
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 };