Ethical?
Many times over yes. In the same way it's ethical for you to take the skills you learn at the current employer and use them at your next job, it's ethical to use your skills in your free time, however you want to
Legal?
Maybe. While it's not up to the company to control what you do with your free time, it's standard for the company to have NDA and non competition agreements as part of your contract. You also will likely not be allowed to use any kind of proprietary information and patents etc... developed and owned by your current company in your work, as well as, very obviously, you'd have to start from scratch when writing the code. It's neither ethical, nor legal, to steal from your current employer.
Notes
- I am not a lawyer. Ask a lawyer for advice regarding your contract.
- I assume you're a regular employee. A shareholder or co-owner of the company has other obligations
- This may not be obvious, but working on the OSS alternative while working for your current employer is a bad idea. I assume you're talking of developing it after the end of your employment
- How you do it is just as important as what you end up doing. The professional way to do this is to do it openly - to let your current employer know what you're doing.
- Consult a lawyer, especially regarding the nitpicky details of NDA and non compete agreements. The enforceability, legality, applicability and various consequences of breaking NDA, non-compete and other agreements is extremely context specific; it varies between states, countries, industries, etc... Also be aware of the potential cost of litigation - there are many corner cases where you can be forced to pony up legal fees just to prove your point, costs which might be debilitating even if you've done nothing wrong