Anybody who got NixOS running? Any problems one should expect when trying to?
Yes, NixOS is working, and most packages are precompiled for aarch64. If you manage to install the Nix tools onto the Debian image then you can build and installer image, see nix-community/hardware-mnt-reform.
Iâve got NixOS running on my MNT Reform right now. Since the original project seems dead, given the unaddressed pull request from March and the fact that Discourse says emery hasnât logged in since July 2021, I went ahead and forked it: lykso/hardware-mnt-reform - hardware-mnt-reform - Codeberg.org
I still want to rewrite the README to make it a little clearer, but as of now you should be able to get NixOS 23.05 running with Linux kernel 6.1.59 and the 2023-10-18 uboot revision from MNTâs repository by following those instructions with very little need for improvisation. (I.e., some of the commands have to be run as root or they wonât work, and I remember having to use the --extra-experimental-features "nix-command flakes" flag with nix a few times as well.)
This fork does not support modules other than the i.MX8MQ, and maybe the i.MX8MP, as far as I can tell. Adding support for other modules ought to be fairly simple, though. In theory it should be simply a matter of getting their kernel configs and device trees in place. My fork currently uses an old version of the kernel config that I think will only work with the i.MX8MQ and maybe the i.MX8MP (I donât have a Reform Pocket to test it with).
Finally, it builds the kernel from source, which takes at least 6 hours on my machine. Plan accordingly.
Edit: Audio works now, but the README still needs a rewrite.
Iâm very interested by a NixOS image for my Reform.
@lykso I tried to build one from your repo, but I got interrupted at the vmlinuz step, the makefile couldnât find the dtb. Iâll retry later with a swapfile to see if performance can be helped during the build process.
Yeah, it took me a 12GB swap file to get past that error, IIRC.
I got the SD card to work ![]()
Do you have any particular advice to boot an encrypted nvme partition from a SD card? I want to boot other partitions without toggling the dipswitch everytime I want to boot something else ![]()
The DIP switch of the imx8mq only chooses where u-boot is loaded from.
But irrespective, whether u-boot is loaded from emmc or sd-card, the default boot order is baked into the u-boot binary remains the same.
I wrote some notes on the boot process down here:
The way that Debian boots a system on encrypted nvme, is to load an initramfs which then knows how to decrypt and boot nvme. The initramfs is loaded by u-boot from the first partition of the sd-card (tried first) or from emmc (tried second). The reform-boundary-uboot fork provided by MNT does not have support for loading data from nvme. There are efforts to rebase the necessary patches for imx8mq to upstream u-boot and I think upstream u-boot should be able to access nvme but I might misremember this and you should ask those working on that about details. One possible contact would be bluerise in the reform irc channel.
Ah I see: if I toggle it on, it will look for /boot/extlinux/extlinux.conf on the eemc, and if I insert my 9front SD Card, it will find the /boot.scr first and go from there.
Thanks for the doc josch!
EDIT: Worked as I expected it to work. Iâll try the NixOS install later and report back if i run into issues. btw @lykso are you on IRC?
EDIT: Install went good, Iâm very thankful for your work ![]()
Oh wow, this is huge! Iâm waiting for my pocket to arrive but as a long time NixOS user on x86 Iâd really love to use it on the pocket reform as well.
Do you think many changes are needed to make this work on the pocket reform?
I think you can reuse the kernel and lpc kernel module. I donât think you need uboot, as it already ships with it.
What probably needs adjusting is boot.initrd.availableKernelModules and boot.kernelParams. And asound state if audio is not working. For some reason the default config has no output volume.
That is basically all that is configured specifically for the reform.
With guix, it should be possible to create a guix system image on other distros using guix system image .... Does something similar exist for NixOS? Iâm interested in creating a bootable NixOS image for the Reform on Debian GNU/Linux.
The Readme has an example of an readonly image with the bootloader. This should be buildable on non NixOS systems. Have a look a installer.nix. There everything like the bootloader is put into the image. Here you could switch from squashfs to e.g. ext4. sd-image.nix might also be useful.
I tried building the installer image from the current stock Debian on a RK3588 Pocket Reform with nix 2.32.2, but it wouldnât build using unstable nixpkgs due to the error below. It seems to be complaining that the kernel patches donât have a name attribute? Might be some change in unstable.
$ nix --extra-experimental-features nix-command --extra-experimental-features flakes build .#
error:
⊠while calling the âderivationStrictâ builtin
at «nix-internal»/derivation-internal.nix:37:12:
36|
37| strict = derivationStrict drvAttrs;
| ^
38|
⊠while evaluating derivation 'nixos-image-25.11pre-git-aarch64-linux.img'
whose name attribute is located at «github:nixos/nixpkgs/2fb006b87f04c4d3bdf08cfdbc7fab9c13d94a15?narHash=sha256-kJ8lIZsiPOmbkJypG%2BB5sReDXSD1KGu2VEPNqhRa/ew%3D»/pkgs/stdenv/generic/make-derivation.nix:544:13
⊠while evaluating attribute 'buildCommand' of derivation 'nixos-image-25.11pre-git-aarch64-linux.img'
at «github:nixos/nixos-hardware/7467f155fcba189eb088a7601f44fbef7688669b?narHash=sha256-rNHeoG3ZrA94jczyLSjxCtu67YYPYIlXXr0uhG3wNxM%3D»/mnt/reform/rk3588/installer.nix:193:11:
192| inherit (config.installerImage) compressImage;
193| buildCommand = ''
| ^
194| mkdir -p $out/nix-support $out/installer-image
⊠while evaluating the option `system.build.toplevel':
⊠while evaluating definitions from `/nix/store/xjjq52iwslhz6lbc621a31v0nfdhr5ks-source/nixos/modules/system/activation/top-level.nix':
⊠while evaluating the option `assertions':
⊠while evaluating definitions from `/nix/store/xjjq52iwslhz6lbc621a31v0nfdhr5ks-source/nixos/modules/system/boot/kernel.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: attribute 'name' missing
at «github:nixos/nixpkgs/2fb006b87f04c4d3bdf08cfdbc7fab9c13d94a15?narHash=sha256-kJ8lIZsiPOmbkJypG%2BB5sReDXSD1KGu2VEPNqhRa/ew%3D»/pkgs/os-specific/linux/kernel/build.nix:564:69:
563| else
564| " (with patches: " + lib.concatStringsSep ", " (map (x: x.name) kernelPatches) + ")"
| ^
565| );
I was able to get further by using nixos-25.05:
$ cat flake.nix
{
inputs.nixpkgs.url = âgithub:nixos/nixpkgs/nixos-25.05â;
inputs.nixos-hardware.url = âgithub:nixos/nixos-hardwareâ;
inputs.flake-utils.url = âgithub:numtide/flake-utilsâ;
outputs = { self, nixpkgs, nixos-hardware, flake-utils, ⊠}:
flake-utils.lib.eachDefaultSystem (system:
rec {
packages.default = packages.installer;
packages.installer = (import â${nixpkgs}/nixosâ {
configuration =
{ config, ⊠}: {
imports = [
â${nixos-hardware}/mnt/reform/rk3588/installer.nixâ
];
system.stateVersion = "25.05";
};
inherit system;
}).config.system.build.image;
});
}
However this now gives an error when building mnt-reform-firmware-rk3855-dsi.drv (../rkbin/tools/boot_merger: cannot execute binary file: Exec format error). I am pretty sure this is due to boot_merger being compiled for x86_64 as discussed here: Building MNT Reform RK3588 U-Boot
I ran out of time to troubleshoot this but based on what Iâm seeing, in order to build on a non-x86_64 machine, I guess that U-Boot (and therefore the install image) will need to be built using qemu or cross-compiling? Is this correct?
Thatâs correct. I set --system=aarch64-linuxwhen running nix build and have my host machine configured with the below config:
boot.binfmt.emulatedSystems = [
âi686-linuxâ
âaarch64-linuxâ
];
nix.settings.extra-platforms = config.boot.binfmt.emulatedSystems;
nix.settings.system-features = [
ânixos-testâ
âbenchmarkâ
âbig-parallelâ
âkvmâ
];
This will then enable your system (I believe this also works if you are not running NixOS, as it configures the Nix daemon behavior) to do emulated builds (warning: slow!) via qemu. Once you get NixOS booted you can build on the device which is (depending on your x86_64 hardware) faster than doing an emulated build. The emulated build support in Nix comes in real handy for this kind of stuff though!
I think this would work for running the build from an x86 machine, but Iâm hoping to get the build running from the Pocket itself, which is already aarch64, using nix on MNTâs Debian image. I added the following to /etc/nix/nix.conf to allow building for x86 to try and work around the issue with the U-Boot build:
experimental-features = nix-command flakes
extra-platforms = i686-linux x86_64-linux
system-features = [ âkvmâ ]
But this doesnât help, I get the same error. My guess is the build works from x86 because it is able to execute the x86 binary boot_merger natively, despite building the package for an aarch64 target?
Ah I missed that detail, sorry! In Nix unless you specifically mark a derivation as being for a specific system the emulated build stuff wonât know the supported build system needs to be emulated. Unfortunately a bunch of the Rockchip stuff needed to build boot binaries is distributed as x86_64 executables. They can be run with qemu-user-static but the derivation would need to be set up for that - likely something @leif can look at!
Thanks, I thought that might be the case but I havenât needed to deal with cross-compiling before. Fortunately it seems to be building fine on an x86 NixOS machine.
I assume this issue will also prevent rebuilding U-Boot from an installed NixOS system on the Reform/Pocket Reform, if and when there are changes. Based on the thread I linked previously, per josch it sounds like the best solution is to improve the MNT U-Boot build scripts, as this would fix the build issue both here and on non-Nix aarch64 systems. I will look into it eventually if nobody else does.
We fixed that recently. It turns out that the created u-boot blob is bit-by-bit identical independent on whether or not that proprietary x86 executable (called boot_merger) is run. See Refactor build.sh (c75c1933) · Commits · Reform / MNT Reform RK3588 U-Boot · GitLab
Is any other change than the above needed? I recently did a lot of refactoring and would like to tag a new u-boot build for rk3588 soon. If you want anything else to change, now is the time to get things in. ![]()
Thank you! That should be all that is needed, will just need to update nixos-hardware/mnt/reform/rk3588/uboot.nix at master · NixOS/nixos-hardware · GitHub to point to the latest tag when it is ready.