Merge pull request #325301 from flokli/linux-firmware-no-fod

linux-firmware: remove FOD
This commit is contained in:
Florian Klink 2024-07-08 08:14:53 +03:00 committed by GitHub
commit 71eca75204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 66 deletions

View File

@ -1,20 +1,17 @@
let
source = import ./source.nix;
in {
stdenvNoCC,
fetchzip,
lib,
rdfind,
which,
{ stdenvNoCC
, fetchzip
, lib
, rdfind
, which
}:
stdenvNoCC.mkDerivation rec {
pname = "linux-firmware";
version = source.version;
version = "20240610";
src = fetchzip {
url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-${source.revision}.tar.gz";
hash = source.sourceHash;
url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-${version}.tar.gz";
hash = "sha256-tjDqviOMvrBoEG8+Yn+XqdBlIDfQUX0KK2kpW6/jed8=";
};
nativeBuildInputs = [
@ -27,10 +24,6 @@ stdenvNoCC.mkDerivation rec {
# Firmware blobs do not need fixing and should not be modified
dontFixup = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = source.outputHash;
meta = with lib; {
description = "Binary firmware collection packaged by kernel.org";
homepage = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git";
@ -39,6 +32,5 @@ stdenvNoCC.mkDerivation rec {
maintainers = with maintainers; [ fpletz ];
priority = 6; # give precedence to kernel firmware
};
passthru.updateScript = ./update.sh;
}

View File

@ -1,7 +0,0 @@
# This file is autogenerated! Run ./update.sh to regenerate.
{
version = "20240610";
revision = "20240610";
sourceHash = "sha256-tjDqviOMvrBoEG8+Yn+XqdBlIDfQUX0KK2kpW6/jed8=";
outputHash = "sha256-2VxzN778TLov5N1DPSnnkT7wQnLg85PyKsljZOoSoNM=";
}

View File

@ -1,47 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$(readlink -f "$0")")" || exit
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git -p common-updater-scripts
set -eu -o pipefail
repo="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
# step 1: figure out the latest version from the tags
if [ -z "${1:-}" ]; then
revision="$(git ls-remote --refs --tags --sort refname "$repo" | tail -n1 | cut -f2 | cut -d '/' -f3)"
version=$revision
else
revision=$1
if [ -z "${2:-}" ]; then
version="unstable-$(date "+%Y-%m-%d")"
else
version=$2
fi
fi
revision="$(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-$revision.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 = "$version";
revision = "$revision";
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 = "$version";
revision = "$revision";
sourceHash = "$sriHash";
outputHash = "$outHash";
}
EOF
update-source-version linux-firmware "$revision"