google-compute-image: Make GZIP compression level configurable

Change-Id: I1bde130f0a951fa40b1a16bad09497c796bca473
This commit is contained in:
embr 2021-07-13 16:53:09 +02:00
parent 9e18ae4302
commit 91646d62b9

View file

@ -36,6 +36,14 @@ in
`<nixpkgs/nixos/modules/virtualisation/google-compute-image.nix>`.
'';
};
virtualisation.googleComputeImage.compressionLevel = mkOption {
type = types.int;
default = 6;
description = ''
GZIP compression level of the resulting disk image (1-9).
'';
};
};
#### implementation
@ -47,7 +55,8 @@ in
PATH=$PATH:${with pkgs; lib.makeBinPath [ gnutar gzip ]}
pushd $out
mv $diskImage disk.raw
tar -Szcf nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.raw.tar.gz disk.raw
tar -Sc disk.raw | gzip -${toString cfg.compressionLevel} > \
nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.raw.tar.gz
rm $out/disk.raw
popd
'';