treewide: use lib.warnIf where appropriate
This commit is contained in:
parent
81e1e68eaf
commit
a8afbb45c1
|
@ -37,7 +37,7 @@ let
|
||||||
setAttrByPath
|
setAttrByPath
|
||||||
toList
|
toList
|
||||||
types
|
types
|
||||||
warn
|
warnIf
|
||||||
;
|
;
|
||||||
inherit (lib.options)
|
inherit (lib.options)
|
||||||
isOption
|
isOption
|
||||||
|
@ -516,8 +516,8 @@ rec {
|
||||||
value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
|
value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
|
||||||
|
|
||||||
warnDeprecation =
|
warnDeprecation =
|
||||||
if opt.type.deprecationMessage == null then id
|
warnIf (opt.type.deprecationMessage != null)
|
||||||
else warn "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";
|
"The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";
|
||||||
|
|
||||||
in warnDeprecation opt //
|
in warnDeprecation opt //
|
||||||
{ value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
|
{ value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
|
||||||
|
|
|
@ -644,8 +644,8 @@ rec {
|
||||||
floatToString = float: let
|
floatToString = float: let
|
||||||
result = toString float;
|
result = toString float;
|
||||||
precise = float == fromJSON result;
|
precise = float == fromJSON result;
|
||||||
in if precise then result
|
in lib.warnIf (!precise) "Imprecise conversion from float to string ${result}"
|
||||||
else lib.warn "Imprecise conversion from float to string ${result}" result;
|
result;
|
||||||
|
|
||||||
/* Check whether a value can be coerced to a string */
|
/* Check whether a value can be coerced to a string */
|
||||||
isCoercibleToString = x:
|
isCoercibleToString = x:
|
||||||
|
|
|
@ -131,10 +131,8 @@ rec {
|
||||||
"it's currently ${toString testNameLen} characters long.")
|
"it's currently ${toString testNameLen} characters long.")
|
||||||
else
|
else
|
||||||
"nixos-test-driver-${name}";
|
"nixos-test-driver-${name}";
|
||||||
|
|
||||||
warn = if skipLint then lib.warn "Linting is disabled!" else lib.id;
|
|
||||||
in
|
in
|
||||||
warn (runCommand testDriverName
|
lib.warnIf skipLint "Linting is disabled" (runCommand testDriverName
|
||||||
{
|
{
|
||||||
buildInputs = [ makeWrapper ];
|
buildInputs = [ makeWrapper ];
|
||||||
testScript = testScript';
|
testScript = testScript';
|
||||||
|
|
|
@ -112,10 +112,8 @@ let
|
||||||
|
|
||||||
warnObsoleteVersionConditional = min-version: result:
|
warnObsoleteVersionConditional = min-version: result:
|
||||||
let ungoogled-version = (importJSON ./upstream-info.json).ungoogled-chromium.version;
|
let ungoogled-version = (importJSON ./upstream-info.json).ungoogled-chromium.version;
|
||||||
in if versionAtLeast ungoogled-version min-version
|
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."
|
||||||
then warn "chromium: ungoogled version ${ungoogled-version} is newer than a conditional bounded at ${min-version}. You can safely delete it."
|
result;
|
||||||
result
|
|
||||||
else result;
|
|
||||||
chromiumVersionAtLeast = min-version:
|
chromiumVersionAtLeast = min-version:
|
||||||
let result = versionAtLeast upstream-info.version min-version;
|
let result = versionAtLeast upstream-info.version min-version;
|
||||||
in warnObsoleteVersionConditional min-version result;
|
in warnObsoleteVersionConditional min-version result;
|
||||||
|
|
|
@ -5,10 +5,8 @@
|
||||||
assert attrs?pname -> attrs?version;
|
assert attrs?pname -> attrs?version;
|
||||||
assert attrs?pname -> !(attrs?name);
|
assert attrs?pname -> !(attrs?name);
|
||||||
|
|
||||||
(if attrs ? name then
|
lib.warnIf (attrs ? name) "builtPerlPackage: `name' (\"${attrs.name}\") is deprecated, use `pname' and `version' instead"
|
||||||
lib.trivial.warn "builtPerlPackage: `name' (\"${attrs.name}\") is deprecated, use `pname' and `version' instead"
|
|
||||||
else
|
|
||||||
(x: x))
|
|
||||||
toPerlModule(stdenv.mkDerivation (
|
toPerlModule(stdenv.mkDerivation (
|
||||||
(
|
(
|
||||||
lib.recursiveUpdate
|
lib.recursiveUpdate
|
||||||
|
|
|
@ -11,9 +11,8 @@ let
|
||||||
else if isAarch64 then "arm64"
|
else if isAarch64 then "arm64"
|
||||||
else lib.warn "Unsupported architecture, some image processing features might be unavailable" "unknown";
|
else lib.warn "Unsupported architecture, some image processing features might be unavailable" "unknown";
|
||||||
musl = lib.optionalString stdenv.hostPlatform.isMusl
|
musl = lib.optionalString stdenv.hostPlatform.isMusl
|
||||||
(if (arch != "x64")
|
(lib.warnIf (arch != "x64") "Some image processing features might be unavailable for non x86-64 with Musl"
|
||||||
then lib.warn "Some image processing features might be unavailable for non x86-64 with Musl" "musl-"
|
"musl-");
|
||||||
else "musl-");
|
|
||||||
runtimeDir = "${os}-${musl}${arch}";
|
runtimeDir = "${os}-${musl}${arch}";
|
||||||
|
|
||||||
in stdenv.mkDerivation rec {
|
in stdenv.mkDerivation rec {
|
||||||
|
|
Loading…
Reference in New Issue