You don't need to set them as sbt launcher will know their values already.
Can these be set as environment vars or do they need to be in each build.sbt?
If you'd like to change them, they should become part of the command line to start the sbt launcher - they're Java's system properties and are set as other Java properties. They are not build settings. There's even no easy way to set them in build.sbt
.
If they're environment vars, would they be sbt.boot.directory and sbt.ivy.home?
No. They are not environment variables.
There's nothing really specific to sbt about setting the Java system properties - just think about sbt as a Java application that happens to read the system properties and defaults when they're not.
If you're new to sbt, you'd be better off forgetting about the Java system properties for now. You just need to remember that sbt's global configuration directory is ~/.sbt
while ~/.ivy2/
is for Ivy stuff. That's enough to get going with sbt.
Is it better to set them in each build.sbt and possibly also as environment variables?
Given that you cannot set them in build.sbt
(it'd be too late in the process of setting up a build from sbt launching process' perspective) and they are no environment variables, the question in the current form has no sensible answer (perhaps a simple "No, it is not" could make sense at all).