I would like to create an SD image for a completely offline Raspberry PI 4.
Since the Raspberry will be offline, I want to preinstall all the binaries I need. Some binaries will come from flakes, thus I am trying to use the flake system.
I have another machine with aarch64 so I don’t need to cross-compile.
I am at the point where I can successfully create the image and the Raspberry boots with the following flake.nix (I started from How to move from building sd card images, to be able to remotely deploy new versions?):
{
description = "Build Raspberry PI 4 image";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
};
outputs = { self, nixpkgs }: rec {
nixosConfigurations.rpi4 = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
({ ... }: {
config = {
time.timeZone = "Europe/Rome";
i18n.defaultLocale = "it_IT.UTF-8";
sdImage.compressImage = false;
console.keyMap = "it";
users.users.root.initialHashedPassword = "$y$j9T$/29noYRT4W/22Hy4lW7B71$MNtGBgjk01Zo3LtKgFRQtwaXdv6I15oiSgGGCMkt9s2"; # =test use mkpasswd to generate
system = {
stateVersion = "23.05";
};
#services.nginx = {
# enable = true;
#};
networking = {
wireless.enable = false;
useDHCP = false;
};
hardware.bluetooth.powerOnBoot = false;
};
})
];
};
images.rpi4 = nixosConfigurations.rpi4.config.system.build.sdImage;
};
}
I build the image with: nix build .#images.rpi4
and flash it to the ssd with dd
.
The Raspberry boots fine, however, I don’t know how to pre-install binaries in the image from nixpkgs such as gpg.
(if you feel ultra helpful following issues are: how to add binaries from flakes, and how to avoid bluetooth error message at login, I want to disable it)