flipperzero-firmware: automate getting new versions

This commit is contained in:
Luke Granger-Brown 2023-02-26 10:25:47 +00:00
parent 9239a8a0a6
commit e16892907f
3 changed files with 40 additions and 6 deletions

View file

@ -47,17 +47,15 @@ let
protobuf protobuf
python-with-deps python-with-deps
]; ];
versionData = builtins.fromJSON (builtins.readFile ./version.json);
in in
pkgs.stdenvNoCC.mkDerivation rec { pkgs.stdenvNoCC.mkDerivation rec {
pname = "flipper-firmware"; pname = "flipper-firmware";
version = "RM0217-2335-0.77.2-1f5ae3c"; inherit (versionData) version upstreamVersion;
upstreamVersion = "0.77.2";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git"; inherit (versionData.src) url rev sha256 fetchLFS fetchSubmodules deepClone leaveDotGit;
rev = "1f5ae3c2a2dfe69e6750e4cd181428c37f6cf92d";
fetchSubmodules = true;
sha256 = "sha256:16773vffzm3v02gpylsgi2d61r42w0lapzqirgc3w78qm13qnrbd";
}; };
patches = [ patches = [

View file

@ -0,0 +1,21 @@
#!/usr/bin/env nix-shell
#!nix-shell -p nix-prefetch-git -p jq -i bash
set -euo pipefail
MYTMPDIR="$(mktemp -d)"
trap 'rm -rf -- "$MYTMPDIR"' EXIT
LATEST_VERSION="$(curl --silent -L https://raw.githubusercontent.com/RogueMaster/flipperzero-firmware-wPlugins/HEAD/ReadMe.md | grep -oP '(?<=Latest Release )[^\]]+')"
echo "Latest version $LATEST_VERSION" >&2
UPSTREAM_VERSION="$(echo "${LATEST_VERSION}" | grep -oP '^RM[^-]+-[^-]+-\K([^-]+)(?=-[0-9a-f]+)')"
echo "Upstream version $UPSTREAM_VERSION" >&2
GIT_HASH="$(echo "${LATEST_VERSION}" | grep -oP '^RM[^-]+-[^-]+-([^-]+)-\K[0-9a-f]+')"
echo "Git hash $GIT_HASH"
nix-prefetch-git --fetch-submodules --url "https://github.com/RogueMaster/flipperzero-firmware-wPlugins" --rev "${GIT_HASH}" > $MYTMPDIR/prefetch.json
jq $MYTMPDIR/prefetch.json >&2
jq "{\"src\": ., \"version\": \"${LATEST_VERSION}\", \"upstreamVersion\": \"${UPSTREAM_VERSION}\"}" $MYTMPDIR/prefetch.json > version.json

View file

@ -0,0 +1,15 @@
{
"src": {
"url": "https://github.com/RogueMaster/flipperzero-firmware-wPlugins",
"rev": "3626499318ed3b938e03a36bb77d588285f08b39",
"date": "2023-02-26T03:26:37-05:00",
"path": "/nix/store/xvisbnj42qmxcldq1s6l9rzvv6pz3720-flipperzero-firmware-wPlugins-3626499",
"sha256": "1rgw3cm0gkik2w02d62rrlsglxkgy4b3p7i2pbjy02dsnqylrpmk",
"fetchLFS": false,
"fetchSubmodules": true,
"deepClone": false,
"leaveDotGit": false
},
"version": "RM0226-0327-0.77.2-3626499",
"upstreamVersion": "0.77.2"
}