From f75552ebcc24acf1cf042cfe05365693980726f1 Mon Sep 17 00:00:00 2001 From: "Manu [tennox]" Date: Sat, 11 Jan 2025 21:17:02 +0100 Subject: [PATCH] add option to skip compression during build I found this decreased the image-generating part from 5m46s to 3m30s Trying to find out a cache size difference, I did not see a change in size of: `nix-tree --derivation ./result` (probably because I don't know how to properly check that) --- sd-image/sd-image.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sd-image/sd-image.nix b/sd-image/sd-image.nix index 60eedfc..65a69a3 100644 --- a/sd-image/sd-image.nix +++ b/sd-image/sd-image.nix @@ -24,7 +24,7 @@ with lib; let rootfsImage = pkgs.callPackage "${modulesPath}/../lib/make-ext4-fs.nix" ({ inherit (config.sdImage) storePaths; - compressImage = true; + compressImage = config.sdImage.compressDuringBuild; populateImageCommands = config.sdImage.populateRootCommands; volumeLabel = "NIXOS_SD"; } // optionalAttrs (config.sdImage.rootPartitionUUID != null) { @@ -141,6 +141,14 @@ in ''; }; + compressDuringBuild = mkOption { + type = types.bool; + default = true; + description = '' + Whether the SD image should be compressed during intermediate build steps (saving cache space, but takes longer) + ''; + }; + expandOnBoot = mkOption { type = types.bool; default = true; @@ -172,7 +180,7 @@ in nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime util-linux zstd ]; - inherit (config.sdImage) compressImage; + inherit (config.sdImage) compressImage compressDuringBuild; buildCommand = '' mkdir -p $out/nix-support $out/sd-image @@ -185,8 +193,12 @@ in echo "file sd-image $img" >> $out/nix-support/hydra-build-products fi - echo "Decompressing rootfs image" - zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img + if test -n "$compressDuringBuild"; then + echo "Decompressing rootfs image" + zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img + else + ln -s "${rootfsImage}" ./root-fs.img + fi # Gap in front of the first partition, in MiB gap=${toString config.sdImage.firmwarePartitionOffset}