Unverified Commit 71eca752 authored by Florian Klink's avatar Florian Klink Committed by GitHub
Browse files

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

linux-firmware: remove FOD
parents 606a3e98 6f2d668d
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
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;
}
+0 −7
Original line number Diff line number Diff line
# This file is autogenerated! Run ./update.sh to regenerate.
{
  version = "20240610";
  revision = "20240610";
  sourceHash = "sha256-tjDqviOMvrBoEG8+Yn+XqdBlIDfQUX0KK2kpW6/jed8=";
  outputHash = "sha256-2VxzN778TLov5N1DPSnnkT7wQnLg85PyKsljZOoSoNM=";
}
+6 −43
Original line number Diff line number Diff line
#!/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

# 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"