Because the collections would need to be installed into the same python environment that ansible-core exists in, or the libraries will not be found.
If both packages where entirely separate this would not work, and I think users would be surprised:
{ pkgs
, ...
}:
{
environment.systemPackages = with pkgs; [
ansible # or python3Packages.ansible-core
python3Packages.ansible-collection
];
}
Instead you’d have to override ansible-core like this to inject the collections package.
{
nixpkgs.overlays = [
(self: super: {
ansible = python3.pkgs.ansible-core.overridePythonAttrs (oldAttrs: {
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [
python3.pkgs.ansible-collections # plus potential overrides on the collections package
];
});
})
];
}
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.