at 18.09-beta 2.1 kB view raw
1# To build, use: 2# nix-build nixos -I nixos-config=nixos/modules/installer/cd-dvd/sd-image-aarch64.nix -A config.system.build.sdImage 3{ config, lib, pkgs, ... }: 4 5let 6 extlinux-conf-builder = 7 import ../../system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix { 8 inherit pkgs; 9 }; 10in 11{ 12 imports = [ 13 ../../profiles/base.nix 14 ../../profiles/installation-device.nix 15 ./sd-image.nix 16 ]; 17 18 assertions = lib.singleton { 19 assertion = pkgs.stdenv.hostPlatform.system == "aarch64-linux" 20 && pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system; 21 message = "sd-image-aarch64.nix can be only built natively on Aarch64 / ARM64; " + 22 "it cannot be cross compiled"; 23 }; 24 25 boot.loader.grub.enable = false; 26 boot.loader.generic-extlinux-compatible.enable = true; 27 28 boot.consoleLogLevel = lib.mkDefault 7; 29 boot.kernelPackages = pkgs.linuxPackages_latest; 30 31 # The serial ports listed here are: 32 # - ttyS0: for Tegra (Jetson TX1) 33 # - ttyAMA0: for QEMU's -machine virt 34 # Also increase the amount of CMA to ensure the virtual console on the RPi3 works. 35 boot.kernelParams = ["cma=32M" "console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0"]; 36 37 sdImage = { 38 populateBootCommands = let 39 configTxt = pkgs.writeText "config.txt" '' 40 kernel=u-boot-rpi3.bin 41 42 # Boot in 64-bit mode. 43 arm_control=0x200 44 45 # U-Boot used to need this to work, regardless of whether UART is actually used or not. 46 # TODO: check when/if this can be removed. 47 enable_uart=1 48 49 # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel 50 # when attempting to show low-voltage or overtemperature warnings. 51 avoid_warnings=1 52 ''; 53 in '' 54 (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/) 55 cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin boot/u-boot-rpi3.bin 56 cp ${configTxt} boot/config.txt 57 ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot 58 ''; 59 }; 60}