diff --git a/nixos/doc/manual/release-notes/rl-2003.xml b/nixos/doc/manual/release-notes/rl-2003.xml
index c84bc8dbb37..2bbc42bbec6 100644
--- a/nixos/doc/manual/release-notes/rl-2003.xml
+++ b/nixos/doc/manual/release-notes/rl-2003.xml
@@ -73,7 +73,7 @@
-
+ SD images are now compressed by default using bzip2.
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index a2a8e8ef752..d510f3b2daf 100644
--- a/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -98,6 +98,16 @@ in
populate the ./files/boot (/boot) directory.
'';
};
+
+ compressImage = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Whether the SD image should be compressed using
+ bzip2.
+ '';
+ };
+
};
config = {
@@ -118,10 +128,12 @@ in
sdImage.storePaths = [ config.system.build.toplevel ];
- system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs, mtools, libfaketime, utillinux }: stdenv.mkDerivation {
+ system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs, mtools, libfaketime, utillinux, bzip2 }: stdenv.mkDerivation {
name = config.sdImage.imageName;
- nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux ];
+ nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 ];
+
+ inherit (config.sdImage) compressImage;
buildCommand = ''
mkdir -p $out/nix-support $out/sd-image
@@ -168,6 +180,9 @@ 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
+ if test -n "$compressImage"; then
+ bzip2 $img
+ fi
'';
}) {};