Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/packages/hyperhive-the-movie.nix
damocles 1c3551b030 hyperhive-the-movie: date-only clock, milestone captions, less elasticity, AV1 webm, --help
The clock shows the date without the time of day. Elasticity drops from 0.3 to 0.1 so the tree sways less through large refactors. Captions come from the git tags and a tracked milestones file with a milestone per component and service at the commit that introduced it, plus growth markers (commit counts, 50k-line steps, issue and PR id doublings). --record writes gource-hyperhive.webm, AV1 in WebM through SVT-AV1, instead of a near-lossless H.264 file. --help (or -h) lists the flags; an unknown argument prints it on stderr and exits 2.
2026-11-11 22:20:50 +01:00

131 lines
4.3 KiB
Nix

# `nix run .#hyperhive-the-movie` — gource visualisation of the git
# history of the repo it is run from. `-- --record` renders
# gource-hyperhive.webm in the cwd instead of opening a window: AV1 in WebM,
# which plays in current Firefox and Chrome and compresses this flat,
# dark picture far better than H.264. Milestones show as captions, from the git
# tags of the repo and from `hyperhive-the-movie-milestones.txt`.
{
lib,
writeShellApplication,
gource,
ffmpeg,
xvfb-run,
librsvg,
curl,
git,
coreutils,
gnugrep,
logo,
}:
writeShellApplication {
name = "hyperhive-the-movie";
runtimeInputs = [
gource
ffmpeg
xvfb-run
librsvg
curl
git
coreutils
gnugrep
];
text = ''
usage() {
cat <<'USAGE'
hyperhive-the-movie - gource visualisation of this repo's git history
Usage: nix run .#hyperhive-the-movie -- [--record | --help]
(no flag) open a gource window and play the history
--record render gource-hyperhive.webm in the current directory
instead (1280x720, 30 fps, AV1 in WebM; plays in recent
Firefox and Chrome). Needs no display.
-h, --help show this text
Run it from inside the repo. Captions come from two places: the git tags
(shown at the tagged commit's date) and the milestones file,
nix/packages/hyperhive-the-movie-milestones.txt, one "YYYY-MM-DD|caption"
per line. Edit that file, or tag a commit with `git tag NAME COMMIT`.
USAGE
}
record=false
case "''${1:-}" in
"") ;;
--record) record=true ;;
-h | --help)
usage
exit 0
;;
*)
echo "hyperhive-the-movie: unknown argument '$1'" >&2
usage >&2
exit 2
;;
esac
cd "$(git rev-parse --show-toplevel)"
# Per-agent avatars from the local forge (same icons the dashboard
# uses), rasterised because --user-image-dir needs png. Cached.
# müde is the human operator: no forge icon.
avatar_dir="''${XDG_CACHE_HOME:-$HOME/.cache}/hyperhive-the-movie/avatars"
mkdir -p "$avatar_dir"
while IFS= read -r author; do
[[ "$author" == "müde" || -f "$avatar_dir/$author.png" ]] && continue
svg="$avatar_dir/$author.svg"
curl -sSf "http://localhost/agent/$author/icon" -o "$svg" 2>/dev/null || rm -f "$svg"
# unknown agents get a 200 html fallback page, not a 404
if [[ -f "$svg" ]]; then
if head -c 200 "$svg" | grep -qi '<svg'; then
rsvg-convert -w 256 -h 256 "$svg" -o "$avatar_dir/$author.png"
fi
rm -f "$svg"
fi
done < <(git log --format='%an' | sort -u)
# Milestone captions, `unix time|text`, sorted by time: the tracked
# milestones file (`YYYY-MM-DD|text`) and the repo's git tags.
captions="$(mktemp)"
trap 'rm -f "$captions"' EXIT
{
while IFS='|' read -r day text; do
[[ -z "$day" || "$day" == \#* ]] && continue
echo "$(date -d "$day" +%s)|$text"
done < ${./hyperhive-the-movie-milestones.txt}
git for-each-ref --format='%(creatordate:unix)|%(refname:short)' refs/tags
} | sort -n > "$captions"
# Catppuccin Mocha, as in frontend/packages/shared/src/colors.css.
args=(
-s 1 -1280x720 --auto-skip-seconds 1 --multi-sampling --stop-at-end
--date-format "%Y-%m-%d"
--caption-file "$captions" --caption-size 28 --caption-duration 4
--caption-colour f9e2af
--background-colour 1e1e2e --font-colour cdd6f4
--highlight-colour f9e2af --highlight-users --highlight-dirs
--filename-colour 585b70 --dir-colour 89b4fa
--bloom-multiplier 1.5 --bloom-intensity 0.75 --elasticity 0.1
--title hyperhive
--logo ${logo} --logo-offset 20x20
--user-image-dir "$avatar_dir"
--key
)
if $record; then
xvfb-run -a --server-args="-screen 0 1280x720x24" \
gource "''${args[@]}" --output-ppm-stream - --output-framerate 30 \
| ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - \
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" \
-c:v libsvtav1 -preset 6 -crf 34 -g 300 -pix_fmt yuv420p \
gource-hyperhive.webm
else
gource "''${args[@]}"
fi
'';
meta = {
description = "gource movie of the hyperhive git history";
mainProgram = "hyperhive-the-movie";
platforms = lib.platforms.linux;
};
}