Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

fix: pin the runtime media download to the same dataset commit

gerrydorof61eb814363c
diff --git a/docs/NIX.md b/docs/NIX.md
index 94cb82d03..7f4f5f3ab 100644
--- a/docs/NIX.md
+++ b/docs/NIX.md
@@ -464,9 +464,10 @@ routine update — see the passkey caveat in §4.
the same commit the Docker build uses) and stored in the Nix store. `imageRoot`/`gifRoot` point
into `/nix/store`. No `opengym-media` service is created. Ideal for air-gapped/immutable systems;
you pay the ~140 MB fetch on every switch that rebuilds the media derivation.
-- **`media.fetchAtBuild = false`** (default) — the `opengym-media` one-shot clones the upstream
- repo on first boot into `media.dataDir`, then skips while files are present (unpinned — it follows
- upstream's default branch). `imageRoot`/`gifRoot` point under `dataDir`, so backups cover media too.
+- **`media.fetchAtBuild = false`** (default) — the `opengym-media` one-shot downloads the pinned
+ dataset tarball (a GitHub `/archive/<rev>.tar.gz` of the **same commit** `media.nix` pins) on first
+ boot into `media.dataDir`, then skips while files are present. `imageRoot`/`gifRoot` point under
+ `dataDir`, so backups cover media too.
## See also
diff --git a/nix/media-script.nix b/nix/media-script.nix
index 5155d051c..cf27f78b4 100644
--- a/nix/media-script.nix
+++ b/nix/media-script.nix
@@ -1,11 +1,18 @@
{
writeShellScriptBin,
- git,
+ curl,
+ gnutar,
}:
+let
+ # Same commit the build-time fetch (media.nix) pins, so runtime and build-time deployments
+ # serve identical exercise media. Kept in sync via nix/version.nix.
+ rev = "7455efae41b330c265e7cd4b78dfa848e7ce5ebd";
+in
writeShellScriptBin "opengym-fetch-media" ''
set -euo pipefail
MEDIA_DIR="''${1:?Usage: opengym-fetch-media <media-dir>}"
+ MEDIA_URL="''${MEDIA_URL:-https://github.com/hasaneyldrm/exercises-dataset}"
mkdir -p "$MEDIA_DIR/img" "$MEDIA_DIR/gif"
if [ -n "$(ls -A "$MEDIA_DIR/img" 2>/dev/null)" ]; then
@@ -16,8 +23,9 @@ writeShellScriptBin "opengym-fetch-media" ''
echo "Downloading exercise media (~140 MB, one time)..."
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
- ${git}/bin/git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset "$TMPDIR/ds"
- cp "$TMPDIR/ds/images/"*.jpg "$MEDIA_DIR/img/"
- cp "$TMPDIR/ds/videos/"*.gif "$MEDIA_DIR/gif/"
- echo "Exercise media ready."
-''
+ ${curl}/bin/curl -fL --retry 3 "$MEDIA_URL/archive/${rev}.tar.gz" -o "$TMPDIR/dataset.tar.gz"
+ ${gnutar}/bin/tar -xzf "$TMPDIR/dataset.tar.gz" -C "$TMPDIR"
+ cp "$TMPDIR/exercises-dataset-${rev}"/images/*.jpg "$MEDIA_DIR/img/"
+ cp "$TMPDIR/exercises-dataset-${rev}"/videos/*.gif "$MEDIA_DIR/gif/"
+ echo "Exercise media ready (pinned to ${rev})."
+''
\ No newline at end of file