Alt text; An image showing a meme about open source software. The top part shows an elephant standing on a beach with text reading “The entire world’s IT infrastructure” superimposed on the elephant. Below this is a large, colorful beach ball being supported by tiny ants, with text reading “Unpaid open source devs.” The meme illustrates how the global IT ecosystem heavily relies on open source software that is often maintained by unpaid volunteer developers who carry a disproportionate burden despite their small numbers.
For individual projects the way this usually works is one of the larger companies that rely on the project hires the developer as an employee to maintain the codebase full-time and help integrate it with their internal processes.
Larger projects might form their own company and sell integration & support to other companies (e.g. Red Hat, Bitwarden).
Otherwise you’re basically dependent on donations or government grants.
There’s a Wikipedia article on this subject: Business models for open-source software
And there’s various industry opinions:
Demystifying the Open Source Business Model: A Comprehensive Explanation
How to build a successful business model around open source software
Open Source Business Models (UNICEF course)
I think monetization is easier for user-facing software though, which a lot of this material is written around, and harder for projects like libraries.