NixOS on ARM: Difference between revisions

imported>Zarelit
e"NixOS installation & configuration: Remove HTML-encoded quotes from config
imported>Fadenb
m replace html entities
Line 3: Line 3:
Note: Everything on this page is work-in-progress and not totally tested yet!
Note: Everything on this page is work-in-progress and not totally tested yet!


Installation images and miscellaneous boot files for ARM devices are built & hosted by '''@dezgeg''' at http://nixos-arm.dezgeg.me/installer.
Installation images and miscellaneous boot files for ARM devices are built & hosted by '''@dezgeg''' at http://nixos-arm.dezgeg.me/installer.


Also, a binary cache containing a subset of the unstable channel is hosted at http://nixos-arm.dezgeg.me/channel (signed with '''key''' <code>nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%</code>).
Also, a binary cache containing a subset of the unstable channel is hosted at http://nixos-arm.dezgeg.me/channel (signed with '''key''' <code>nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%</code>).
Line 84: Line 84:
The amount of memory (-m 512) should be at least 512 megabytes, or you will get all sorts of funny behaviour if/when U-Boot tries to access nonexistent RAM. Unfortunately, the maximum amount of memory is limited to 1024 megabytes.
The amount of memory (-m 512) should be at least 512 megabytes, or you will get all sorts of funny behaviour if/when U-Boot tries to access nonexistent RAM. Unfortunately, the maximum amount of memory is limited to 1024 megabytes.


== NixOS installation &amp; configuration ==
== NixOS installation & configuration ==


The installation image is actually a MBR partition table plus two partitions; a FAT32 /boot and a ext4 root filesystem. The image is designed such that it's possible to directly reuse the SD image's partition layout and &quot;install&quot; NixOS on the very same SD card by simply replacing the default configuration.nix and running nixos-rebuild. Using this installation method is strongly recommended, though if you know exactly what you're doing and how U-Boot on your board works, you can use nixos-install as usual. To help with the SD card installation method, the boot scripts on the image automatically resize the rootfs partition to fit the SD card on the first boot.
The installation image is actually a MBR partition table plus two partitions; a FAT32 /boot and a ext4 root filesystem. The image is designed such that it's possible to directly reuse the SD image's partition layout and "install" NixOS on the very same SD card by simply replacing the default configuration.nix and running nixos-rebuild. Using this installation method is strongly recommended, though if you know exactly what you're doing and how U-Boot on your board works, you can use nixos-install as usual. To help with the SD card installation method, the boot scripts on the image automatically resize the rootfs partition to fit the SD card on the first boot.


Use this as a template:
Use this as a template:
Line 123: Line 123:
   # swapDevices = [ { device = "/swapfile"; size = 1024; } ];
   # swapDevices = [ { device = "/swapfile"; size = 1024; } ];
}</syntaxhighlight>
}</syntaxhighlight>
Note: the default configuration.nix will contain something like <code>imports = [ &lt;nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix&gt; ];</code> do not include that in your final installation or you will experience interesting problems. It is only for building the installation image!
Note: the default configuration.nix will contain something like <code>imports = [ <nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix> ];</code> do not include that in your final installation or you will experience interesting problems. It is only for building the installation image!


To make the ARM experience slightly less painful, the config template adds <code>nixos-arm.dezgeg.me</code> as a binary cache, which contains a small subset of packages on the unstable channel (though a caution for US users: the server hosting them is physically located in Finland). Note that the binary cache isn't enabled on the prebuilt images, so enable it via the command line when building for the first time:
To make the ARM experience slightly less painful, the config template adds <code>nixos-arm.dezgeg.me</code> as a binary cache, which contains a small subset of packages on the unstable channel (though a caution for US users: the server hosting them is physically located in Finland). Note that the binary cache isn't enabled on the prebuilt images, so enable it via the command line when building for the first time:
Line 131: Line 131:
== Details about the boot process ==
== Details about the boot process ==


On NixOS, all ARM boards use the popular U-Boot as the bootloader and U-Boot's Generic Distro Configuration Concept as the mechanism to communicate boot information (such as path to kernel zImage, initrd, DTB, command line arguments). For a quick TL;DR about the generic distro configuration support: U-Boot is scripted to scan all attached storage devices &amp; partitions and look for a file named <code>/extlinux/extlinux.conf</code> or <code>/boot/extlinux/extlinux.conf</code> (which will be generated by NixOS, just like <code>/boot/grub/grub.cfg</code> is generated on PCs).
On NixOS, all ARM boards use the popular U-Boot as the bootloader and U-Boot's Generic Distro Configuration Concept as the mechanism to communicate boot information (such as path to kernel zImage, initrd, DTB, command line arguments). For a quick TL;DR about the generic distro configuration support: U-Boot is scripted to scan all attached storage devices & partitions and look for a file named <code>/extlinux/extlinux.conf</code> or <code>/boot/extlinux/extlinux.conf</code> (which will be generated by NixOS, just like <code>/boot/grub/grub.cfg</code> is generated on PCs).


U-Boot also provides an interactive shell and the generation selection menu (just like GRUB). However, support for input or display devices varies greatly, depending on the board:
U-Boot also provides an interactive shell and the generation selection menu (just like GRUB). However, support for input or display devices varies greatly, depending on the board:
Line 167: Line 167:


* Add a new derivation for your board's U-Boot configuration, see for example ubootJetsonTK1 in all-packages.nix.
* Add a new derivation for your board's U-Boot configuration, see for example ubootJetsonTK1 in all-packages.nix.
* If your board's U-Boot configuration doesn't use the <code>extlinux.conf</code> format by default, create a patch to enable it. Some C hacking skills &amp; U-Boot knowledge might be required. For some pointers, see this patch to enable it on the Versatile Express.
* If your board's U-Boot configuration doesn't use the <code>extlinux.conf</code> format by default, create a patch to enable it. Some C hacking skills & U-Boot knowledge might be required. For some pointers, see this patch to enable it on the Versatile Express.
* Make a pull request, also containing the board-specific instructions. Ping '''@dezgeg''' for review and for building &amp; hosting the U-Boots at http://nixos-arm.dezgeg.me/installer.
* Make a pull request, also containing the board-specific instructions. Ping '''@dezgeg''' for review and for building & hosting the U-Boots at http://nixos-arm.dezgeg.me/installer.