Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dramforever/nixos-riscv-efi
NixOS EFI boot on RISC-V using systemd-boot
https://github.com/dramforever/nixos-riscv-efi
Last synced: about 1 month ago
JSON representation
NixOS EFI boot on RISC-V using systemd-boot
- Host: GitHub
- URL: https://github.com/dramforever/nixos-riscv-efi
- Owner: dramforever
- Created: 2022-11-24T18:08:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-12T13:51:31.000Z (almost 2 years ago)
- Last Synced: 2024-11-09T21:37:23.188Z (about 1 month ago)
- Language: Nix
- Size: 8.79 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NixOS EFI boot on RISC-V using systemd-boot
Just a demo for now. Very dirty code inside; you have been warned!
## Supported devices
- [X] QEMU with U-Boot
Requires a properly configured, recent-ish U-Boot that provides a correct device tree, which is... hard to find on real hardware these days. I really hope one day vendors can do this right, but until then we might have to make do with hacky things like `/dtbs/${fdtfile}`.
## Usage
Prepare U-Boot and disk image:
```console
$ nix build -o uboot ".#ubootQemuRiscv64Smode"
$ nix build -o image ".#nixos-image"
$ cp --no-preserve=mode image/efi-image.img .
$ truncate -s 4G efi-image.img # Size to your liking
```Boot the image:
```bash
qemu-system-riscv64 -M virt -m 2g -nographic -s \
-kernel uboot/u-boot.bin \
-drive id=image,file=efi-image.img,format=raw,if=virtio
```## First boot
A temporary initial configuration (generated on the build system) is used for the first boot. It's easier to do this than to use `bootctl` on the 'wrong' architecture and on a disk that doesn't really exist.
Early on during the first boot:
- The root partition is expanded to fill the device
- The Nix database is initialized and the system profile is set to the booted closure
- The 'correct' bootloader configuration is installed with NixOS's systemd-boot configuration generatorFrom now on the system should behave as a regular NixOS EFI image.
## References
Largely based on the existing `sd-image.nix` code.