Skip to content

Instantly share code, notes, and snippets.

@astr0n8t
Created October 7, 2025 17:39
Show Gist options
  • Select an option

  • Save astr0n8t/8643b4695084c56be7c523a421f0a6a9 to your computer and use it in GitHub Desktop.

Select an option

Save astr0n8t/8643b4695084c56be7c523a421f0a6a9 to your computer and use it in GitHub Desktop.
Working format to get a working Raspberry Pi 2B+ SD card build using NixOS and nixos-generators
{
system = "armv7l-linux";
format = "sd-armv7l";
customFormats = { "sd-armv7l" = ./formats/sd-armv7l.nix; };
modules = [
nixos-hardware.nixosModules.raspberry-pi-2
];
}
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
"${toString modulesPath}/installer/sd-card/sd-image-armv7l-multiplatform.nix"
];
boot.initrd.includeDefaultModules = false;
boot.initrd.kernelModules = [ "ext4" "mmc_block" ];
boot.supportedFilesystems = lib.mkForce [ "vfat" "ext4" ];
disabledModules =
[ "${modulesPath}/profiles/all-hardware.nix"
"${modulesPath}/profiles/base.nix"
];
sdImage = {
populateFirmwareCommands =
''
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp *rpi-2*.dtb $NIX_BUILD_TOP/firmware/)
'';
};
formatAttr = "sdImage";
fileExtension = ".img.*";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment