|
7 | 7 |
|
8 | 8 | kernelAtLeast = lib.versionAtLeast config.boot.kernelPackages.kernel.version;
|
9 | 9 |
|
| 10 | + erofs-utils = |
| 11 | + # Are any extended options specified? |
| 12 | + if lib.any (with lib; flip elem ["-Ededupe" "-Efragments"]) config.microvm.storeDiskErofsFlags |
| 13 | + then |
| 14 | + # If extended options are present, |
| 15 | + # stick to the single-threaded erofs-utils |
| 16 | + # to not scare anyone with warning messages. |
| 17 | + pkgs.buildPackages.erofs-utils |
| 18 | + else |
| 19 | + # If no extended options are configured, |
| 20 | + # rebuild mkfs.erofs with multi-threading. |
| 21 | + pkgs.buildPackages.erofs-utils.overrideAttrs (attrs: { |
| 22 | + configureFlags = attrs.configureFlags ++ [ |
| 23 | + "--enable-multithreading" |
| 24 | + ]; |
| 25 | + }); |
| 26 | + |
10 | 27 | erofsFlags = builtins.concatStringsSep " " config.microvm.storeDiskErofsFlags;
|
11 | 28 | squashfsFlags = builtins.concatStringsSep " " config.microvm.storeDiskSquashfsFlags;
|
12 | 29 |
|
|
25 | 42 | storeDiskErofsFlags = mkOption {
|
26 | 43 | type = with types; listOf str;
|
27 | 44 | default =
|
28 |
| - [ |
29 |
| - "-zlz4hc" |
30 |
| - ] |
31 |
| - # ++ |
32 |
| - # lib.optional (kernelAtLeast "5.13") "-C1048576" |
| 45 | + [ "-zlz4hc" ] |
33 | 46 | ++
|
34 | 47 | lib.optional (kernelAtLeast "5.16") "-Eztailpacking"
|
35 | 48 | ++
|
36 | 49 | lib.optionals (kernelAtLeast "6.1") [
|
| 50 | + # not implemented with multi-threading |
37 | 51 | "-Efragments"
|
38 |
| - # "-Ededupe" |
| 52 | + "-Ededupe" |
39 | 53 | ];
|
40 | 54 | };
|
41 | 55 |
|
42 | 56 | storeDiskSquashfsFlags = mkOption {
|
43 | 57 | type = with types; listOf str;
|
44 |
| - default = [ "-c" "zstd" ]; |
| 58 | + default = [ "-c" "zstd" "-j" "$NIX_BUILD_CORES" ]; |
45 | 59 | };
|
46 | 60 |
|
47 | 61 | storeDisk = mkOption {
|
|
69 | 83 | ];
|
70 | 84 |
|
71 | 85 | microvm.storeDisk = pkgs.runCommandLocal "microvm-store-disk.${config.microvm.storeDiskType}" {
|
72 |
| - nativeBuildInputs = with pkgs.buildPackages; [ { |
73 |
| - squashfs = [ squashfs-tools-ng ]; |
74 |
| - erofs = [ erofs-utils ]; |
75 |
| - }.${config.microvm.storeDiskType} ]; |
| 86 | + nativeBuildInputs = [ |
| 87 | + { |
| 88 | + squashfs = [ pkgs.buildPackages.squashfs-tools-ng ]; |
| 89 | + erofs = [ erofs-utils ]; |
| 90 | + }.${config.microvm.storeDiskType} |
| 91 | + ]; |
76 | 92 | passthru = {
|
77 | 93 | inherit regInfo;
|
78 | 94 | };
|
|
92 | 108 | done
|
93 | 109 |
|
94 | 110 | echo Creating a ${config.microvm.storeDiskType}
|
95 |
| - ${{ |
96 |
| - squashfs = "gensquashfs -D store --all-root -q ${squashfsFlags} $out"; |
| 111 | + time ${{ |
| 112 | + squashfs = "gensquashfs ${squashfsFlags} -D store --all-root -q $out"; |
97 | 113 | erofs = "mkfs.erofs ${erofsFlags} -T 0 --all-root -L nix-store --mount-point=/nix/store $out store";
|
98 | 114 | }.${config.microvm.storeDiskType}}
|
99 | 115 | '';
|
|
0 commit comments