As seen here and here, the Ansible Core package depends on Ansible.
This is weird, because it is generally expected to be the other way around. Ansible is supposed to be a distribution of Ansible Core + official collections. But with NixOS, those collections are always available for Ansible Core. That was unexpected to me.
I’ve searched through blame and found how this happened, but couldn’t find why. I’m curious…
This isn’t really discoverable for users, so I made the swap.
In general ansible in nixpkgs needs more maintenanence, since it should probably accept all kinds of collections, which I’m not sure it currently does.
The code you wrote is what I was expecting to see in nixpkgs: one ansible-core derivation, and another ansible derivation which just does the thing you did in the overlay. It can be done without an overlay, right?
The complicated part is that sometimes collections are not python packages, but are installed through Ansible Galaxy instead. And there are roles which equally are supposed to be installed like that too, but have a slightly different logic.
IMHO it would make sense to have something like ansible-core.withCollections, ansible-core.withRoles and ansible.withPackages (which would be basically python3.withPackages). I guess all of them should be chainable.
I removed myself from ansible maintenance, because I couldn’t find time to deal with that.
For work I now use direnv, a shell.nix with a shellHook managing the environment with pip (requirements.txt) as well as ansible-collection (requirements.yml), which draws a bridge to a setup that my colleagues can also use.