NixOS on ARM: Difference between revisions

imported>Makefu
initial batch of nixos-users
 
imported>Fadenb
m syntaxhighlight fixes
Line 53: Line 53:
The .img files can be directly written to a microSD/SD card (minimal recommended size: 4 GB) using dd. For example, if your SD card shows up as <code>/dev/sdc</code>:
The .img files can be directly written to a microSD/SD card (minimal recommended size: 4 GB) using dd. For example, if your SD card shows up as <code>/dev/sdc</code>:


<source lang="bash">sudo dd if=sd-image-armv7l-linux.img of=/dev/sdc</source>
<syntaxhighlight lang="bash">sudo dd if=sd-image-armv7l-linux.img of=/dev/sdc</syntaxhighlight>
(As always, be careful when using dd so you don't wipe your hard drive!)
(As always, be careful when using dd so you don't wipe your hard drive!)


Line 68: Line 68:
U-Boot needs to be copied to the microSD card with dd, with parameters bs=1024 seek=8. Download U-Boot for the board (uboot-Linksprite_pcDuino3_Nano_defconfig-2015.07_u-boot-sunxi-with-spl.bin), and copy it to the correct location with (assuming the SD card still shows up as /dev/sdc):
U-Boot needs to be copied to the microSD card with dd, with parameters bs=1024 seek=8. Download U-Boot for the board (uboot-Linksprite_pcDuino3_Nano_defconfig-2015.07_u-boot-sunxi-with-spl.bin), and copy it to the correct location with (assuming the SD card still shows up as /dev/sdc):


<source lang="bash">sudo dd if=uboot-Linksprite_pcDuino3_Nano_defconfig-2015.07_u-boot-sunxi-with-spl.bin of=/dev/sdc bs=1024 seek=8</source>
<syntaxhighlight lang="bash">sudo dd if=uboot-Linksprite_pcDuino3_Nano_defconfig-2015.07_u-boot-sunxi-with-spl.bin of=/dev/sdc bs=1024 seek=8</syntaxhighlight>
=== Raspberry Pi ===
=== Raspberry Pi ===


Line 77: Line 77:
First, convert the downloaded sd-image-armv7l-linux.img to a new qcow2 formatted disk image (for example, arm-vm.qcow2) and resize it to the desired size (for example, 2.5G):
First, convert the downloaded sd-image-armv7l-linux.img to a new qcow2 formatted disk image (for example, arm-vm.qcow2) and resize it to the desired size (for example, 2.5G):


<source lang="bash">qemu-img convert -O qcow2 sd-image-armv7l-linux.img arm-vm.qcow2
<syntaxhighlight lang="bash">qemu-img convert -O qcow2 sd-image-armv7l-linux.img arm-vm.qcow2
qemu-img resize arm-vm.qcow2 2.5G</source>
qemu-img resize arm-vm.qcow2 2.5G</syntaxhighlight>
Then, to boot the VM, download U-Boot for the Versatile board (uboot-vexpress_ca9x4_defconfig-2015.07_u-boot) and run:
Then, to boot the VM, download U-Boot for the Versatile board (uboot-vexpress_ca9x4_defconfig-2015.07_u-boot) and run:


<source lang="bash">qemu-system-arm -kernel uboot-vexpress_ca9x4_defconfig-2015.07_u-boot -M vexpress-a9 -serial stdio -sd arm-vm.qcow2 -m 512</source>
<syntaxhighlight lang="bash">qemu-system-arm -kernel uboot-vexpress_ca9x4_defconfig-2015.07_u-boot -M vexpress-a9 -serial stdio -sd arm-vm.qcow2 -m 512</syntaxhighlight>
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.


Line 90: Line 90:
Use this as a template:
Use this as a template:


<pre class="nix">{ config, pkgs, lib, ... }:
<syntaxhighlight lang="nix">{ config, pkgs, lib, ... }:
{
{
   # NixOS wants to enable GRUB by default
   # NixOS wants to enable GRUB by default
Line 122: Line 122:
   # !!! Adding a swap file is optional, but strongly recommended!
   # !!! Adding a swap file is optional, but strongly recommended!
   # swapDevices = [ { device = &quot;/swapfile&quot;; size = 1024; } ];
   # swapDevices = [ { device = &quot;/swapfile&quot;; size = 1024; } ];
}</pre>
}</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 = [ &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!


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:


<source lang="bash">nixos-rebuild switch --fast --option binary-caches http://nixos-arm.dezgeg.me/channel --option binary-cache-public-keys nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%</source>
<syntaxhighlight lang="bash">nixos-rebuild switch --fast --option binary-caches http://nixos-arm.dezgeg.me/channel --option binary-cache-public-keys nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%</syntaxhighlight>
== Details about the boot process ==
== Details about the boot process ==