We obviously aren't just subject to the whims of our environment, we make choices and can decide things, but after a lot of reading on AI / neuroscience, and just being alive longer I am becoming convinced the environment and your perception of it is the single biggest factor. It goes beyond happiness toward fundamental outlook and beliefs.
I would argue that you have done that trickery of your mind I mentioned. Self awareness, recognition of meta-thought patterns, alignment of other systems in your brain with your "ego" or consciousness. Those tools let you make choices that are theoretically not possible if your will is entirely depleted and you are subject to the whims of lower level systems. It is in this area where radicalizing life style, having big goals and ideas that excite you and, say, require physical health, or really learning deeply on some topic, can pull you through. You have tricked or overridden those underlying systems that would push you towards a lazy or consumptive habit towards a more generative habit. The big goal may require high degree of physical health, or deep knowledge on some topic. It really helps to be able to achieve it in small, observable chunks (getting a little fitter every day/week, learning a little more, etc.).
There is clearly something to the whole ego depletion concept, it is, at least, a helpful mental model to observe the act of becoming mentally tired and acknowledge it. I really do believe in decision fatigue. I have tried to (radically) cut decisions out of my life (what to wear, etc.). So that I can make decisions about the most important things, my work goals, family goals, big picture stuff. Despite ego depletion being a tricky mental model, it is obvious everyone gets tired. Most good developers, even after years of consistent hacking will still only have 3-6 deep hours in them on any given day. That's it. Only (rather extreme, IMO) outliers can, say, code intense for 12 hours with the same quality of the first few. Most of us require sleep, mental digestion, and problems get solved somewhere in the depths of our mind outside of the view of our consciousness. Then we return and the problem is solved in the shower or in flashes of "insight" (which would just be whatever system in your brain finally getting the message through to your consciousness... the pieces finally got connected).
How does this happen? We have no will, yet in our sleep our brain is clearing out memories and getting our systems tuned up for the next go. Is this "actual" thinking? Or is it really the equivalent of compacting a database so that the higher level systems can now just see more clearly? It is super complex. There are so many questions about the way deep thinking and problem solving works, how we create things that we set out to create, overcoming obstacles. Ego depletion is like a local maxima or tactical part of the bigger picture of getting what you want and building / solving.
So what is will power? Is there ego that we deplete? I don't know, but I know straight up higher level conscious thinking about every decision to achieve a desired outcome are practically impossible for most people. That means other systems and processes work as the primary agents of change in our lives, and willpower is at best a passenger giving you advice and helping you out once in a while.
There is, but most people don't understand how it works. According to recent neurological studies, it's a lot like a muscle. In the long term, you exercise it and it gets stronger. In the short term - and this is the important part - it can become depleted. If your work requires a lot of will power (including focus, discipline, initiative) then you'll have little left for other parts of your life.
This is really what I think a lot of people mean when they say they come home tired. They're not physically tired, they're not low on energy, but they are low on will. Therefore they tend to settle for the easy or familiar, such as watching Netflix instead of exercising or eating junk instead of cooking real food. I can often feel the pull myself, but the fact that I understand and recognize what's happening helps me resist/manage it.