Find source of a deprecation warning

Hi, lately I’m getting a lot of warnings when I do nixos-rebuild switch --flake, such as

They all seems to come from outside of my repo, meaning in the flake inputs. What is the best approach to find exact source of the warning, so I can fix it or open some issues?

(edit: please note that on the screenshot update is just alias for nixos-rebuild switch --flake .#host)

1 Like

You can try adding the --stacktrace flag to potentially get more information about where those deprecation warnings are coming from. The difficulty here is that stack traces produced by Nix can often be hard to comprehend; Especially when it involves Nixpkgs.

An alternative method (and what I would do personally) is to grab a clone of the Nixpkgs repo, check out the Nixpkgs commit referenced in your flake.lock, and then git grep for those deprecation warnings. That should point you to the exact *.nix files. Ex: git grep "cartesianProductOfSets instead".

thanks, I was hoping to avoid using grep for that

Set NIX_ABORT_ON_WARN=true, that way you can get stack traces.

This does of course not work with flakes/pure evaluation.

The majority seem to come from a recent change in the module system: lib/modules.nix: Make some functions private · NixOS/nixpkgs@3633bf9 · GitHub

What are the inputs to your flake?
And are you using any of these module system functions directly?

1 Like

For flakes, pass the --impure option when you set environment variable NIX_ABORT_ON_WARN=1.

Yes, but we also need to be aware that --impure does do so much more than just reading exactly the one environment variable you actually want to be read.

All of a sudden ~/.config/nixpkgs/overlay.nix is considered, or a config.nix in the same folder…