Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to skip compression during build #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions sd-image/sd-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with lib;
let
rootfsImage = pkgs.callPackage "${modulesPath}/../lib/make-ext4-fs.nix" ({
inherit (config.sdImage) storePaths;
compressImage = true;
compressImage = config.sdImage.compressDuringBuild;
populateImageCommands = config.sdImage.populateRootCommands;
volumeLabel = "NIXOS_SD";
} // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
Expand Down Expand Up @@ -141,6 +141,14 @@ in
'';
};

compressDuringBuild = mkOption {
type = types.bool;
default = true;
description = ''
Whether the SD image should be compressed during intermediate build steps (saving cache space, but takes longer)
'';
};

expandOnBoot = mkOption {
type = types.bool;
default = true;
Expand Down Expand Up @@ -172,7 +180,7 @@ in
nativeBuildInputs =
[ dosfstools e2fsprogs mtools libfaketime util-linux zstd ];

inherit (config.sdImage) compressImage;
inherit (config.sdImage) compressImage compressDuringBuild;

buildCommand = ''
mkdir -p $out/nix-support $out/sd-image
Expand All @@ -185,8 +193,12 @@ 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
if test -n "$compressDuringBuild"; then
echo "Decompressing rootfs image"
zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img
else
ln -s "${rootfsImage}" ./root-fs.img
fi

# Gap in front of the first partition, in MiB
gap=${toString config.sdImage.firmwarePartitionOffset}
Expand Down