diff options
author | Bernardo Meurer <meurerbernardo@gmail.com> | 2019-12-12 23:14:04 -0800 |
---|---|---|
committer | Bernardo Meurer <meurerbernardo@gmail.com> | 2019-12-13 16:18:04 -0800 |
commit | 70c5a7806256518c9e63aceacba881da212a9125 (patch) | |
tree | e57a554f7559abc2e1c5b690cb10c7edc4e929a6 /nixos/modules/installer | |
parent | 476547eb6695226889f9988820954de0346e3c4a (diff) | |
download | nixlib-70c5a7806256518c9e63aceacba881da212a9125.tar nixlib-70c5a7806256518c9e63aceacba881da212a9125.tar.gz nixlib-70c5a7806256518c9e63aceacba881da212a9125.tar.bz2 nixlib-70c5a7806256518c9e63aceacba881da212a9125.tar.lz nixlib-70c5a7806256518c9e63aceacba881da212a9125.tar.xz nixlib-70c5a7806256518c9e63aceacba881da212a9125.tar.zst nixlib-70c5a7806256518c9e63aceacba881da212a9125.zip |
nixos: compress make-ext4-fs with zstd
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r-- | nixos/modules/installer/cd-dvd/sd-image.nix | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix index 7865b767f0b7..901c60befb6c 100644 --- a/nixos/modules/installer/cd-dvd/sd-image.nix +++ b/nixos/modules/installer/cd-dvd/sd-image.nix @@ -18,6 +18,7 @@ with lib; let rootfsImage = pkgs.callPackage ../../../lib/make-ext4-fs.nix ({ inherit (config.sdImage) storePaths; + compressImage = true; populateImageCommands = config.sdImage.populateRootCommands; volumeLabel = "NIXOS_SD"; } // optionalAttrs (config.sdImage.rootPartitionUUID != null) { @@ -128,10 +129,11 @@ in sdImage.storePaths = [ config.system.build.toplevel ]; - system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs, mtools, libfaketime, utillinux, bzip2 }: stdenv.mkDerivation { + system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs, + mtools, libfaketime, utillinux, bzip2, zstd }: stdenv.mkDerivation { name = config.sdImage.imageName; - nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 ]; + nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 zstd ]; inherit (config.sdImage) compressImage; @@ -146,11 +148,14 @@ in echo "file sd-image $img" >> $out/nix-support/hydra-build-products fi + echo "Decompressing rootfs image" + zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img + # 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 }') + rootSizeBlocks=$(du -B 512 --apparent-size ./root-fs.img | awk '{ print $1 }') firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512)) imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024)) truncate -s $imageSize $img @@ -168,7 +173,7 @@ in # Copy the rootfs into the SD image eval $(partx $img -o START,SECTORS --nr 2 --pairs) - dd conv=notrunc if=${rootfsImage} of=$img seek=$START count=$SECTORS + dd conv=notrunc if=./root-fs.img 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) |