Skip to content

builtins.suppressWarnings builtin #15847

Open

Description

@Pandapip1

Is your feature request related to a problem?

I have the following flake: https://codeberg.org/Pandapip1/nixos-linux-rt. It automatically walks through all the nixpkgs kernels and creates PREEMPT_RT variants of them. However, because some filtering is necessary, I have to evaluate all of the entries, which triggers warnings:

evaluation warning: linux-rpi series will be removed in a future release. Please change to use nixos-hardware.
evaluation warning: linux-rpi series will be removed in a future release. Please change to use nixos-hardware.
evaluation warning: linux-rpi series will be removed in a future release. Please change to use nixos-hardware.
evaluation warning: linux-rpi series will be removed in a future release. Please change to use nixos-hardware.

Proposed solution

A builtin builtins.suppressWarnings that operates similarly to builtins.tryEval, except it suppresses warnings instead of eval errors.

Alternative solutions

The filtering code is as follows:

          upstreamKernels = pkgs.linuxKernel.kernels;
          safeKernels = lib.filterAttrs (_: isSafeKernel) upstreamKernels;
          rtKernels = lib.mapAttrs (_: mkRtKernel) safeKernels;

If builtins.filterAttrs existed (#11888), then safeKernels would not require the evaluation of the entirety of upstreamKernels, and I wouldn't have to deal with these warnings.

Additional context

N.A.

Checklist


Add 👍 to issues you find important.

Activity

  1. added
    feature
    on May 13, 2026
  2. changed the title [-]builtins.suppressWarnings builtin[/-] [+]`builtins.suppressWarnings` builtin[/+] on May 13, 2026
  3. roberth commented on May 20, 2026

    @roberth
    Member

    This builtin would be a bit quirky. Because call-by-need saves various intermediate results, you would be able to

    1. have a = builtins.warn "foo" something;
    2. in package x:
    • evaluate a as part of a suppressWarnings call, not emitting the warning
    • ignore the value of a
    1. in package y:
    • evaluate a
    • use the value of a

    Here y should have triggered the warning, but didn't because of call-by-need.
    A crude way to solve this is to create a new evaluator + heap to cut out any sharing, but that risks other side effects (e.g. broken function equality breaking some more). I don't think we'd want to go there.

    Ideally you could expose enough information in a way that doesn't trigger the warning?
    For example, Nixpkgs has warnOnInstantiate to delay the warning until outPath or similar is accessed.
    Maybe something like that could be used in your situation too?

  4. hyperparabolic commented on Sep 12, 2026

    @hyperparabolic

    I've been struggling with similar. I run nixos-unstable with zfs, so I iterate all of the kernel packages to find the most recent kernel with zfs support to stay (mostly) pinned to the latest tagged zfs release without twiddling zfs_*version numbers with every release.

    I've been getting annoyed with more breaks pushing into my hydra due to getting blocked out of abort-on-warn, and eventually took the time to dig into this and part of that led me here. I landed on just filtering out the linux_rpi* packages by filtering on name prefix before evaluating attributes that warn. Similar might help you with the rpi warnings.

    I'd still love a feature like this, or exceptions on abort-on-warn. stdenv.hostPlatform.* warnings have been pretty endless for me from upstream flakes.

  5. roberth commented on Sep 15, 2026

    @roberth
    Member

    abort-on-warn,

    As the author, I would recommend to use that as a flag for finding details about warnings and nothing else.

    or exceptions on abort-on-warn

    I think you mean making tryEval catch these aborts?
    The purpose of the flag is to produce a trace, so getting tryEval to swallow those traces would make it incapable of serving its original purpose.

  6. hyperparabolic commented on Sep 17, 2026

    @hyperparabolic

    abort-on-warn,

    As the author, I would recommend to use that as a flag for finding details about warnings and nothing else.

    or exceptions on abort-on-warn

    I think you mean making tryEval catch these aborts? The purpose of the flag is to produce a trace, so getting tryEval to swallow those traces would make it incapable of serving its original purpose.

    I know it's not really intended to be used as a linting tool, but it kind of quacks like one.

    I like when I can have it enabled. It draws my attention to upcoming deprecations in otherwise automated flows. If the warnings are local I fix them immediately. If it's upstream I tend to disable abort-on-warn and more issues that would be open PRs waiting for me turn into broken hydra builds waiting for me. Not a huge difference at the end of the day, but I prefer the former. If I could ignore warnings matching a specific string pattern or warning class and attach tracking an issue to that, I'd do that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions