From 04ecfade8a19839595a898ef1ace9394b00fdbdc Mon Sep 17 00:00:00 2001 From: Mysaa Java Date: Fri, 17 Apr 2026 16:42:11 +0200 Subject: [PATCH] ocamlPackages.elpi: Add update.sh --- .../ocaml-modules/elpi/default.nix | 2 ++ pkgs/development/ocaml-modules/elpi/update.sh | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 pkgs/development/ocaml-modules/elpi/update.sh diff --git a/pkgs/development/ocaml-modules/elpi/default.nix b/pkgs/development/ocaml-modules/elpi/default.nix index 553ffabd31f8..4a2f2e50e8c0 100644 --- a/pkgs/development/ocaml-modules/elpi/default.nix +++ b/pkgs/development/ocaml-modules/elpi/default.nix @@ -109,6 +109,8 @@ buildDunePackage { ] ); + passthru.updateScript = ./update.sh; + meta = { description = "Embeddable λProlog Interpreter"; license = lib.licenses.lgpl21Plus; diff --git a/pkgs/development/ocaml-modules/elpi/update.sh b/pkgs/development/ocaml-modules/elpi/update.sh new file mode 100755 index 000000000000..3f6cf03b9292 --- /dev/null +++ b/pkgs/development/ocaml-modules/elpi/update.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnugrep gnused jq + +set -euo pipefail + +cd $(dirname ${BASH_SOURCE[0]}) + +# Detect latest tag +latestVersion=$(curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ + 'https://api.github.com/repos/LPCIC/elpi/releases' | jq -r 'map(.tag_name).[0]' | sed 's/^v//') + +# Detect current tag +currentVersion=$(sed -e "/ if lib.versionAtLeast ocaml.version \"4.13\" then/{n;q}" default.nix | tail -n 1 | sed 's/[[:space:]"]//g') + +if [ "$latestVersion" == "$currentVersion" ] +then + echo "Already up to date" + exit 0 +fi + +# Get hash for latest tag +versionCommit=$(curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ + 'https://api.github.com/repos/LPCIC/elpi/tags' | \ + jq -r "map(select(.name == \"v$latestVersion\")) | .[0] | .commit.sha") + +ELPI_GIT_PREFETCH=$(nix-prefetch-url --unpack https://github.com/LPCIC/elpi/archive/${versionCommit}.tar.gz) +ELPI_GIT_HASH=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 ${ELPI_GIT_PREFETCH}) + +# We register the new version +sed "/fetched = coqPackages.metaFetch {/a\\ release.\"$latestVersion\".sha256 = \"$ELPI_GIT_HASH\";" -i default.nix + +# We set it as default +sed "/ if lib.versionAtLeast ocaml.version \"4.13\" then/{n;d}" -i default.nix +sed "/ else if lib.versionAtLeast ocaml.version \"4.08\" then/i\\ \"$latestVersion\"" -i default.nix