diff options
Diffstat (limited to 'pkgs/build-support/kernel/compress-firmware-xz.nix')
-rw-r--r-- | pkgs/build-support/kernel/compress-firmware-xz.nix | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkgs/build-support/kernel/compress-firmware-xz.nix b/pkgs/build-support/kernel/compress-firmware-xz.nix new file mode 100644 index 0000000000000..56595131c891d --- /dev/null +++ b/pkgs/build-support/kernel/compress-firmware-xz.nix @@ -0,0 +1,16 @@ +{ 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 +'' |