initrd: Make compression method an option
This is a semi-internal option. The end-user may want to change it.
Though in reality this is aimed toward device integrators that integrate
a device with a small boot partition.
@@ -181,6 +181,15 @@ let
initrd = makeInitrd {
name = "initrd-${device_config.name}";
inherit contents;
+
+ compressor = {
+ # Default from <nixpkgs/pkgs/build-support/kernel/make-initrd.nix>
+ gzip = "gzip -9n";
+
+ # The `--check` option is required since the kernel's implementation is minimal.
+ # `-e` trades CPU runtime at compression to find the best compression possible.
+ xz = "xz -9 -e --check=crc32";
+ }.${config.mobile.boot.stage-1.compression};
};
# ncdu -f result/initrd.ncdu
@@ -201,6 +210,16 @@ let
in
{
options = {
+ mobile.boot.stage-1.compression = mkOption {
+ type = types.enum [ "gzip" "xz" ];
+ default = "gzip";
+ description = ''
+ The compression method for the stage-1 (initrd).
+
+ This may be set as a default by some devices requiring specific
+ compression methods. Most likely to work around size limitations.
+ '';
+ };
mobile.boot.stage-1.tasks = mkOption {
type = with types; listOf (either package path);
default = [];
