I've always thought that inspiration came out of nowhere and there are some times when it does, when the muse strucks. But those times don't come around often and if you are just waiting for them you will never write consistently. There is no secret to it. It is just the discipline of sitting down to write that get you started and keep going until you get a flow of ideas and you can't stop anymore. You just need to push through that initial bit of resistance.
The most difficult part is to find that time. It doesn't really matter for how long. Although it needs to be enough to sit down without distractions and write something coherent. If you know you are going to be busy in 5 minutes, better pick a different time to write.
When I do I love to put a 10-hour version of 'Time' from Inception OST as the background to keep the rhythm going. It's relaxing, it sets up the pace and let me focus on the words since it doesn't have any lyrics to follow. It simply puts me into the flow.
I used to do the same for programming, but I found that music works way better for writing than it does for programming (for me) so lately I prefer to program with little noise as possible.