But larger packages like texinfo are part of bootstrap and thus it triggers rebuilds for most packages on linux. rebuild-amount.sh output is not useful. Good first approximation would be to find all derivations that mention texinfo in it’s package inputs.
I came up with the following hack to find candidates:
# cat revdeps.nix
# use as:
# import ./revdeps.nix "texinfo" pkgs lib
revdep: pkgs: lib:
let isDrv = v: (builtins.tryEval v).success && lib.isDerivation v;
isDrvName = name: d: isDrv d && lib.strings.hasInfix name d.name;
getList = a: s: if builtins.hasAttr a s then builtins.getAttr a s else [];
matchedPackages = lib.filterAttrs (n: v: isDrv v
&& builtins.any (isDrvName revdep)
(getList "buildInputs" v
++ getList "nativeBuildInputs" v))
pkgs;
in
builtins.attrNames matchedPackages
That is almost directly usable for nix build -f . <pkgs>.
I think it lacks support for non-toplevel packages like elpa and friends. Do we have something slightly more generic and probably more maintained that covers similar use case? What do you use for similar purposes? Worth adding to maintainers/scripts/?
I don’t know of a current way to do this, and I would find this very useful!
If I understand correctly, your code looks at nativeBuildInputs and buildInputs, but it won’t see interpolated references (e.g. cp ${texinfo}/bin/* .) or references in other attrs (e.g. propagatedBuildInputs). Maybe a more robust way to do this, would be to check the entire text of each derivation for matches.
You can do nixpkgs-review wip and this will attempt to rebuild all packages which were changed by your changes.
You can also see all downstream dependencies by doing nix-store --query --referrers, however, this will only show you the packages which exist on your nix store and refer to the package; there’s the possibility of a package not being reflected in this (although it’s almost instant to do)
I think what @trofi is looking for is a way to query the “direct” referrers. For small changes building all transitive referrers is easy, but for huge staging patches it would be handy to be able to look at just the “direct” referrers.
If I understand correctly, your code looks at nativeBuildInputs and buildInputs, but it won’t see interpolated references (e.g. cp ${texinfo}/bin/* . ) or references in other attrs (e.g. propagatedBuildInputs). Maybe a more robust way to do this, would be to check the entire text of each derivation for matches.
That’s a great point! texinfo was a simple depend that did not seem to use such tricks. linuxHeaders is one of those. The hack reports no direct users, but we have quite a few ${linuxHeaders} injections.
It’s far from complete (for example it misses glibc due to different parameters being passed to linuxHeaders on bootstrap), but is a good starting point for initial tests. Slightly less involved example:
It calculates the drv outpath of almost every package in all-packages before and after a change is made and diffs the two.
It is very slow though.
This is what I copied for nixpkgs-update. I was thinking of moving to something simpler like some of the examples above because a majority of time updating is spent calculating outpaths. Thanks for the ideas!
drv’s reference the build closure, so there’s going to be many more dependencies which may not use the package at runtime.
This “only” references derivations which are at the top-level or have the “_recurseForDerivations = true;” flag on a package set. So it’s not a complete list of all possible packages, but probably as close as you can get realistically.