summary refs log tree commit diff
path: root/nixos/modules/installer/cd-dvd/sd-image.nix
diff options
context:
space:
mode:
authorSamuel Dionne-Riel <samuel@dionne-riel.com>2019-06-04 21:33:09 -0400
committerSamuel Dionne-Riel <samuel@dionne-riel.com>2019-06-16 17:47:31 -0400
commitc113c094cf1b8e6c344178aa420c679baef33e17 (patch)
tree7f19c9d8719a18e0e532809dcd00a1984fa6f99d /nixos/modules/installer/cd-dvd/sd-image.nix
parent1843e00146439b226d842a370da63e4a3a04d336 (diff)
downloadnixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.tar
nixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.tar.gz
nixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.tar.bz2
nixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.tar.lz
nixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.tar.xz
nixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.tar.zst
nixpkgs-c113c094cf1b8e6c344178aa420c679baef33e17.zip
sd-image: Pull less slack in the image by accounting for slack
The slack, seemingly, accounted for more than the minimum required for
slack plus the two partitions.

This change makes the gap a somewhat abstracted amount, but is not
configurable within the derivation.
Diffstat (limited to 'nixos/modules/installer/cd-dvd/sd-image.nix')
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image.nix11
1 files changed, 7 insertions, 4 deletions
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index 1faa657885b..5ee594b2336 100644
--- a/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -125,10 +125,13 @@ in
         echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system
         echo "file sd-image $img" >> $out/nix-support/hydra-build-products
 
-        # Create the image file sized to fit /boot/firmware and /, plus 20M of slack
+        # Gap in front of the first partition, in MiB
+        gap=8
+
+        # Create the image file sized to fit /boot/firmware and /, plus slack for the gap.
         rootSizeBlocks=$(du -B 512 --apparent-size ${rootfsImage} | awk '{ print $1 }')
         firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
-        imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + 20 * 1024 * 1024))
+        imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024))
         truncate -s $imageSize $img
 
         # type=b is 'W95 FAT32', type=83 is 'Linux'.
@@ -138,8 +141,8 @@ in
             label: dos
             label-id: ${config.sdImage.firmwarePartitionID}
 
-            start=8M, size=$firmwareSizeBlocks, type=b
-            start=${toString (8 + config.sdImage.firmwareSize)}M, type=83, bootable
+            start=''${gap}M, size=$firmwareSizeBlocks, type=b
+            start=$((gap + ${toString config.sdImage.firmwareSize}))M, type=83, bootable
         EOF
 
         # Copy the rootfs into the SD image