1{ config, lib, pkgs, ... }:
2
3let
4 extlinux-conf-builder =
5 import ../../system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix {
6 inherit pkgs;
7 };
8in
9{
10 imports = [
11 ../../profiles/minimal.nix
12 ../../profiles/installation-device.nix
13 ./sd-image.nix
14 ];
15
16 assertions = lib.singleton {
17 assertion = pkgs.stdenv.system == "armv7l-linux";
18 message = "sd-image-armv7l-multiplatform.nix can be only built natively on ARMv7; " +
19 "it cannot be cross compiled";
20 };
21
22 # Needed by RPi firmware
23 nixpkgs.config.allowUnfree = true;
24
25 boot.loader.grub.enable = false;
26 boot.loader.generic-extlinux-compatible.enable = true;
27
28 boot.kernelPackages = pkgs.linuxPackages_latest;
29 boot.kernelParams = ["console=ttyS0,115200n8" "console=ttymxc0,115200n8" "console=ttyAMA0,115200n8" "console=ttyO0,115200n8" "console=tty0"];
30 boot.consoleLogLevel = 7;
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 for f in bootcode.bin fixup.dat start.elf; do
47 cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/$f boot/
48 done
49 cp ${pkgs.ubootRaspberryPi2}/u-boot.bin boot/u-boot-rpi2.bin
50 cp ${pkgs.ubootRaspberryPi3}/u-boot.bin boot/u-boot-rpi3.bin
51 cp ${configTxt} boot/config.txt
52 ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot
53 '';
54 };
55}