With one company I worked for, that was completely impractical. The company thought they were doing the right thing by asking me to declare whatever outside works I might be producing, and they would be 100% fine with that so long as it didn't compete with the company's products.
In practice, that meant every time I was reading some mailing list and would like to reply to something with a small patch, I would first need to contact my company, add that mailing list's project to the set of outside works, write a bit about the project and get approval. It would turn a 10 minute action into a multi-day administrative action involving managers - completely impractical.
The company just didn't have a way to model someone whose idea of outside works was to contribute to countless random projects in small ways every evening, without knowing in advance what those would be.
I tried to talk with the company about this problem, and they weren't interested enough to solve it, and didn't see it as a real problem. They thought I was making waves about something unimportant, and perhaps I was misjudging its importance. Perhaps it would all be fine. But I didn't want to accidentally produce things that the company later decided it had a claim on.
This was a significant factor in my relief when I was made redundant, as I felt free to finally pursue my interests instead of holding back. I didn't know how much it meant to me until then, but the relief made it obvious that this one issue had been seriously weighing me down throughout the employment, and that I should be more mindful of it in future.
If the company had found a good solution to this problem early on, I expect I would have been very much happier working there. Clarity is all that was needed, really.
That was before GitHub. I'm guessing companies are a lot more used to their employees doing small outside contributions like that now. I am still wary of doing so without a clear line. Fortunately, all my recent engagements have contracts that limit what the company is interested in, and exist in a context which recognises and even encourages that outside works will take place.