How can I stop mongodb being build from source very frequently when I upgrade nixos?
Not the answer you’re looking for… but see Petition to build and cache unfree packages on cache.nixos.org - #7 by vcunat
From what I can find, mongodb is provided in 2 versions, 3.x and 4.x. The former is using AGPL and considered a “free” license, the latter is using a license that isn’t considered “free” and therefore can’t be built by hydra.
As the latter license seems to allow redistribution though, it might be built by hydra again once some things and discussions have been settled. In the thread @aanderse linked are some links to GitHub issues, which again link to other issues.
I skimmed it yesterday and the topics TL’DR seems to be “it’s not as easy as it sounds for legal and ethical reasons”.
PS: A kind-of workaround would be to use a version controlled configuration with pinning and only update the pins through CI, let it build the config and then upload the built system to a (private) cachix instance or a self hosted substitute.
For anyone else that stumbles across this older topic (like I did), one option is to pin the mongodb version. I did that in my flakes setup.