1 { config, lib, pkgs, ... }:
6 cfg = config.boot.loader.raspberryPi;
8 builderUboot = import ./uboot-builder.nix { inherit pkgs configTxt; inherit (cfg) version; };
9 builderGeneric = import ./raspberrypi-builder.nix { inherit pkgs configTxt; };
12 if cfg.uboot.enable then
13 "${builderUboot} -g ${toString cfg.uboot.configurationLimit} -t ${timeoutStr} -c"
15 "${builderGeneric} -c";
17 blCfg = config.boot.loader;
18 timeoutStr = if blCfg.timeout == null then "-1" else toString blCfg.timeout;
20 isAarch64 = pkgs.stdenv.hostPlatform.isAarch64;
21 optional = pkgs.lib.optionalString;
24 pkgs.writeText "config.txt" (''
25 # U-Boot used to need this to work, regardless of whether UART is actually used or not.
26 # TODO: check when/if this can be removed.
29 # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
30 # when attempting to show low-voltage or overtemperature warnings.
32 '' + optional isAarch64 ''
33 # Boot in 64-bit mode.
35 '' + (if cfg.uboot.enable then ''
39 initramfs initrd followkernel
40 '') + optional (cfg.firmwareConfig != null) cfg.firmwareConfig);
47 boot.loader.raspberryPi = {
52 Whether to create files with the system generations in
54 `/boot/old` will hold files from old generations.
57 These options are deprecated, unsupported, and may not work like expected.
64 type = types.enum [ 0 1 2 3 4 ];
73 Enable using uboot as bootmanager for the raspberry pi.
76 These options are deprecated, unsupported, and may not work like expected.
81 configurationLimit = mkOption {
86 Maximum number of configurations in the boot menu.
89 These options are deprecated, unsupported, and may not work like expected.
96 firmwareConfig = mkOption {
98 type = types.nullOr types.lines;
100 Extra options that will be appended to `/boot/config.txt` file.
101 For possible values, see: https://www.raspberrypi.com/documentation/computers/config_txt.html
104 These options are deprecated, unsupported, and may not work like expected.
112 (mkIf cfg.uboot.enable {
115 The option set for `boot.loader.raspberrypi.uboot` has been recommended against
116 for years, and is now formally deprecated.
118 It is possible it already did not work like you expected.
120 It never worked on the Raspberry Pi 4 family.
122 These options will be removed by NixOS 24.11.
129 The option set for `boot.loader.raspberrypi` has been recommended against
130 for years, and is now formally deprecated.
132 It is possible it already did not work like you expected.
134 It never worked on the Raspberry Pi 4 family.
136 These options will be removed by NixOS 24.11.
141 assertions = singleton {
142 assertion = !pkgs.stdenv.hostPlatform.isAarch64 || cfg.version >= 3;
143 message = "Only Raspberry Pi >= 3 supports aarch64.";
146 system.build.installBootLoader = builder;
147 system.boot.loader.id = "raspberrypi";
148 system.boot.loader.kernelFile = pkgs.stdenv.hostPlatform.linux-kernel.target;