You can always use something like the Nix package manager[1] to install Firefox, Git, and Emacs, and leave the rest to Ubuntu. Save for Firefox, which I install from a tarball and use auto-update, I have been doing that with Debian stable on my laptop, and it works well.
So they will run on X11 that's from Debian stable? Will for example Emacs read your .Xresources from your home directory?
I've been eyeing this setup with Guix but I have some concerns. If I install a newer version of GCC through Nix/Guix, can I run update-alternatives on it?
Yes, it will run on your system X11 obeying your .Xresources. I have never tried using update-alternatives to replace the system-wide GCC (or any piece of software for that matter).