at 18.03-beta 2.4 kB view raw
1# To build, use: 2# nix-build nixos -I nixos-config=nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.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.system == "armv7l-linux"; 20 message = "sd-image-armv7l-multiplatform.nix can be only built natively on ARMv7; " + 21 "it cannot be cross compiled"; 22 }; 23 24 # Needed by RPi firmware 25 nixpkgs.config.allowUnfree = true; 26 27 boot.loader.grub.enable = false; 28 boot.loader.generic-extlinux-compatible.enable = true; 29 30 boot.consoleLogLevel = lib.mkDefault 7; 31 boot.kernelPackages = pkgs.linuxPackages_latest; 32 # The serial ports listed here are: 33 # - ttyS0: for Tegra (Jetson TK1) 34 # - ttymxc0: for i.MX6 (Wandboard) 35 # - ttyAMA0: for Allwinner (pcDuino3 Nano) and QEMU's -machine virt 36 # - ttyO0: for OMAP (BeagleBone Black) 37 # - ttySAC2: for Exynos (ODROID-XU3) 38 boot.kernelParams = ["console=ttyS0,115200n8" "console=ttymxc0,115200n8" "console=ttyAMA0,115200n8" "console=ttyO0,115200n8" "console=ttySAC2,115200n8" "console=tty0"]; 39 40 # FIXME: this probably should be in installation-device.nix 41 users.extraUsers.root.initialHashedPassword = ""; 42 43 sdImage = { 44 populateBootCommands = let 45 configTxt = pkgs.writeText "config.txt" '' 46 # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel 47 # when attempting to show low-voltage or overtemperature warnings. 48 avoid_warnings=1 49 50 [pi2] 51 kernel=u-boot-rpi2.bin 52 53 [pi3] 54 kernel=u-boot-rpi3.bin 55 56 # U-Boot used to need this to work, regardless of whether UART is actually used or not. 57 # TODO: check when/if this can be removed. 58 enable_uart=1 59 ''; 60 in '' 61 (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/) 62 cp ${pkgs.ubootRaspberryPi2}/u-boot.bin boot/u-boot-rpi2.bin 63 cp ${pkgs.ubootRaspberryPi3_32bit}/u-boot.bin boot/u-boot-rpi3.bin 64 cp ${configTxt} boot/config.txt 65 ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot 66 ''; 67 }; 68}