Asterinas NixOS
Asterinas NixOS 是 Asterinas 的第一個散布版。我們選擇 NixOS 作為基礎作業系統,是因為其無與倫比的可訂製性與豐富的軟體包生態系統。Asterinas NixOS 的目的在於提供與原生 NixOS 相似的外觀與使用體驗,唯一的區別在於它將內核從 Linux 替換為 Asterinas。關於選擇 NixOS 的更多理由,請參見 RFC。
免責聲明:Asterinas 是一個獨立且由社群主導的專案。Asterinas NixOS 並非 NixOS 的官方專案,且與 NixOS 基金會 無 任何隸屬關係。此處 不 包含任何贊助或背書之意。
Asterinas NixOS 尚未準備好用於生產環境。我們提供 Asterinas NixOS 是為了降低 Asterinas 內核的使用門檻,讓早期採用者與愛好者能夠嘗試並提供反饋。此外,Asterinas 開發者將此散布版作為主要的開發工具,有助於在 Asterinas 內核上啟用並測試更多現實世界的應用程式。
開始使用
終端使用者
The following instructions describe how to install Asterinas NixOS in a VM using the Asterinas NixOS installer ISO.
-
啟動 x86-64 的 Ubuntu 容器:
docker run -it --privileged --network=host ubuntu:latest bash -
在容器內安裝 QEMU:
apt update apt install -y qemu-system-x86 qemu-utils -
從 GitHub Releases 下載最新的 Asterinas NixOS 安裝程式 ISO。
-
Create a file that will be used as the target disk to install Asterinas NixOS:
# The capacity of the disk is 10GB; adjust it as you see fit dd if=/dev/zero of=aster_nixos_disk.img bs=1G count=10 -
Start an x86-64 VM with two drives: one is the installer CD-ROM and the other is the target disk:
export INSTALLER_ISO=/path/to/your/downloaded/installer.iso qemu-system-x86_64 \ -cpu host -m 8G -enable-kvm \ -drive file="$INSTALLER_ISO",media=cdrom -boot d \ -drive if=virtio,format=raw,file=aster_nixos_disk.img \ -chardev stdio,id=mux,mux=on,logfile=qemu.log \ -device virtio-serial-pci -device virtconsole,chardev=mux \ -serial chardev:mux -monitor chardev:mux \ -nographicAfter the VM boots, you now have access to the installation environment.
-
Edit the
configuration.nixfile in the home directory to customize the NixOS system to be installed:vim configuration.nixThe complete syntax and guidance for the
configuration.nixfile can be found in the NixOS manual. If you are not familiar with NixOS, you can simply skip this step.Not all combinations of settings in
configuration.nixare supported by Asterinas NixOS yet. The ones that have been tested are documented in the subsequent chapters. -
開始安裝:
install_aster_nixos.sh --config configuration.nix --disk /dev/vda --force-format-diskThe installation process involves downloading packages and may take around 30 minutes to complete, depending on your network speed.
-
After the installation is complete, you can shut down the VM:
poweroffNow Asterinas NixOS is installed in
aster_nixos_disk.img. -
Start a VM to boot the newly installed Asterinas NixOS:
qemu-system-x86_64 \ -cpu host -m 8G -enable-kvm \ -bios /usr/share/qemu/OVMF.fd \ -drive if=none,format=raw,id=x0,file=aster_nixos_disk.img \ -device virtio-blk-pci,drive=x0,disable-legacy=on,disable-modern=off \ -chardev stdio,id=mux,mux=on,logfile=qemu.log \ -device virtio-serial-pci -device virtconsole,chardev=mux \ -serial chardev:mux -monitor chardev:mux \ -device virtio-net-pci,netdev=net0,disable-legacy=on,disable-modern=off \ -netdev user,id=net0 \ -device isa-debug-exit,iobase=0xf4,iosize=0x04 \ -nographic -display vnc=127.0.0.1:21If a desktop environment is enabled in the
configuration.nixfile, you can view the graphical interface using a VNC client.
內核開發者
-
Follow Steps 1 and 2 in the “Getting Started” section of the Asterinas Kernel to set up the development environment.
-
在 Docker 容器內,使用以下命令生成已安裝 Asterinas NixOS 的磁碟映像:
make nixosor this command:
make iso && make run_isoThe difference between the two methods is that the first installs NixOS to a disk image entirely inside the container, whereas the second emulates the manual ISO installation steps (see the previous section) by running a VM. Using either method results in a disk image with an Asterinas NixOS installation.
-
Start a VM to run the installed Asterinas NixOS:
make run_nixos