I'll offer a slightly different suggestion. I see many people, once they get comfortable with a particular distribution, fall into a cycle of perpetual changeover. They install a new shiny distro, but they can't get their webcam to work. So they switch. Now the webcam works, but something else doesn't work, and they switch again. (Then they get a job and are restricted to RHEL...). You might get the impression that there's some sort of expert level-up progression of Ubuntu -> Arch -> Gentoo ( -> FreeBSD?), but that's not strictly necessary, and plenty of people get into a trap of learning how to merely use distributions instead of build or change them.
Rather than run around in circles, it pays to really get to know how a distribution that already does most of what you need works. You know Ubuntu well. What I will advocate is to dig into the Ubuntu community and documentation to find answers to the following questions:
- What are the core components of a minimal install?
- How do you configure installed packages?
- Where can you find the corresponding source to an installed binary package?
- What is the complete path source code takes to arrive on your computer as a binary?
- How do developers build binary packages?
- How can you rebuild a package from source?
- What steps should be taken to upgrade package source versions?
- What are the best practices for building and installing programs?
- Where is the documentation for building and configuring programs stored?
- Who reviews and approves changes to the distribution itself?
Finding the answers to these questions will be valuable no matter what distribution you decide to investigate. You may even already know the answer to some of these.
In the case of Ubuntu, many of answers will be similar to Debian. For example, best practices in packaging are codified in the Debian Policy Manual.