sd-image: add preBuildCommands option (#501160)
This commit is contained in:
@@ -179,12 +179,44 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
preBuildCommands = mkOption {
|
||||
type = types.lines;
|
||||
example = literalExpression ''
|
||||
'''
|
||||
if [ ! -w "$root_fs" ]; then
|
||||
cp --no-preserve=mode "$root_fs" ./root-fs.img
|
||||
root_fs=./root-fs.img
|
||||
fi
|
||||
resize2fs $root_fs 15G
|
||||
'''
|
||||
'';
|
||||
default = "";
|
||||
description = ''
|
||||
Shell commands to run after the root filesystem image has been
|
||||
prepared, but before the final SD image is assembled.
|
||||
|
||||
The path to the root filesystem image is available in the
|
||||
{var}`root_fs` shell variable. This hook can be used to modify
|
||||
the rootfs, for example to resize it or inject additional files.
|
||||
|
||||
Note that when {option}`sdImage.compressImage` is disabled,
|
||||
{var}`root_fs` points to a read-only store path. To modify it,
|
||||
first copy it to a writable location and update {var}`root_fs`
|
||||
to point to the copy.
|
||||
'';
|
||||
};
|
||||
|
||||
postBuildCommands = mkOption {
|
||||
type = types.lines;
|
||||
example = literalExpression "'' 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.
|
||||
Shell commands to run after the SD image has been assembled.
|
||||
|
||||
The path to the image is available in the {var}`img` shell
|
||||
variable. This hook is typically used for boards that require
|
||||
writing a bootloader (such as u-boot SPL) to a fixed offset
|
||||
before the first partition.
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -284,6 +316,8 @@ in
|
||||
zstd -d --no-progress "${config.sdImage.rootFilesystemImage}" -o $root_fs
|
||||
''}
|
||||
|
||||
${config.sdImage.preBuildCommands}
|
||||
|
||||
# Gap in front of the first partition, in MiB
|
||||
gap=${toString config.sdImage.firmwarePartitionOffset}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user