From a8afbb45c12be27b9b93a802e9e276595899ed5a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 27 Apr 2021 13:52:15 +0000 Subject: treewide: use lib.warnIf where appropriate --- lib/modules.nix | 6 +++--- lib/strings.nix | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/modules.nix b/lib/modules.nix index d3f10944e7085..d515ee24d16ef 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -37,7 +37,7 @@ let setAttrByPath toList types - warn + warnIf ; inherit (lib.options) isOption @@ -516,8 +516,8 @@ rec { value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue; warnDeprecation = - if opt.type.deprecationMessage == null then id - else warn "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}"; + warnIf (opt.type.deprecationMessage != null) + "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}"; in warnDeprecation opt // { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; diff --git a/lib/strings.nix b/lib/strings.nix index 5010d9159cb89..0f23b6b9d41f8 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -644,8 +644,8 @@ rec { floatToString = float: let result = toString float; precise = float == fromJSON result; - in if precise then result - else lib.warn "Imprecise conversion from float to string ${result}" result; + in lib.warnIf (!precise) "Imprecise conversion from float to string ${result}" + result; /* Check whether a value can be coerced to a string */ isCoercibleToString = x: -- cgit 1.4.1