My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/pkgs/build-support/kernel/compress-firmware-xz.nix

16 lines
578 B

{ runCommand }:
firmware:
runCommand "${firmware.name}-xz" {} ''
mkdir -p $out/lib
(cd ${firmware} && find lib/firmware -type d -print0) |
(cd $out && xargs -0 mkdir -v --)
(cd ${firmware} && find lib/firmware -type f -print0) |
(cd $out && xargs -0tP "$NIX_BUILD_CORES" -n1 \
sh -c 'xz -9c -T1 -C crc32 --lzma2=dict=2MiB "${firmware}/$1" > "$1.xz"' --)
(cd ${firmware} && find lib/firmware -type l) | while read link; do
target="$(readlink "${firmware}/$link")"
ln -vs -- "''${target/^${firmware}/$out}.xz" "$out/$link.xz"
done
''