As part of my bachelor’s thesis, I created a full-source bootstrap chain for NixOS.
It consists of a modified nixpkgs fork that I modified to bootstrap the package set based on the bootstrap chain from Aux Foundation.
Additionally, there is a larger bootstrap chain based on live-bootstrap, that builds a full NixOS installation, including the Nix package manager itself from source.
While the project is not in a state that it could or should be merged into nixpkgs as-is, I hope that it may serve as a proof of concept and as a starting point for extending the minimal-bootstrap package set already present in nixpkgs.
Lastly, a huge thank you to @jakehamilton and @emilytrau for their work on the Aux Foundation bootstrap, without which this would not have been possible!
I think it would be great to compare that with what you did — I am sure there are things that are better in one than the other. And I think it is much easier to edit a thing that works than complete the first draft, so rather than this being an “oops, all done!” moment, this can be a “now is the perfect time to start improving it much more rapidly!” moment.
Rooting nixpkgs’s stdenv in hex0 probably cuts out the detour into Aux Foundation that builds bootstrap-tools, but I think the bulk of the work in this thesis remains relevant. NixOS no longer supports i686 and live-bootstrap currently only bootstraps into i686, so the bootstrap has to build an i686 version of nix, get an x86_64 Linux kernel running, and then replace nix with an x86_64 version before building the NixOS toplevel, and all of that is probably still necessary.
NixOS does support i686 still, as in you can build packages for it. It’s just that maintainers do not guarantee fixes for i686, nor are packages cached for it anymore. You can still use it to build i686 packages, and in fact the new minimal-bootstrap merged into nixpkgs today(which is from a user perspective extremely similar to aux foundation) was originally i686-only, but also supports x86_64 as well.
I would definitely like to see live-bootstrap for 64-bit platforms, but also following a discussion I had the 100% pure live-bootstrap in nixpkgs will probably not happen for the simple reason that we want to support more than x86, including some very experimental exploratory work into aarch64 and riscv64 support in the minimal-bootstrap set, which would allow full-source bootstraps on those platforms as well.
I tried to run the bootstrap in qemu, and while it got all the way to a running Linux system, it failed to build the first nixpkgs:
mount: dev already mounted or /dev busy
mount: according to mtab, devtmpfs is already mounted on /dev
Creating 32GiB swapfile at /nix-build-swap to hold build data
32768+0 records in
32768+0 records out
34359738368 bytes (34 GB, 32 GiB) copied, 94.0459 s, 365 MB/s
Setting up swapspace version 1, size = 33554428 KiB
no label, UUID=711b50bc-61c0-461b-902f-8e93b9a0a09d
[ 1028.328985] Adding 33554428k swap on /nix-build-swap. Priority:-2 extents:280 across:43913604k FS
warning: can't open /etc/fstab: No such file or directory
Remounted /tmp with size 32GiB and 4M inodes
/proc /steps
grep: ./29004/status: No such file or directory
/steps
nixpkgs: beginning build using script pass1.sh
nixpkgs: getting sources.
nixpkgs-bootstrap.tar.gz: OK
/steps/nixpkgs/build
nixpkgs: unpacking source.
nixpkgs: preparing source.
nixpkgs: configuring source.
nixpkgs: compiling source.
accepted connection from pid 29177, user root (trusted)
accepted connection from pid 29182, user root (trusted)
this derivation will be built:
/nix/store/i6ncqyf4g7q6yw2qyx7j1sc6yq9n51xf-nixpkgs.drv
building '/nix/store/i6ncqyf4g7q6yw2qyx7j1sc6yq9n51xf-nixpkgs.drv'...
unpacking 1 channels...
accepted connection from pid 29193, user root (trusted)
nixpkgs: install to fakeroot.
nixpkgs: postprocess binaries.
nixpkgs: creating package.
nixpkgs: checksumming created package.
nixpkgs_0.tar.bz2: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match
/init: line 3: /bootstrap.cfg: No such file or directory
/init: line 4: ./env: No such file or directory
/init: line 5: ./helpers.sh: No such file or directory
[ 1045.416819] Adding 2097148k swap on /swapfile. Priority:-3 extents:18 across:2269180k FS
@endgame I’ve already fixed that, just update the live-bootstrap submodule. It is because I had to change the download URL for the nixpkgs tarball from the git forge I developed this on to GitHub, leading to a changed hash