diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-04-27 13:52:15 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-04-28 21:44:21 +0000 |
commit | a8afbb45c12be27b9b93a802e9e276595899ed5a (patch) | |
tree | b4065c9ea79cf310b1b76976f21067761c206d88 | |
parent | 81e1e68eaf6c765147da964d356f704030734dd2 (diff) | |
download | nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.tar nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.tar.gz nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.tar.bz2 nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.tar.lz nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.tar.xz nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.tar.zst nixpkgs-a8afbb45c12be27b9b93a802e9e276595899ed5a.zip |
treewide: use lib.warnIf where appropriate
-rw-r--r-- | lib/modules.nix | 6 | ||||
-rw-r--r-- | lib/strings.nix | 4 | ||||
-rw-r--r-- | nixos/lib/testing-python.nix | 4 | ||||
-rw-r--r-- | pkgs/applications/networking/browsers/chromium/common.nix | 6 | ||||
-rw-r--r-- | pkgs/development/perl-modules/generic/default.nix | 6 | ||||
-rw-r--r-- | pkgs/servers/jellyfin/default.nix | 5 |
6 files changed, 12 insertions, 19 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index d3f10944e70..d515ee24d16 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 5010d9159cb..0f23b6b9d41 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: diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index 6192be1cd05..c7e45f55ce1 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -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'; diff --git a/pkgs/applications/networking/browsers/chromium/common.nix b/pkgs/applications/networking/browsers/chromium/common.nix index b08ff1ac7c1..73ce022915c 100644 --- a/pkgs/applications/networking/browsers/chromium/common.nix +++ b/pkgs/applications/networking/browsers/chromium/common.nix @@ -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; diff --git a/pkgs/development/perl-modules/generic/default.nix b/pkgs/development/perl-modules/generic/default.nix index c7b57eae906..9beacd65a64 100644 --- a/pkgs/development/perl-modules/generic/default.nix +++ b/pkgs/development/perl-modules/generic/default.nix @@ -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 diff --git a/pkgs/servers/jellyfin/default.nix b/pkgs/servers/jellyfin/default.nix index 2b00cb50073..77406c46415 100644 --- a/pkgs/servers/jellyfin/default.nix +++ b/pkgs/servers/jellyfin/default.nix @@ -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 { |