1 { runCommand, lib, type ? "zstd", zstd }:
9 nativeBuildInputs = [ ];
10 cmd = file: target: ''xz -9c -T1 -C crc32 --lzma2=dict=2MiB "${file}" > "${target}"'';
14 nativeBuildInputs = [ zstd ];
15 cmd = file: target: ''zstd -T1 -19 --long --check -f "${file}" -o "${target}"'';
17 }.${type} or (throw "Unsupported compressor type for firmware.");
20 allowedRequisites = [];
21 inherit (compressor) nativeBuildInputs;
22 } // lib.optionalAttrs (firmware ? meta) { inherit (firmware) meta; };
25 runCommand "${firmware.name}-${type}" args ''
27 (cd ${firmware} && find lib/firmware -type d -print0) |
28 (cd $out && xargs -0 mkdir -v --)
29 (cd ${firmware} && find lib/firmware -type f -print0) |
30 (cd $out && xargs -0rtP "$NIX_BUILD_CORES" -n1 \
31 sh -c '${compressor.cmd "${firmware}/$1" "$1.${compressor.ext}"}' --)
32 (cd ${firmware} && find lib/firmware -type l) | while read link; do
33 target="$(readlink "${firmware}/$link")"
34 if [ -f "${firmware}/$link" ]; then
35 ln -vs -- "''${target/^${firmware}/$out}.${compressor.ext}" "$out/$link.${compressor.ext}"
37 ln -vs -- "''${target/^${firmware}/$out}" "$out/$link"
41 echo "Checking for broken symlinks:"
42 find -L $out -type l -print -execdir false -- '{}' '+'