86 lines
2.4 KiB
Nix
86 lines
2.4 KiB
Nix
{ pkgs, config, ... }: {
|
|
nixpkgs.system = "aarch64-linux";
|
|
|
|
boot = {
|
|
kernelParams = [
|
|
"console=ttyS1,115200n8"
|
|
"console=tty0"
|
|
];
|
|
|
|
loader.generic-extlinux-compatible = {
|
|
enable = true;
|
|
configurationLimit = 3;
|
|
};
|
|
};
|
|
|
|
hardware = {
|
|
deviceTree.filter = "*rpi-3*.dtb";
|
|
enableRedistributableFirmware = true;
|
|
};
|
|
|
|
systemd.network.links = {
|
|
"10-ethernet" = {
|
|
matchConfig.Path = "platform-3f980000.usb-usb-0:1.1.1:1.0";
|
|
linkConfig.Name = "ethernet";
|
|
};
|
|
"10-wifi" = {
|
|
matchConfig.Path = "platform-3f300000.mmc";
|
|
linkConfig.Name = "wifi";
|
|
};
|
|
};
|
|
|
|
my = {
|
|
disk = {
|
|
bootSize = 512;
|
|
persistSize = 1024;
|
|
rootSize = "128M";
|
|
imageBaseName = "qclkos-rpi3";
|
|
|
|
# Based on `nixos/modules/installer/sd-card/sd-image-aarch64.nix`
|
|
populateBootCommands =
|
|
let
|
|
configTxt = pkgs.writeText "config.txt" ''
|
|
[pi3]
|
|
kernel=u-boot-rpi3.bin
|
|
|
|
[pi02]
|
|
kernel=u-boot-rpi3.bin
|
|
|
|
# Otherwise the resolution will be weird in most cases, compared to
|
|
# what the pi3 firmware does by default.
|
|
disable_overscan=1
|
|
|
|
# Supported in newer board revisions
|
|
arm_boost=1
|
|
|
|
[all]
|
|
# Boot in 64-bit mode.
|
|
arm_64bit=1
|
|
|
|
# U-Boot needs this to work, regardless of whether UART is actually used or not.
|
|
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still
|
|
# a requirement in the future.
|
|
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
|
|
'';
|
|
in ''
|
|
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/boot/)
|
|
|
|
# Add the config
|
|
cp ${configTxt} boot/config.txt
|
|
|
|
# Add pi3 specific files
|
|
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin boot/u-boot-rpi3.bin
|
|
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-2-b.dtb boot/
|
|
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-3-b.dtb boot/
|
|
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-3-b-plus.dtb boot/
|
|
|
|
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./boot
|
|
'';
|
|
};
|
|
};
|
|
}
|