aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix')
-rw-r--r--nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix36
1 files changed, 28 insertions, 8 deletions
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix b/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
index 4187c01d70e..231c7bf0a6c 100644
--- a/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -63,6 +63,14 @@ in
'';
};
+ firmwarePartitionName = mkOption {
+ type = types.str;
+ default = "FIRMWARE";
+ description = ''
+ Name of the filesystem which holds the boot firmware.
+ '';
+ };
+
rootPartitionUUID = mkOption {
type = types.nullOr types.str;
default = null;
@@ -91,7 +99,7 @@ in
};
populateRootCommands = mkOption {
- example = literalExample "''\${extlinux-conf-builder} -t 3 -c \${config.system.build.toplevel} -d ./files/boot''";
+ example = literalExample "''\${config.boot.loader.generic-extlinux-compatible.populateCmd} -c \${config.system.build.toplevel} -d ./files/boot''";
description = ''
Shell commands to populate the ./files directory.
All files in that directory are copied to the
@@ -100,12 +108,21 @@ 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;
description = ''
Whether the SD image should be compressed using
- <command>bzip2</command>.
+ <command>zstd</command>.
'';
};
@@ -114,7 +131,7 @@ in
config = {
fileSystems = {
"/boot/firmware" = {
- device = "/dev/disk/by-label/FIRMWARE";
+ device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}";
fsType = "vfat";
# Alternatively, this could be removed from the configuration.
# The filesystem is not needed at runtime, it could be treated
@@ -130,10 +147,10 @@ in
sdImage.storePaths = [ config.system.build.toplevel ];
system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs,
- mtools, libfaketime, utillinux, bzip2, zstd }: stdenv.mkDerivation {
+ mtools, libfaketime, utillinux, zstd }: stdenv.mkDerivation {
name = config.sdImage.imageName;
- nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 zstd ];
+ nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux zstd ];
inherit (config.sdImage) compressImage;
@@ -143,7 +160,7 @@ in
echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system
if test -n "$compressImage"; then
- echo "file sd-image $img.bz2" >> $out/nix-support/hydra-build-products
+ echo "file sd-image $img.zst" >> $out/nix-support/hydra-build-products
else
echo "file sd-image $img" >> $out/nix-support/hydra-build-products
fi
@@ -178,7 +195,7 @@ in
# Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
truncate -s $((SECTORS * 512)) firmware_part.img
- faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n FIRMWARE firmware_part.img
+ faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img
# Populate the files intended for /boot/firmware
mkdir firmware
@@ -189,8 +206,11 @@ 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
- bzip2 $img
+ zstd -T$NIX_BUILD_CORES --rm $img
fi
'';
}) {};