Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.trivial: rename NIX_ABORT_ON_WARN to NIXPKGS_ABORT_ON_WARN #306026

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions lib/trivial.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,24 @@ let
version
versionSuffix
warn;
in {

# We have to use builtins here in place of lib.warn, as otherwise its
# definition would depend on itself. Further, we do not want this to
# actually abort even if NIX_ABORT_ON_WARN is set, as otherwise legacy
# uses of this variable would immediately result in an unrecoverable
# error where there should be a deprecation warning.
printDeprecationWarning =
if 2405 <= oldestSupportedRelease && builtins.getEnv "NIX_ABORT_ON_WARN" != "" then
builtins.trace
"warning: NIX_ABORT_ON_WARN has been renamed to NIXPKGS_ABORT_ON_WARN. NIX_ABORT_ON_WARN is still honored, but deprecated and will be removed from nixpkgs after the 24.11 release."
else
a: a;

# Temporarily moved here to prevent lib.trivial from referencing itself.
# See the `inherit oldestSupportedRelease' further down.
oldestSupportedRelease = 2311;

in printDeprecationWarning {

## Simple (higher order) functions

Expand Down Expand Up @@ -377,9 +394,8 @@ in {
This release number allows deprecation warnings to be implemented such that
they take effect as soon as the oldest release reaches end of life.
*/
oldestSupportedRelease =
# Update on master only. Do not backport.
2311;
inherit oldestSupportedRelease;

/**
Whether a feature is supported in all supported releases (at the time of
Expand Down Expand Up @@ -698,8 +714,10 @@ in {
```
*/
warn =
if lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") ["1" "true" "yes"]
then msg: builtins.trace "warning: ${msg}" (abort "NIX_ABORT_ON_WARN=true; warnings are treated as unrecoverable errors.")
if lib.elem (builtins.getEnv "NIXPKGS_ABORT_ON_WARN") [ "1" "true" "yes" ]
# this latter clause is deprecated. When removing, also remove printDeprecationWarning above.
|| lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") [ "1" "true" "yes" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a comment here to mention that this one is deprecated, referring to printDeprecationWarning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added one

then msg: builtins.trace "warning: ${msg}" (abort "NIXPKGS_ABORT_ON_WARN=true; warnings are treated as unrecoverable errors.")
else msg: builtins.trace "warning: ${msg}";

/**
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/misc/documentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ let
libPath = filter (pkgs.path + "/lib");
pkgsLibPath = filter (pkgs.path + "/pkgs/pkgs-lib");
nixosPath = filter (pkgs.path + "/nixos");
NIX_ABORT_ON_WARN = warningsAreErrors;
NIXPKGS_ABORT_ON_WARN = warningsAreErrors;
modules =
"[ "
+ concatMapStringsSep " " (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy
Expand Down
4 changes: 2 additions & 2 deletions pkgs/top-level/nixpkgs-basic-release-checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pkgs.runCommand "nixpkgs-release-checks"

# To get a call trace; see https://nixos.org/manual/nixpkgs/stable/#function-library-lib.trivial.warn
# Relies on impure eval
export NIX_ABORT_ON_WARN=true
export NIXPKGS_ABORT_ON_WARN=true

set +e
(
Expand Down Expand Up @@ -79,7 +79,7 @@ pkgs.runCommand "nixpkgs-release-checks"
exit 1
fi

# Catch any trace calls not caught by NIX_ABORT_ON_WARN (lib.warn)
# Catch any trace calls not caught by NIXPKGS_ABORT_ON_WARN (lib.warn)
if [ -s eval-warnings.log ]; then
echo "Nixpkgs on $platform evaluated with warnings, aborting"
exit 1
Expand Down