Skip to content

Commit

Permalink
nixos-modules/microvm/store-disk: make squashfs/erofs flags configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Dec 10, 2024
1 parent 1164dfc commit 02c5b7a
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions nixos-modules/microvm/store-disk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,8 @@ let

kernelAtLeast = lib.versionAtLeast config.boot.kernelPackages.kernel.version;

erofsFlags = builtins.concatStringsSep " " (
[ "-zlz4hc" "--force-uid=0" "--force-gid=0" ]
# ++
# lib.optional (kernelAtLeast "5.13") "-C1048576"
++
lib.optional (kernelAtLeast "5.16") "-Eztailpacking"
++
lib.optionals (kernelAtLeast "6.1") [
"-Efragments"
# "-Ededupe"
]
);
erofsFlags = builtins.concatStringsSep " " config.microvm.storeDiskErofsFlags;
squashfsFlags = builtins.concatStringsSep " " config.microvm.storeDiskSquashfsFlags;

writeClosure = pkgs.writeClosure or pkgs.writeReferencesToFile;

Expand All @@ -32,6 +22,28 @@ in
'';
};

storeDiskErofsFlags = mkOption {
type = with types; listOf str;
default =
[
"-zlz4hc"
]
# ++
# lib.optional (kernelAtLeast "5.13") "-C1048576"
++
lib.optional (kernelAtLeast "5.16") "-Eztailpacking"
++
lib.optionals (kernelAtLeast "6.1") [
"-Efragments"
# "-Ededupe"
];
};

storeDiskSquashfsFlags = mkOption {
type = with types; listOf str;
default = [ "-c" "zstd" ];
};

storeDisk = mkOption {
type = types.path;
description = ''
Expand Down Expand Up @@ -81,8 +93,8 @@ in
echo Creating a ${config.microvm.storeDiskType}
${{
squashfs = "gensquashfs -D store --all-root -c zstd -q $out";
erofs = "mkfs.erofs ${erofsFlags} -L nix-store --mount-point=/nix/store $out store";
squashfs = "gensquashfs -D store --all-root -q ${squashfsFlags} $out";
erofs = "mkfs.erofs ${erofsFlags} -T 0 --all-root -L nix-store --mount-point=/nix/store $out store";
}.${config.microvm.storeDiskType}}
'';
})
Expand Down

0 comments on commit 02c5b7a

Please sign in to comment.