dragnpkgs/lib/make-squashfs/default.nix

24 lines
594 B
Nix
Raw Normal View History

2024-09-14 19:56:09 +00:00
{
squashfsTools,
closureInfo,
runCommand
}:
{
filename ? "image",
storeContents ? [],
comp ? "xz -Xdict-size 100%"
}:
let
compFlag = if comp == null then "-no-compression" else "-comp ${comp}";
in runCommand "${filename}.squashfs" {
nativeBuildInputs = [ squashfsTools ];
} ''
closureInfo=${closureInfo { rootPaths = storeContents; }}
cp $closureInfo/registration nix-path-registration
mksquashfs nix-path-registration $(cat $closureInfo/store-paths) $out \
-no-hardlinks -keep-as-directory -all-root -b 1048576 ${compFlag} \
-processors $NIX_BUILD_CORES
''