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