Skip to content

Examples of Nix expressions for cross compiling NixOS images for ARM

License

Notifications You must be signed in to change notification settings

cyber-murmel/NixOS-on-ARM-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS on ARM Examples

Examples of Nix expressions for cross compiling NixOS images for ARM

Customizing

If you want to setup wireless networking, public SSH keys or the like, copy custom.nix.template to custom.nix and edit its content to your requirements.

Building

Set BOARD_TYPE to the desired value and run the command as shown below.

$ export BOARD_TYPE=foobar
# nixpkgs pinned to master as of Thu Mar 31 08:01:29 2022 -0700
$ export NIXPKGS="https://github.com/NixOS/nixpkgs/archive/3e481ad.tar.gz"
$ nix-build -I nixpkgs=$NIXPKGS -I machine=machines/$BOARD_TYPE --out-link out-links/$BOARD_TYPE

Boards

BOARD_TYPE can be set to the name of any directory in machines.

Board BOARD_TYPE
generic AArch64 generic-aarch64
generic ARMv7l generic-armv7l-hf
ESPRESSObin espressobin
Orange Pi Zero orange-pi-zero
ROC-RK3328-CC roc-rk3328-cc
Raspberry Pi Zero W raspberry-pi-zero-w

Building All

Run this command to build images for all available boards. I just added this section to have something to copy and paste for a "release build".

$ export NIXPKGS=https://github.com/NixOS/nixpkgs/archive/3e481ad.tar.gz
$ for machine in $(find machines -maxdepth 1 -mindepth 1 -type d)
do
    export BOARD_TYPE=$(basename $machine);
    nix-build -I nixpkgs=$NIXPKGS -I machine=machines/$BOARD_TYPE --out-link out-links/$BOARD_TYPE
done

Flashing

# set correct path for SD card
export SD_CARD=/dev/sda
# inflate image and write to SD card
zstd -dcf out-links/$BOARD_TYPE/sd-image/*.img.zst | sudo dd status=progress bs=64k iflag=fullblock oflag=direct of=$SD_CARD && sync && sudo eject $SD_CARD

Attribution

About

Examples of Nix expressions for cross compiling NixOS images for ARM

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages