Skip to content

Instantly share code, notes, and snippets.

@betaboon
Last active October 9, 2020 17:28
Show Gist options
  • Save betaboon/04b1c8be280d76ab8e6cc41fefe94690 to your computer and use it in GitHub Desktop.
Save betaboon/04b1c8be280d76ab8e6cc41fefe94690 to your computer and use it in GitHub Desktop.
raspberrypiConfig = pkgs.writeText "raspberrypi-config.txt" ''
[pi4]
arm_64bit=1
kernel=kernel-raspberrypi-4
initramfs initramfs-raspberrypi-4
cmdline cmdline-raspberrypi-4.txt
gpu_mem=16
[all]
enable_uart=1
dtparam=spi=on
dtparam=i2c_arm=on
dtparam=sd_poll_once
'';
raspberrypi4CommandlineConfig = pkgs.writeText "cmdline-raspberrypi-4-txt" ''
init=${raspberrypi4Image.init} ${toString raspberrypi4Image.kernelParams} ip=dhcp nfsnixstore=172.16.100.10:nix-store,vers=4,tcp,ro
'';
tftpRoot = pkgs.stdenv.mkDerivation {
name = "tftp-root";
buildCommand = ''
mkdir -p $out
ln -s ${pkgs.raspberrypifw}/share/raspberrypi/boot/bootcode.bin $out/
ln -s ${pkgs.raspberrypifw}/share/raspberrypi/boot/start*.elf $out/
ln -s ${raspberrypi4Image.kernel}/Image $out/kernel-raspberrypi-4
ln -s ${raspberrypi4Image.kernel}/dtbs/broadcom/*.dtb $out/
ln -s ${raspberrypi4Image.kernel}/dtbs/overlays $out/
ln -s ${raspberrypi4Image.initialRamdisk}/initrd $out/initramfs-raspberrypi-4
ln -s ${raspberrypi4CommandlineConfig} $out/cmdline-raspberrypi-4.txt
ln -s ${raspberrypiConfig} $out/config.txt
'';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment