about summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorwucke13 <wucke13@gmail.com>2021-12-19 13:39:42 +0100
committerwucke13 <wucke13@gmail.com>2021-12-21 21:31:44 +0100
commit121e2f7e1554794e7392427cf77e94ab9887871e (patch)
tree83dbeb674f76007326554aa2d8bafa2cda057a40 /nixos/modules/installer
parentd4a497382befcde76470e4ebb8f89062fe354c7d (diff)
downloadnixlib-121e2f7e1554794e7392427cf77e94ab9887871e.tar
nixlib-121e2f7e1554794e7392427cf77e94ab9887871e.tar.gz
nixlib-121e2f7e1554794e7392427cf77e94ab9887871e.tar.bz2
nixlib-121e2f7e1554794e7392427cf77e94ab9887871e.tar.lz
nixlib-121e2f7e1554794e7392427cf77e94ab9887871e.tar.xz
nixlib-121e2f7e1554794e7392427cf77e94ab9887871e.tar.zst
nixlib-121e2f7e1554794e7392427cf77e94ab9887871e.zip
honor sdImage.compressImage in intermediate build steps
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r--nixos/modules/installer/sd-card/sd-image.nix15
1 files changed, 10 insertions, 5 deletions
diff --git a/nixos/modules/installer/sd-card/sd-image.nix b/nixos/modules/installer/sd-card/sd-image.nix
index a964cf2d6f85..1fd2db39fc56 100644
--- a/nixos/modules/installer/sd-card/sd-image.nix
+++ b/nixos/modules/installer/sd-card/sd-image.nix
@@ -18,7 +18,7 @@ with lib;
 let
   rootfsImage = pkgs.callPackage ../../../lib/make-ext4-fs.nix ({
     inherit (config.sdImage) storePaths;
-    compressImage = true;
+    compressImage = config.sdImage.compressImage;
     populateImageCommands = config.sdImage.populateRootCommands;
     volumeLabel = "NIXOS_SD";
   } // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
@@ -174,7 +174,8 @@ in
     mtools, libfaketime, util-linux, zstd }: stdenv.mkDerivation {
       name = config.sdImage.imageName;
 
-      nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime util-linux zstd ];
+      nativeBuildInputs = [ dosfstools e2fsprogs libfaketime mtools util-linux ]
+      ++ lib.optional config.sdImage.compressImage zstd;
 
       inherit (config.sdImage) compressImage;
 
@@ -189,14 +190,18 @@ in
           echo "file sd-image $img" >> $out/nix-support/hydra-build-products
         fi
 
+        root_fs=${rootfsImage}
+        ${lib.optionalString config.sdImage.compressImage ''
+        root_fs=./root-fs.img
         echo "Decompressing rootfs image"
-        zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img
+        zstd -d --no-progress "${rootfsImage}" -o $root_fs
+        ''}
 
         # Gap in front of the first partition, in MiB
         gap=${toString config.sdImage.firmwarePartitionOffset}
 
         # Create the image file sized to fit /boot/firmware and /, plus slack for the gap.
-        rootSizeBlocks=$(du -B 512 --apparent-size ./root-fs.img | awk '{ print $1 }')
+        rootSizeBlocks=$(du -B 512 --apparent-size $root_fs | awk '{ print $1 }')
         firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
         imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024))
         truncate -s $imageSize $img
@@ -214,7 +219,7 @@ in
 
         # Copy the rootfs into the SD image
         eval $(partx $img -o START,SECTORS --nr 2 --pairs)
-        dd conv=notrunc if=./root-fs.img of=$img seek=$START count=$SECTORS
+        dd conv=notrunc if=$root_fs of=$img seek=$START count=$SECTORS
 
         # Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img
         eval $(partx $img -o START,SECTORS --nr 1 --pairs)