NixOS on RISCV/VisionFive 2: Difference between revisions
→Setup: Update and fix btrfs image instruction |
|||
| (14 intermediate revisions by 5 users not shown) | |||
| Line 36: | Line 36: | ||
= Setup = | = Setup = | ||
Precompiled SD-card images can be found [https://hydra. | 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 43: | Line 43: | ||
{{file|flake.nix|nix|<nowiki> | {{file|flake.nix|nix|<nowiki> | ||
{ | { | ||
inputs.nixpkgs.url = " | inputs.nixpkgs.url = "nixpkgs/nixos-25.11"; | ||
inputs.nixos-hardware.url = "github:nixos/nixos-hardware"; | inputs.nixos-hardware.url = "github:nixos/nixos-hardware"; | ||
| Line 80: | Line 80: | ||
}; | }; | ||
system.stateVersion = " | system.stateVersion = "25.11"; | ||
}; | }; | ||
inherit system; | inherit system; | ||
| Line 87: | Line 87: | ||
} | } | ||
</nowiki>}} | </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 | |||
{{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" | |||
"rw" | |||
]; | |||
}; | |||
</nowiki>}} | |||
It might be helpful to add [[RISC-V#Binary cache|third-party binary cache configuration]] to this system configuration. | |||
Run following command to build the SD-card image | Run following command to build the SD-card image | ||
| Line 117: | Line 151: | ||
</syntaxhighlight>Bootstrap NixOS system configuration at <code>/etc/nixos/configuration.nix</code><syntaxhighlight lang="bash"> | </syntaxhighlight>Bootstrap NixOS system configuration at <code>/etc/nixos/configuration.nix</code><syntaxhighlight lang="bash"> | ||
nixos-generate-config | nixos-generate-config | ||
</syntaxhighlight> | </syntaxhighlight>It is recommended to [[RISC-V#Binary cache|configure third-party binary caches]] to speed up build times. | ||
== Tips and tricks == | == Tips and tricks == | ||
| Line 137: | Line 171: | ||
=== Deploy and Update the Visionfive 2 NixOS system once it's running NixOS === | === Deploy and Update the Visionfive 2 NixOS system once it's running NixOS === | ||
Once the | 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> | ||
tool with a call similar to | tool with a call similar to | ||
<code>nixos-rebuild --flake .#visionfive2 --build-host | <code>nixos-rebuild --flake .#visionfive2 --build-host user@visionfive2 --target-host user@visionfive2 --use-remote-sudo switch</code> | ||
that uses the SSH connection from the remote builder section. | that uses the SSH connection from the remote builder section. | ||