at 17.09-beta 1.8 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/installation-device.nix 14 ./sd-image.nix 15 ]; 16 17 assertions = lib.singleton { 18 assertion = pkgs.stdenv.system == "armv7l-linux"; 19 message = "sd-image-armv7l-multiplatform.nix can be only built natively on ARMv7; " + 20 "it cannot be cross compiled"; 21 }; 22 23 # Needed by RPi firmware 24 nixpkgs.config.allowUnfree = true; 25 26 boot.loader.grub.enable = false; 27 boot.loader.generic-extlinux-compatible.enable = true; 28 29 boot.kernelPackages = pkgs.linuxPackages_latest; 30 boot.kernelParams = ["console=ttyS0,115200n8" "console=ttymxc0,115200n8" "console=ttyAMA0,115200n8" "console=ttyO0,115200n8" "console=ttySAC2,115200n8" "console=tty0"]; 31 32 # FIXME: this probably should be in installation-device.nix 33 users.extraUsers.root.initialHashedPassword = ""; 34 35 sdImage = { 36 populateBootCommands = let 37 configTxt = pkgs.writeText "config.txt" '' 38 [pi2] 39 kernel=u-boot-rpi2.bin 40 41 [pi3] 42 kernel=u-boot-rpi3.bin 43 enable_uart=1 44 ''; 45 in '' 46 (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/) 47 cp ${pkgs.ubootRaspberryPi2}/u-boot.bin boot/u-boot-rpi2.bin 48 cp ${pkgs.ubootRaspberryPi3_32bit}/u-boot.bin boot/u-boot-rpi3.bin 49 cp ${configTxt} boot/config.txt 50 ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot 51 ''; 52 }; 53}