82 lines
2.5 KiB
Nix
82 lines
2.5 KiB
Nix
# `nix run .#hyperhive-the-movie` — gource visualisation of the git
|
|
# history of the repo it is run from. `-- --record` renders
|
|
# gource-hyperhive.mp4 in the cwd instead of opening a window.
|
|
{
|
|
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 = ''
|
|
record=false
|
|
[[ "''${1:-}" == "--record" ]] && record=true
|
|
|
|
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)
|
|
|
|
# Catppuccin Mocha, as in frontend/packages/shared/src/colors.css.
|
|
args=(
|
|
-s 1 -1280x720 --auto-skip-seconds 1 --multi-sampling --stop-at-end
|
|
--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.3
|
|
--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" \
|
|
-vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 \
|
|
gource-hyperhive.mp4
|
|
else
|
|
gource "''${args[@]}"
|
|
fi
|
|
'';
|
|
meta = {
|
|
description = "gource movie of the hyperhive git history";
|
|
mainProgram = "hyperhive-the-movie";
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
}
|