From 6ce605e18da7a4b4ef76c47cde8882f322eee3e7 Mon Sep 17 00:00:00 2001 From: AmineChikhaoui Date: Sat, 28 Sep 2019 11:57:19 -0400 Subject: [PATCH] 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 --- nixos/doc/manual/release-notes/rl-2003.xml | 2 +- nixos/modules/installer/cd-dvd/sd-image.nix | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) 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 ''; }) {};