at 23.05-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 14 nativeBuildInputs = [ squashfsTools ]; 15 16 buildCommand = 17 '' 18 closureInfo=${closureInfo { rootPaths = storeContents; }} 19 20 # Also include a manifest of the closures in a format suitable 21 # for nix-store --load-db. 22 cp $closureInfo/registration nix-path-registration 23 24 # 64 cores on i686 does not work 25 # fails with FATAL ERROR: mangle2:: xz compress failed with error code 5 26 if ((NIX_BUILD_CORES > 48)); then 27 NIX_BUILD_CORES=48 28 fi 29 30 # Generate the squashfs image. 31 mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out \ 32 -no-hardlinks -keep-as-directory -all-root -b 1048576 -comp ${comp} \ 33 -processors $NIX_BUILD_CORES 34 ''; 35}