at 23.11-pre 1.1 kB view raw
1{ stdenv, squashfsTools, closureInfo 2 3, # The root directory of the squashfs filesystem is filled with the 4 # closures of the Nix store paths listed here. 5 storeContents ? [] 6, # Compression parameters. 7 # For zstd compression you can use "zstd -Xcompression-level 6". 8 comp ? "xz -Xdict-size 100%" 9}: 10 11stdenv.mkDerivation { 12 name = "squashfs.img"; 13 __structuredAttrs = true; 14 15 nativeBuildInputs = [ squashfsTools ]; 16 17 buildCommand = 18 '' 19 closureInfo=${closureInfo { rootPaths = storeContents; }} 20 21 # Also include a manifest of the closures in a format suitable 22 # for nix-store --load-db. 23 cp $closureInfo/registration nix-path-registration 24 25 # 64 cores on i686 does not work 26 # fails with FATAL ERROR: mangle2:: xz compress failed with error code 5 27 if ((NIX_BUILD_CORES > 48)); then 28 NIX_BUILD_CORES=48 29 fi 30 31 # Generate the squashfs image. 32 mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out \ 33 -no-hardlinks -keep-as-directory -all-root -b 1048576 -comp ${comp} \ 34 -processors $NIX_BUILD_CORES 35 ''; 36}