@@ -0,0 +1,61 @@
1+{ config, lib, pkgs, ... }:
2+
3+let
4+ extlinux-conf-builder =
5+ import ../../system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix {
6+ inherit pkgs;
7+ };
8+in
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 == "aarch64-linux";
18+ message = "sd-image-aarch64.nix can be only built natively on Aarch64 / ARM64; " +
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=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+ # Contains a couple of fixes for booting a Linux kernel, will hopefully appear upstream soon.
38+ patchedUboot = pkgs.ubootRaspberryPi3_64bit.overrideAttrs (oldAttrs: {
39+ src = pkgs.fetchFromGitHub {
40+ owner = "dezgeg";
41+ repo = "u-boot";
42+ rev = "baab53ec244fe44def01948a0f10e67342d401e6";
43+ sha256 = "0r5j2pc42ws3w3im0a9c6bh01czz5kapqrqp0ik9ra823cw73lxr";
44+ };
45+ });
46+
47+ configTxt = pkgs.writeText "config.txt" ''
48+ kernel=u-boot-rpi3.bin
49+ arm_control=0x200
50+ enable_uart=1
51+ '';
52+ in ''
53+ for f in bootcode.bin fixup.dat start.elf; do
54+ cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/$f boot/
55+ done
56+ cp ${patchedUboot}/u-boot.bin boot/u-boot-rpi3.bin
57+ cp ${configTxt} boot/config.txt
58+ ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot
59+ '';
60+ };
61+}