nixos/home/hyprland/waybar/flakestat.sh

27 lines
819 B
Bash
Raw Normal View History

2024-04-21 09:46:33 +00:00
#!/usr/bin/env bash
FLAKE_DIR="/home/torjus/nixos"
NIXPKGS_DIR="/home/torjus/git/nixpkgs"
flake_metadata=$(nix flake metadata --json "$FLAKE_DIR" 2>/dev/null)
2024-05-28 17:47:42 +00:00
unstable_input=$(echo "$flake_metadata" | jq '.locks.nodes.root.inputs.nixpkgs')
2024-04-21 09:46:33 +00:00
unstable_rev=$(echo "$flake_metadata" | jq -r ".locks.nodes.$unstable_input.locked.rev")
unstable_branch=$(echo "$flake_metadata" | jq -r ".locks.nodes.$unstable_input.original.ref")
cd "$NIXPKGS_DIR" || exit 1
2024-04-22 22:48:45 +00:00
git fetch -q --all
unstable_commit_count=$(git rev-list --count "$unstable_rev..origin/$unstable_branch")
2024-04-21 09:46:33 +00:00
2024-05-28 17:47:42 +00:00
text="$unstable_commit_count"
tooltip="${unstable_branch}: ${unstable_commit_count}"
2024-04-29 09:51:25 +00:00
output=$(jq -n \
--arg text "$text" \
--arg tooltip "$tooltip" \
--unbuffered \
--compact-output \
'{text: $text, tooltip: $tooltip}')
echo "$output"