Merge pull request #191816 from K900/linux-firmware-20220913

linux-firmware: 20220815 -> 20220913, add overengineered update script

authored by Franz Pletz and committed by GitHub 79ef5f03 f6913bcc

+50 -4
+10 -4
pkgs/os-specific/linux/firmware/linux-firmware/default.nix
··· 1 - { stdenvNoCC, fetchzip, lib }: 1 + let 2 + source = import ./source.nix; 3 + in { 4 + stdenvNoCC, 5 + fetchzip, 6 + lib, 7 + }: 2 8 3 9 stdenvNoCC.mkDerivation rec { 4 10 pname = "linux-firmware"; 5 - version = "20220815"; 11 + version = source.version; 6 12 7 13 src = fetchzip { 8 14 url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-${version}.tar.gz"; 9 - sha256 = "sha256-StPlnwn4KOvOf4fRblDzJQqyI8iIz8e9fo/BsTyCKjI="; 15 + hash = source.sourceHash; 10 16 }; 11 17 12 18 installFlags = [ "DESTDIR=$(out)" ]; ··· 16 22 17 23 outputHashMode = "recursive"; 18 24 outputHashAlgo = "sha256"; 19 - outputHash = "sha256-VTRrOOkdWepUCKAkziO/0egb3oaQEOJCtsuDEgs/W78="; 25 + outputHash = source.outputHash; 20 26 21 27 meta = with lib; { 22 28 description = "Binary firmware collection packaged by kernel.org";
+6
pkgs/os-specific/linux/firmware/linux-firmware/source.nix
··· 1 + # This file is autogenerated! Run ./update.sh to regenerate. 2 + { 3 + version = "20220913"; 4 + sourceHash = "sha256-qxSgkytJBW9ux95tEOHfz/4pvOp5TII3ICAY7dg5UC8="; 5 + outputHash = "sha256-eVDXNyx9gwa46pBmsoTU9bQ2XBzkjVocIHydieJ9ruU="; 6 + }
+34
pkgs/os-specific/linux/firmware/linux-firmware/update.sh
··· 1 + #!/usr/bin/env bash 2 + set -euo pipefail 3 + cd "$(dirname "$(readlink -f "$0")")" || exit 4 + 5 + # step 1: figure out the latest version from the tags 6 + repo="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" 7 + latestTag="$(git ls-remote --refs --tags --sort refname "$repo" | tail -n1 | cut -f2 | cut -d '/' -f3)" 8 + 9 + # step 2: prefetch the source tarball 10 + snapshotUrl="$repo/snapshot/linux-firmware-$latestTag.tar.gz" 11 + hash="$(nix-prefetch-url --unpack "$snapshotUrl")" 12 + sriHash="$(nix --experimental-features nix-command hash to-sri "sha256:$hash")" 13 + 14 + # step 3: rebuild as a non-FO derivation to get the right hash 15 + cat > source.nix << EOF 16 + { 17 + version = "$latestTag"; 18 + sourceHash = "$sriHash"; 19 + outputHash = null; 20 + } 21 + EOF 22 + 23 + outPath="$(nix --experimental-features "nix-command flakes" build ".#linux-firmware" --no-link --print-out-paths)" 24 + outHash="$(nix --experimental-features nix-command hash path "$outPath")" 25 + 26 + # step 4: generate the final file 27 + cat > source.nix << EOF 28 + # This file is autogenerated! Run ./update.sh to regenerate. 29 + { 30 + version = "$latestTag"; 31 + sourceHash = "$sriHash"; 32 + outputHash = "$outHash"; 33 + } 34 + EOF