This. I have it in my contracts or a rider if they don't like amending the contract itself. I write code, when I stop working for you for the day I still write code. Yes it's lucky that I can get paid to do the main thing I enjoy, but you aren't paying me for the stuff I do off the clock. I will let you know about any major pieces of software I write (not like twenty line Python scripts for managing my music) and if you detect a conflict that's the moment to object, if you do then I'll work on something else, otherwise I own it outright and that's fair.
Good employers don't want to abuse you, and in turn don't want to get abused, drawing a line is something they can understand and their lawyers can get their heads around. "This is mine, this is yours".