The developers of Apple have released the Darwin source code for macOS 10.12 Sierra. Darwin comprises of the kernel, BSD portions, drivers, and developer tools. The source code can be found at the links provided.
The lowest layers of macOS, including the kernel, BSD portions, and drivers are based mainly on open source technologies, collectively called Darwin. As such, Apple provides download links to the latest versions of these technologies for the open source community to learn and to use.
Source code: https://opensource.apple.com/release/os-x-1012.html