2023-06-24 23:08:28 +02:00
|
|
|
{ runCommand, lib }:
|
2022-05-12 17:23:12 +02:00
|
|
|
|
|
|
|
firmware:
|
|
|
|
|
2023-06-24 23:08:28 +02:00
|
|
|
let
|
|
|
|
args = lib.optionalAttrs (firmware ? meta) { inherit (firmware) meta; };
|
|
|
|
in
|
|
|
|
|
|
|
|
runCommand "${firmware.name}-xz" args ''
|
2022-05-12 17:23:12 +02:00
|
|
|
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) |
|
2022-05-26 09:06:13 +02:00
|
|
|
(cd $out && xargs -0rtP "$NIX_BUILD_CORES" -n1 \
|
2022-05-12 17:23:12 +02:00
|
|
|
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
|
|
|
|
''
|