Skip to content

Commit

Permalink
nixos/sdImage: add postBuildCommands
Browse files Browse the repository at this point in the history
This allows to perform `dd if= of=$img` after the image is built
which is handy to add e.g. uBoot SPL to the built image.

Instructions for some ARM boards sometimes contain this step
that needs to be performed manually, with this patch it can be
part of the nix file used to built the image.
  • Loading branch information
sorki committed Aug 27, 2020
1 parent c557ea5 commit 170e1af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nixos/modules/installer/cd-dvd/sd-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ in
'';
};

postBuildCommands = mkOption {
example = literalExample "'' dd if=\${pkgs.myBootLoader}/SPL of=$img bs=1024 seek=1 conv=notrunc ''";
default = "";
description = ''
Shell commands to run after the image is built.
Can be used for boards requiring to dd u-boot SPL before actual partitions.
'';
};

compressImage = mkOption {
type = types.bool;
default = true;
Expand Down Expand Up @@ -197,6 +206,9 @@ in
# Verify the FAT partition before copying it.
fsck.vfat -vn firmware_part.img
dd conv=notrunc if=firmware_part.img of=$img seek=$START count=$SECTORS
${config.sdImage.postBuildCommands}
if test -n "$compressImage"; then
zstd -T$NIX_BUILD_CORES --rm $img
fi
Expand Down

0 comments on commit 170e1af

Please sign in to comment.