> This U-Boot version is packaged in the [`u-boot`] directory.
[`u-boot`]: ./u-boot
Provided you have a way to build Nix derivations for `aarch64-linux` (like a remote builder, [binfmt emulation], or you're building it on the phone itself), just run `nix-build u-boot/build.nix`.
> Even though I've tested this myself, I can't guarantee that this will not render your device unbootable.
> Proceed with caution.
>
> If it does not work, your best bet is to follow the advice here, which will flash U-Boot build by upstream: https://forums.puri.sm/t/can-someone-with-serial-console-access-try-nixos-kernel-on-librem-5/19121/27
- if you're running an existing OS on the Librem 5, run `# result/bin/u-boot-install-librem5 /dev/mmcblk0` on the device itself
- if you've mounted the Librem 5's internal MMC via Jumpdrive, run `# TARGET="$(pwd)/result" result/bin/u-boot-install-librem5 <path to Librem 5's MMC>`
- if you want to flash u-boot manually (not recommended!), use `dd if=/dev/zero of=<path to MMC> bs=1024 count=1055 seek=2` and `dd if=result/uboot.imx conv=notrunc of=<path to MMC> bs=1024 seek=33`
Now you can create filesystems on those partitions.
I went with a bootable `ext2` partition for `/boot`, and one `f2fs` partition for `/`. You can use any filesystem supported by NixOS (like `ext4` or `zfs`) for `/`, but `f2fs` might improve your eMMC lifespan as it supports wear leveling. Note that `f2fs` does not have a journal, so filesystem corruption can happen if the battery runs out for example.
Start it up and you should be booting straight into your NixOS installation.
## Updating u-boot
Once you're running NixOS with this module, you can run `# u-boot-install-librem5 /dev/mmcblk0` any time to reflash the most recent version of u-boot from the running NixOS.
> **Warning**
>
> While I (@999eagle) will test u-boot updates on my own device before updating this repository, flashing u-boot may still render your device unbootable!