diff --git a/nix/pkgs/flipperzero-firmware/default.nix b/nix/pkgs/flipperzero-firmware/default.nix index 1235cf5b71..bb09f25e51 100644 --- a/nix/pkgs/flipperzero-firmware/default.nix +++ b/nix/pkgs/flipperzero-firmware/default.nix @@ -47,17 +47,15 @@ let protobuf python-with-deps ]; + + versionData = builtins.fromJSON (builtins.readFile ./version.json); in pkgs.stdenvNoCC.mkDerivation rec { pname = "flipper-firmware"; - version = "RM0217-2335-0.77.2-1f5ae3c"; - upstreamVersion = "0.77.2"; + inherit (versionData) version upstreamVersion; src = pkgs.fetchgit { - url = "https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git"; - rev = "1f5ae3c2a2dfe69e6750e4cd181428c37f6cf92d"; - fetchSubmodules = true; - sha256 = "sha256:16773vffzm3v02gpylsgi2d61r42w0lapzqirgc3w78qm13qnrbd"; + inherit (versionData.src) url rev sha256 fetchLFS fetchSubmodules deepClone leaveDotGit; }; patches = [ diff --git a/nix/pkgs/flipperzero-firmware/regen.sh b/nix/pkgs/flipperzero-firmware/regen.sh new file mode 100755 index 0000000000..9fdadc275a --- /dev/null +++ b/nix/pkgs/flipperzero-firmware/regen.sh @@ -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 diff --git a/nix/pkgs/flipperzero-firmware/version.json b/nix/pkgs/flipperzero-firmware/version.json new file mode 100644 index 0000000000..b55842299e --- /dev/null +++ b/nix/pkgs/flipperzero-firmware/version.json @@ -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" +}