1 { lib, stdenv, squashfsTools, closureInfo
3 , fileName ? "squashfs"
4 , # The root directory of the squashfs filesystem is filled with the
5 # closures of the Nix store paths listed here.
7 # Pseudo files to be added to squashfs image
10 , # Compression parameters.
11 # For zstd compression you can use "zstd -Xcompression-level 6".
12 comp ? "xz -Xdict-size 100%"
16 pseudoFilesArgs = lib.concatMapStrings (f: ''-p "${f}" '') pseudoFiles;
19 name = "${fileName}.img";
20 __structuredAttrs = true;
22 nativeBuildInputs = [ squashfsTools ];
26 closureInfo=${closureInfo { rootPaths = storeContents; }}
28 # Also include a manifest of the closures in a format suitable
29 # for nix-store --load-db.
30 cp $closureInfo/registration nix-path-registration
32 '' + lib.optionalString stdenv.buildPlatform.is32bit ''
33 # 64 cores on i686 does not work
34 # fails with FATAL ERROR: mangle2:: xz compress failed with error code 5
35 if ((NIX_BUILD_CORES > 48)); then
40 # Generate the squashfs image.
41 mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out ${pseudoFilesArgs} \
42 -no-hardlinks ${lib.optionalString noStrip "-no-strip"} -keep-as-directory -all-root -b 1048576 -comp ${comp} \
43 -processors $NIX_BUILD_CORES