NixOS on RISCV/VisionFive 2: Difference between revisions
→Manually build a SD-card image: Update NixOS sys version |
mNo edit summary |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 36: | Line 36: | ||
= Setup = | = Setup = | ||
Precompiled SD-card images can be found | Precompiled SD-card images with unstable NixOS can be found [https://hydra.ztier.in/job/nixos/nixos-unstable/sd-image-riscv64-new-kernel-no-zfs-installer-cross/latest on misuzu's Hydra instance]. Before flashing the image, use <code>unzstd</code> to unpack the downloaded archive. | ||
=== Manually build a SD-card image === | === Manually build a SD-card image === | ||
| Line 86: | Line 86: | ||
}); | }); | ||
} | } | ||
</nowiki>}} | |||
If you want to use an alternative filesystem for system root, for example [[Btrfs]], you could change the <code>sdImage</code>-part to this. Currently [https://github.com/NixOS/nixpkgs/pull/434122 this patch] is required to produce a functioning btrfs image. | |||
{{file|flake.nix|nix|<nowiki> | |||
sdImage = { | |||
compressImage = false; | |||
rootFilesystemCreator = "${pkgs.path}/nixos/lib/make-btrfs-fs.nix"; | |||
# do this manually as replacing the resize2fs string in postBootCommands | |||
# might be too complex. btrfs uses its own resize command. | |||
expandOnBoot = false; | |||
}; | |||
nixpkgs.overlays = [ | |||
(final: prev: { | |||
ubootVisionFive2 = prev.ubootVisionFive2.overrideAttrs (oldAttrs: { | |||
extraConfig = (oldAttrs.extraConfig or "") + '' | |||
CONFIG_FS_BTRFS=y | |||
CONFIG_CMD_BTRFS=y | |||
''; | |||
}); | |||
}) | |||
]; | |||
fileSystems."/" = { | |||
fsType = lib.mkForce "btrfs"; | |||
options = [ | |||
"compress=zstd" | |||
"noatime" | |||
]; | |||
}; | |||
</nowiki>}} | </nowiki>}} | ||
| Line 121: | Line 152: | ||
</syntaxhighlight>It is recommended to [[RISC-V#Binary cache|configure third-party binary caches]] to speed up build times. | </syntaxhighlight>It is recommended to [[RISC-V#Binary cache|configure third-party binary caches]] to speed up build times. | ||
= Tips and tricks = | |||
== Using the Visionfive 2 as a remote builder to build native RISCV packages for e.g. the Visionfive 2 == | |||
Building an NixOS system image that can be flashed to an SD card or NVMe SSD requires to '''build RISCV binaries''', more specifically for the <code>"riscv64-linux"</code>platform. From a typical Intel/AMD computer we can either | Building an NixOS system image that can be flashed to an SD card or NVMe SSD requires to '''build RISCV binaries''', more specifically for the <code>"riscv64-linux"</code>platform. From a typical Intel/AMD computer we can either | ||
| Line 138: | Line 169: | ||
# '''flash that resulting image onto an SD card''' or NVMe SSD using a call similar to <code>zstdcat result/sd-image/nixos-sd-image-23.11.20230703.ea4c80b-riscv64-linux.img.zst | sudo dd of=/dev/mmcblk0 bs=100M status=progress</code> and place that card into the Visionfive 2. | # '''flash that resulting image onto an SD card''' or NVMe SSD using a call similar to <code>zstdcat result/sd-image/nixos-sd-image-23.11.20230703.ea4c80b-riscv64-linux.img.zst | sudo dd of=/dev/mmcblk0 bs=100M status=progress</code> and place that card into the Visionfive 2. | ||
== Deploy and Update the Visionfive 2 NixOS system once it's running NixOS == | |||
Once the Visionfive 2 is running NixOS, you can update it with newer NixOS system configurations using e.g. the usual <code>nix-rebuild</code> | Once the Visionfive 2 is running NixOS, you can update it with newer NixOS system configurations using e.g. the usual <code>nix-rebuild</code> | ||
| Line 149: | Line 180: | ||
See [https://nixcademy.com/2023/08/10/nixos-rebuild-remote-deployment/ this guide] for a good explanation of this terminal call. | See [https://nixcademy.com/2023/08/10/nixos-rebuild-remote-deployment/ this guide] for a good explanation of this terminal call. | ||
= See also = | |||
* There's also a port of the UEFI reference implementation EDK2 available at https://github.com/starfive-tech/edk2 to support a future generic RISCV Linux image that can be booted from any RISCV device. | * There's also a port of the UEFI reference implementation EDK2 available at https://github.com/starfive-tech/edk2 to support a future generic RISCV Linux image that can be booted from any RISCV device. | ||