List packages added or modified by an overlay

Hello. I’m in process of writing some overlays and I find it useful to have packages which the overlays add or modify also exposed as packages in the flake itself. I can then very conveniently use nix build/develop/shell .#packageName during development.

I’d like to automatize the exposing and so far I came up with this abomination added_or_modified_pkgs = builtins.attrNames (overlay null null); which of course breaks on python and similar packages which contains other packages.

Here is my flake: flake.nix · 97cd73d308f0e9d5877227ba501fea8c754ae823 · Michal Ulianko / Nix things · GitLab
nix flake show now lists two packages for each arch: dotter and cq/python3 and I’d like to have something like cq/python3/clang_10.

I know that this does not have completely generic solution. One can not for example recursively compare vanilla nixpkgs and nixpkgs with an overlay without triggering an evaluation of all packages.
But perhaps somebody can recommend me some already writtern convenience utils or tell me that having both an overlay and its packages as “packages” in a flake is a wrong thing :smiley:

Thanks

I’m afraid going further than your trick is not possible in a clean way. One could theoretically also capture the overlays provided for sub package sets, such as python3.pkgs, by writing something that polyfills the used functions (e. g. python3.pkgs.override). However, this approach would mean maintaining a somewhat comprehensive polyfill, as the sub package sets almost all have a (slightly) custom interface.

The generic way would indeed be to compare the drvPaths of all attributes to a vanilla version of nixpkgs, but this is quite expensive (and requires some care when implementing).

At the moment, I’d either re-expose everything added and changed at the top-level and use your trick or keep a list manually.

1 Like