Skip to content

Commit 02c5b7a

Browse files
committed
nixos-modules/microvm/store-disk: make squashfs/erofs flags configurable
1 parent 1164dfc commit 02c5b7a

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

nixos-modules/microvm/store-disk.nix

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,8 @@ let
77

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

10-
erofsFlags = builtins.concatStringsSep " " (
11-
[ "-zlz4hc" "--force-uid=0" "--force-gid=0" ]
12-
# ++
13-
# lib.optional (kernelAtLeast "5.13") "-C1048576"
14-
++
15-
lib.optional (kernelAtLeast "5.16") "-Eztailpacking"
16-
++
17-
lib.optionals (kernelAtLeast "6.1") [
18-
"-Efragments"
19-
# "-Ededupe"
20-
]
21-
);
10+
erofsFlags = builtins.concatStringsSep " " config.microvm.storeDiskErofsFlags;
11+
squashfsFlags = builtins.concatStringsSep " " config.microvm.storeDiskSquashfsFlags;
2212

2313
writeClosure = pkgs.writeClosure or pkgs.writeReferencesToFile;
2414

@@ -32,6 +22,28 @@ in
3222
'';
3323
};
3424

25+
storeDiskErofsFlags = mkOption {
26+
type = with types; listOf str;
27+
default =
28+
[
29+
"-zlz4hc"
30+
]
31+
# ++
32+
# lib.optional (kernelAtLeast "5.13") "-C1048576"
33+
++
34+
lib.optional (kernelAtLeast "5.16") "-Eztailpacking"
35+
++
36+
lib.optionals (kernelAtLeast "6.1") [
37+
"-Efragments"
38+
# "-Ededupe"
39+
];
40+
};
41+
42+
storeDiskSquashfsFlags = mkOption {
43+
type = with types; listOf str;
44+
default = [ "-c" "zstd" ];
45+
};
46+
3547
storeDisk = mkOption {
3648
type = types.path;
3749
description = ''
@@ -81,8 +93,8 @@ in
8193
8294
echo Creating a ${config.microvm.storeDiskType}
8395
${{
84-
squashfs = "gensquashfs -D store --all-root -c zstd -q $out";
85-
erofs = "mkfs.erofs ${erofsFlags} -L nix-store --mount-point=/nix/store $out store";
96+
squashfs = "gensquashfs -D store --all-root -q ${squashfsFlags} $out";
97+
erofs = "mkfs.erofs ${erofsFlags} -T 0 --all-root -L nix-store --mount-point=/nix/store $out store";
8698
}.${config.microvm.storeDiskType}}
8799
'';
88100
})

0 commit comments

Comments
 (0)