I’m writing a Nix intro for some colleagues. While trying to run a simple filter on nixpkgs.*.meta.maintainers I run into the dreaded “Please be informed that this pseudo-package is not the only part of Nixpkgs that fails to evaluate.” error. How can I filter on maintainers without rebuilding each package, or is this just not possible?
The two things you probably need are 1) builtins.tryEval to detect errors thrown by nixpkgs, and 2) the or syntax for something like pkg.meta.maintainers or [] for eval errors that aren’t caught by tryEval such as accessing an attribute that doesn’t exist.
This returns true for every package that evaluates, not just the ones that fit your desired filter. You need something more like let x = builtins.tryEval whatever; in if x.success then x.value else someDefault
Thanks! I’ve amended to robustEelcoMaintains = pkg: let result = builtins.tryEval (eelcoMaintains pkg); in if result.success then result.value else false (assuming Eelco doesn’t maintain any broken packages ). It still crashes, tho.
I ran it and the failures come from the packages that eelco maintains that are broken for other reasons, like being unfree, insecure, or just actually marked broken. If you don’t do builtins.attrValues pkgs and use pkgs.lib.filterAttrs instead of builtins.filter, you then get back an attrset that you can use builtins.attrNames on to at least see the attribute names of the packages that match the filter