at 18.09-beta 1.7 kB view raw
1# To build, use: 2# nix-build nixos -I nixos-config=nixos/modules/installer/cd-dvd/sd-image-raspberrypi.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 == "armv6l-linux" 20 && pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system; 21 message = "sd-image-raspberrypi.nix can be only built natively on ARMv6; " + 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_rpi; 30 31 sdImage = { 32 populateBootCommands = let 33 configTxt = pkgs.writeText "config.txt" '' 34 # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel 35 # when attempting to show low-voltage or overtemperature warnings. 36 avoid_warnings=1 37 38 [pi0] 39 kernel=u-boot-rpi0.bin 40 41 [pi1] 42 kernel=u-boot-rpi1.bin 43 ''; 44 in '' 45 (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/) 46 cp ${pkgs.ubootRaspberryPiZero}/u-boot.bin boot/u-boot-rpi0.bin 47 cp ${pkgs.ubootRaspberryPi}/u-boot.bin boot/u-boot-rpi1.bin 48 cp ${configTxt} boot/config.txt 49 ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot 50 ''; 51 }; 52}