2017-01-25 13:07:37 +00:00
|
|
|
# To build, use:
|
|
|
|
# nix-build nixos -I nixos-config=nixos/modules/installer/cd-dvd/sd-image-aarch64.nix -A config.system.build.sdImage
|
2017-01-23 22:52:25 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
extlinux-conf-builder =
|
|
|
|
import ../../system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix {
|
|
|
|
inherit pkgs;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
2017-10-25 20:26:45 +01:00
|
|
|
../../profiles/base.nix
|
2017-01-23 22:52:25 +00:00
|
|
|
../../profiles/installation-device.nix
|
|
|
|
./sd-image.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
assertions = lib.singleton {
|
|
|
|
assertion = pkgs.stdenv.system == "aarch64-linux";
|
|
|
|
message = "sd-image-aarch64.nix can be only built natively on Aarch64 / ARM64; " +
|
|
|
|
"it cannot be cross compiled";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Needed by RPi firmware
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
|
|
boot.loader.grub.enable = false;
|
|
|
|
boot.loader.generic-extlinux-compatible.enable = true;
|
|
|
|
|
|
|
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
2017-10-25 18:30:17 +01:00
|
|
|
|
|
|
|
# The serial ports listed here are:
|
|
|
|
# - ttyS0: for Tegra (Jetson TX1)
|
|
|
|
# - ttyAMA0: for QEMU's -machine virt
|
|
|
|
# Also increase the amount of CMA to ensure the virtual console on the RPi3 works.
|
|
|
|
boot.kernelParams = ["cma=32M" "console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"];
|
2017-01-23 22:52:25 +00:00
|
|
|
|
|
|
|
# FIXME: this probably should be in installation-device.nix
|
|
|
|
users.extraUsers.root.initialHashedPassword = "";
|
|
|
|
|
|
|
|
sdImage = {
|
|
|
|
populateBootCommands = let
|
|
|
|
configTxt = pkgs.writeText "config.txt" ''
|
|
|
|
kernel=u-boot-rpi3.bin
|
|
|
|
arm_control=0x200
|
|
|
|
enable_uart=1
|
|
|
|
'';
|
|
|
|
in ''
|
2017-02-11 10:23:16 +00:00
|
|
|
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/)
|
2017-11-06 23:56:59 +00:00
|
|
|
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin boot/u-boot-rpi3.bin
|
2017-01-23 22:52:25 +00:00
|
|
|
cp ${configTxt} boot/config.txt
|
|
|
|
${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|