about summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorAmineChikhaoui <amine.chikhaoui91@gmail.com>2019-09-28 11:57:19 -0400
committerAmineChikhaoui <amine.chikhaoui91@gmail.com>2019-09-30 15:42:13 -0400
commit6ce605e18da7a4b4ef76c47cde8882f322eee3e7 (patch)
treeb512f2f449c0ba5b938f4abc468b968e8cb9ee2d /nixos/modules/installer
parent5afde25a10185b56f348eb6112656ed9ef2d4bb0 (diff)
downloadnixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.tar
nixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.tar.gz
nixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.tar.bz2
nixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.tar.lz
nixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.tar.xz
nixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.tar.zst
nixlib-6ce605e18da7a4b4ef76c47cde8882f322eee3e7.zip
sdImage: add option to enable bzip2 compression
also make SD image compression the default setup.
Fixes issues with output size such as: https://hydra.nixos.org/build/102163603
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image.nix19
1 files changed, 17 insertions, 2 deletions
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index a2a8e8ef7522..d510f3b2daf2 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
+        <command>bzip2</command>.
+      '';
+    };
+
   };
 
   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
       '';
     }) {};