I had the same problem. Using f.lux[0] and writing down all the problems (programming related or not) that occupy my thoughts on a notepad which lives next to my bed, just before going to sleep totally eliminated the issue.
I recommend Redshift instead, which is a free software alternative: https://github.com/jonls/redshift