CI: getting a list of affected attrnames

How would one get a list of all attribute names (in nixpkgs) that refer to a file?

Or alternatively, to avoid X-Y, the goal is to get a list of affected attrs given some list of changed files. Is this possible?

The naive way I can think of would be to filter the package list by meta.position, which sounds horribly jank and could potentially miss some packages where the file that was modified isn’t the same as the file where its meta information is stored.

We already have CI for (something like) this. “OfBorg eval” posts a link to a file with one (per-platform) attribute per line, listing everything that gets rebuilt by the pull request.

For example this PR https://github.com/NixOS/nixpkgs/pull/326302 posts

ofborg-eval — ^.^! Details

1 Like

Thanks, I’ll look into that further.

This script isn’t perfect at all, but it can give you almost the same locally: https://github.com/NixOS/nixpkgs/blob/8be517b5c9817f2122f27cf8000dda859747adc0/maintainers/scripts/rebuild-amount.sh

Just beware that the computation is pretty expensive. Depending on settings, it needs several minutes and RAM on the order of 30G.

1 Like