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.system == "armv6l-linux";
20 message = "sd-image-raspberrypi.nix can be only built natively on ARMv6; " +
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_rpi;
32
33 # FIXME: this probably should be in installation-device.nix
34 users.extraUsers.root.initialHashedPassword = "";
35
36 sdImage = {
37 populateBootCommands = ''
38 (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/)
39 cp ${pkgs.ubootRaspberryPi}/u-boot.bin boot/u-boot-rpi.bin
40 echo 'kernel u-boot-rpi.bin' > boot/config.txt
41 ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot
42 '';
43 };
44}