diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2022-02-25 12:56:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-25 12:56:14 +0100 |
commit | f8adc2e087569149646a18da70bd0c09652e609f (patch) | |
tree | fe91d0161d74290144015179b31ac4e0eba5a991 /pkgs | |
parent | a9578062cc0d227d3581a76910da6fcfdd51b738 (diff) | |
parent | 6432e8c08a7b50e1a568d65482fd17b82a9fc57e (diff) | |
download | nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.tar nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.tar.gz nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.tar.bz2 nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.tar.lz nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.tar.xz nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.tar.zst nixpkgs-f8adc2e087569149646a18da70bd0c09652e609f.zip |
Merge pull request #156522 from vs49688/vgmstream
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/applications/audio/vgmstream/default.nix | 33 | ||||
-rwxr-xr-x | pkgs/applications/audio/vgmstream/update.sh | 77 |
2 files changed, 98 insertions, 12 deletions
diff --git a/pkgs/applications/audio/vgmstream/default.nix b/pkgs/applications/audio/vgmstream/default.nix index a3518f23984..f696c506186 100644 --- a/pkgs/applications/audio/vgmstream/default.nix +++ b/pkgs/applications/audio/vgmstream/default.nix @@ -1,26 +1,35 @@ { stdenv, lib, fetchFromGitHub, cmake, pkg-config -, mpg123, ffmpeg, libvorbis, libao, jansson +, mpg123, ffmpeg, libvorbis, libao, jansson, speex }: +let + vgmstreamVersion = "r1702-5596-00bdb165b"; +in stdenv.mkDerivation rec { - pname = "vgmstream"; - version = "r1050-3448-g77cc431b"; + pname = "vgmstream"; + version = "unstable-2022-02-21"; src = fetchFromGitHub { - owner = "vgmstream"; - repo = "vgmstream"; - rev = version; - sha256 = "030q02c9li14by7vm00gn6v3m4dxxmfwiy9iyz3xsgzq1i7pqc1d"; + owner = "vgmstream"; + repo = "vgmstream"; + rev = "00bdb165ba6b55420bbd5b21f54c4f7a825d15a0"; + sha256 = "18g1yqlnf48hi2xn2z2wajnjljpdbfdqmcmi7y8hi1r964ypmfcr"; }; + passthru.updateScript = ./update.sh; + nativeBuildInputs = [ cmake pkg-config ]; - buildInputs = [ mpg123 ffmpeg libvorbis libao jansson ]; + buildInputs = [ mpg123 ffmpeg libvorbis libao jansson speex ]; - # There's no nice way to build the audacious plugin without a circular dependency - cmakeFlags = [ "-DBUILD_AUDACIOUS=OFF" ]; + cmakeFlags = [ + # There's no nice way to build the audacious plugin without a circular dependency + "-DBUILD_AUDACIOUS=OFF" + # It always tries to download it, no option to use the system one + "-DUSE_CELT=OFF" + ]; - preConfigure = '' - echo "#define VERSION \"${version}\"" > cli/version.h + postConfigure = '' + echo "#define VGMSTREAM_VERSION \"${vgmstreamVersion}\"" > ../version.h ''; meta = with lib; { diff --git a/pkgs/applications/audio/vgmstream/update.sh b/pkgs/applications/audio/vgmstream/update.sh new file mode 100755 index 00000000000..5353480dd33 --- /dev/null +++ b/pkgs/applications/audio/vgmstream/update.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash --pure --keep GITHUB_TOKEN -p gnused jq nix-prefetch-git curl cacert + +set -euo pipefail + +ROOT="$(dirname "$(readlink -f "$0")")" +if [[ ! "$(basename $ROOT)" == "vgmstream" || ! -f "$ROOT/default.nix" ]]; then + echo "ERROR: Not in the vgmstream folder" + exit 1 +fi + +if [[ ! -v GITHUB_TOKEN ]]; then + echo "ERROR: \$GITHUB_TOKEN not set" + exit 1 +fi + + +payload=$(jq -cn --rawfile query /dev/stdin '{"query": $query}' <<EOF | curl -s -H "Authorization: bearer $GITHUB_TOKEN" -d '@-' https://api.github.com/graphql +{ + repository(owner: "vgmstream", name: "vgmstream") { + branch: ref(qualifiedName: "refs/heads/master") { + target { + oid + ... on Commit { + committedDate + history { + totalCount + } + } + } + } + + tag: refs(refPrefix: "refs/tags/", first: 1, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) { + nodes { + name + } + } + } +} +EOF +) + +committed_full_date=$(jq -r .data.repository.branch.target.committedDate <<< "$payload") +committed_date=$(sed -nE 's/^([0-9]{4}-[0-9]{2}-[0-9]{2}).+$/\1/p' <<< $committed_full_date) +commit_unix=$(date --utc --date="$committed_date" +%s) +last_updated_unix=$(date --utc --date=$(sed -nE 's/^\s*version\s*=\s*\"unstable-([0-9]{4}-[0-9]{2}-[0-9]{2})\";$/\1/p' default.nix) +%s) + +commit_sha=$(jq -r .data.repository.branch.target.oid <<< "$payload") +major_ver=$(jq -r .data.repository.tag.nodes[0].name <<< "$payload" | sed 's/^v//g') +commit_count=$(jq -r .data.repository.branch.target.history.totalCount <<< "$payload") +final_ver="$major_ver-$commit_count-${commit_sha::9}" + + +echo "INFO: Latest commit is $commit_sha" +echo "INFO: Latest commit date is $committed_full_date" +echo "INFO: Latest version is $final_ver" + +## +# VGMStream has no stable releases, so only update if there's been at +# least a week between commits to reduce maintainer pressure. +## +time_diff=$(( $commit_unix - $last_updated_unix )) +if [[ $time_diff -lt 604800 ]]; then + echo "INFO: Not updating, less than a week between commits." + echo "INFO: $time_diff < 604800" + exit 0 +fi + +nix_sha256=$(nix-prefetch-git --quiet https://github.com/vgmstream/vgmstream.git "$commit_sha" | jq -r .sha256) +echo "INFO: SHA256 is $nix_sha256" + +sed -i -E \ + -e "s/vgmstreamVersion\s*=\s*\"[a-z0-9-]+\";$/vgmstreamVersion = \"${final_ver}\";/g" \ + -e "s/version\s*=\s*\"[a-z0-9-]+\";$/version = \"unstable-${committed_date}\";/g" \ + -e "s/rev\s*=\s*\"[a-z0-9]+\";$/rev = \"${commit_sha}\";/g" \ + -e "s/sha256\s*=\s*\"[a-z0-9]+\";$/sha256 = \"${nix_sha256}\";/g" \ + "$ROOT/default.nix" |