2020-03-09 14:01:55 +00:00
|
|
|
# Base image for building SD images for my Pi 3's
|
|
|
|
#
|
|
|
|
# To build, use:
|
|
|
|
# imports = [ ./sd-image_paidh-base ]
|
2022-03-07 14:26:15 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2021-11-16 04:57:23 +00:00
|
|
|
extlinux-conf-builder = import
|
2022-03-07 14:26:15 +00:00
|
|
|
<nixpkgs/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix> {
|
|
|
|
pkgs = pkgs.buildPackages;
|
|
|
|
};
|
2021-11-16 04:57:23 +00:00
|
|
|
in {
|
2020-03-09 14:01:55 +00:00
|
|
|
imports = [
|
|
|
|
<nixpkgs/nixos/modules/profiles/base.nix>
|
2022-06-16 02:09:40 +00:00
|
|
|
<nixpkgs/nixos/modules/installer/sd-card/sd-image.nix>
|
2020-03-09 14:01:55 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
boot.consoleLogLevel = lib.mkDefault 7;
|
|
|
|
|
|
|
|
sdImage = {
|
|
|
|
populateFirmwareCommands = let
|
|
|
|
configTxt = pkgs.writeText "config.txt" ''
|
|
|
|
kernel=u-boot-rpi3.bin
|
|
|
|
|
|
|
|
# Boot in 64-bit mode.
|
|
|
|
arm_control=0x200
|
|
|
|
|
|
|
|
# U-Boot used to need this to work, regardless of whether UART is actually used or not.
|
|
|
|
# TODO: check when/if this can be removed.
|
|
|
|
enable_uart=1
|
|
|
|
|
|
|
|
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
|
|
|
|
# when attempting to show low-voltage or overtemperature warnings.
|
|
|
|
avoid_warnings=1
|
|
|
|
'';
|
2021-11-16 04:57:23 +00:00
|
|
|
in ''
|
|
|
|
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
|
|
|
|
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin
|
|
|
|
cp ${configTxt} firmware/config.txt
|
|
|
|
'';
|
2020-03-09 14:01:55 +00:00
|
|
|
populateRootCommands = ''
|
|
|
|
mkdir -p ./files/boot
|
|
|
|
${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./files/boot
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|