3
0
Fork 0
forked from mirrors/nixpkgs

treewide: use lib.warnIf where appropriate

This commit is contained in:
Alyssa Ross 2021-04-27 13:52:15 +00:00
parent 81e1e68eaf
commit a8afbb45c1
6 changed files with 12 additions and 19 deletions

View file

@ -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;

View file

@ -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:

View file

@ -131,10 +131,8 @@ rec {
"it's currently ${toString testNameLen} characters long.")
else
"nixos-test-driver-${name}";
warn = if skipLint then lib.warn "Linting is disabled!" else lib.id;
in
warn (runCommand testDriverName
lib.warnIf skipLint "Linting is disabled" (runCommand testDriverName
{
buildInputs = [ makeWrapper ];
testScript = testScript';

View file

@ -112,10 +112,8 @@ let
warnObsoleteVersionConditional = min-version: result:
let ungoogled-version = (importJSON ./upstream-info.json).ungoogled-chromium.version;
in if versionAtLeast ungoogled-version min-version
then warn "chromium: ungoogled version ${ungoogled-version} is newer than a conditional bounded at ${min-version}. You can safely delete it."
result
else result;
in warnIf (versionAtLeast ungoogled-version min-version) "chromium: ungoogled version ${ungoogled-version} is newer than a conditional bounded at ${min-version}. You can safely delete it."
result;
chromiumVersionAtLeast = min-version:
let result = versionAtLeast upstream-info.version min-version;
in warnObsoleteVersionConditional min-version result;

View file

@ -5,10 +5,8 @@
assert attrs?pname -> attrs?version;
assert attrs?pname -> !(attrs?name);
(if attrs ? name then
lib.trivial.warn "builtPerlPackage: `name' (\"${attrs.name}\") is deprecated, use `pname' and `version' instead"
else
(x: x))
lib.warnIf (attrs ? name) "builtPerlPackage: `name' (\"${attrs.name}\") is deprecated, use `pname' and `version' instead"
toPerlModule(stdenv.mkDerivation (
(
lib.recursiveUpdate

View file

@ -11,9 +11,8 @@ let
else if isAarch64 then "arm64"
else lib.warn "Unsupported architecture, some image processing features might be unavailable" "unknown";
musl = lib.optionalString stdenv.hostPlatform.isMusl
(if (arch != "x64")
then lib.warn "Some image processing features might be unavailable for non x86-64 with Musl" "musl-"
else "musl-");
(lib.warnIf (arch != "x64") "Some image processing features might be unavailable for non x86-64 with Musl"
"musl-");
runtimeDir = "${os}-${musl}${arch}";
in stdenv.mkDerivation rec {