From ee024891bd04e87678d74f9f1ebadad16b7ba392 Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 18 Sep 2022 19:37:06 +0300 Subject: [PATCH] linux-firmware: 20220815 -> 20220913, add overengineered update script --- .../linux/firmware/linux-firmware/default.nix | 14 +++++--- .../linux/firmware/linux-firmware/source.nix | 6 ++++ .../linux/firmware/linux-firmware/update.sh | 34 +++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 pkgs/os-specific/linux/firmware/linux-firmware/source.nix create mode 100755 pkgs/os-specific/linux/firmware/linux-firmware/update.sh diff --git a/pkgs/os-specific/linux/firmware/linux-firmware/default.nix b/pkgs/os-specific/linux/firmware/linux-firmware/default.nix index 20058e7bc821..e882ddd69b43 100644 --- a/pkgs/os-specific/linux/firmware/linux-firmware/default.nix +++ b/pkgs/os-specific/linux/firmware/linux-firmware/default.nix @@ -1,12 +1,18 @@ -{ stdenvNoCC, fetchzip, lib }: +let + source = import ./source.nix; +in { + stdenvNoCC, + fetchzip, + lib, +}: stdenvNoCC.mkDerivation rec { pname = "linux-firmware"; - version = "20220815"; + version = source.version; src = fetchzip { url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-${version}.tar.gz"; - sha256 = "sha256-StPlnwn4KOvOf4fRblDzJQqyI8iIz8e9fo/BsTyCKjI="; + hash = source.sourceHash; }; installFlags = [ "DESTDIR=$(out)" ]; @@ -16,7 +22,7 @@ stdenvNoCC.mkDerivation rec { outputHashMode = "recursive"; outputHashAlgo = "sha256"; - outputHash = "sha256-VTRrOOkdWepUCKAkziO/0egb3oaQEOJCtsuDEgs/W78="; + outputHash = source.outputHash; meta = with lib; { description = "Binary firmware collection packaged by kernel.org"; diff --git a/pkgs/os-specific/linux/firmware/linux-firmware/source.nix b/pkgs/os-specific/linux/firmware/linux-firmware/source.nix new file mode 100644 index 000000000000..a0f049ce1347 --- /dev/null +++ b/pkgs/os-specific/linux/firmware/linux-firmware/source.nix @@ -0,0 +1,6 @@ +# This file is autogenerated! Run ./update.sh to regenerate. +{ + version = "20220913"; + sourceHash = "sha256-qxSgkytJBW9ux95tEOHfz/4pvOp5TII3ICAY7dg5UC8="; + outputHash = "sha256-eVDXNyx9gwa46pBmsoTU9bQ2XBzkjVocIHydieJ9ruU="; +} diff --git a/pkgs/os-specific/linux/firmware/linux-firmware/update.sh b/pkgs/os-specific/linux/firmware/linux-firmware/update.sh new file mode 100755 index 000000000000..cd711db7de40 --- /dev/null +++ b/pkgs/os-specific/linux/firmware/linux-firmware/update.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$(readlink -f "$0")")" || exit + +# step 1: figure out the latest version from the tags +repo="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" +latestTag="$(git ls-remote --refs --tags --sort refname "$repo" | tail -n1 | cut -f2 | cut -d '/' -f3)" + +# step 2: prefetch the source tarball +snapshotUrl="$repo/snapshot/linux-firmware-$latestTag.tar.gz" +hash="$(nix-prefetch-url --unpack "$snapshotUrl")" +sriHash="$(nix --experimental-features nix-command hash to-sri "sha256:$hash")" + +# step 3: rebuild as a non-FO derivation to get the right hash +cat > source.nix << EOF +{ + version = "$latestTag"; + sourceHash = "$sriHash"; + outputHash = null; +} +EOF + +outPath="$(nix --experimental-features "nix-command flakes" build ".#linux-firmware" --no-link --print-out-paths)" +outHash="$(nix --experimental-features nix-command hash path "$outPath")" + +# step 4: generate the final file +cat > source.nix << EOF +# This file is autogenerated! Run ./update.sh to regenerate. +{ + version = "$latestTag"; + sourceHash = "$sriHash"; + outputHash = "$outHash"; +} +EOF