This always is made to sound easy but I can count on one hand the number of "habits" I successfully built around things I didn't want to do. Getting up in the morning to go to work vs skipping morning classes back in college is the main one. But it's still unpleasant and I still just do it because that's how I get paid, not because it's a "default." "Not eating as much junk food" was a slightly easier one - because you don't buy it once when doing groceries and then it's not available during the week - but exercise or other un-fun decisions you have to make every day? Nope.
I agree with both your sentiments actually. A lot of the times, I do not like going to the gym on certain days. Like Friday morning leg days - I do not like it to this day. But I go anyway - why? Because friday 7 am is leg training day and it's like a habit/ritual at this point. I guess that's the aspect of discipline I like.
Similar with moving away from my home office at 7pm. I have just trained myself to not go in there after 7pm, resisting the urge to check Slack or anything. I'll get a call if anything blows up, so it's become a habit at this point to not even glance over to my home office after 7pm
I started having more success with setting up habits after reading up on habit formation science.
The junk food example is one aspect on frequency and availability. There are other aspects to habit formation like understanding how habits are triggered (by system1) and creating or removing triggers, how location can play into habit triggers, how habits can be more easily bootstrapped on top of existing habits, etc
I liked the book Good Habits Bad Habits which is more science based than the pop stuff but I would guess that Atomic Habits covers similar stuff.