nixos/home/hyprland/waybar/flakestat.sh
Torjus Håkestad 65c166c4af
Some checks failed
pre-commit / pre-commit (push) Failing after 28s
Fix flakestat after unstable switch
2024-05-28 19:47:42 +02:00

27 lines
819 B
Bash

#!/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)
unstable_input=$(echo "$flake_metadata" | jq '.locks.nodes.root.inputs.nixpkgs')
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
git fetch -q --all
unstable_commit_count=$(git rev-list --count "$unstable_rev..origin/$unstable_branch")
text="$unstable_commit_count"
tooltip="${unstable_branch}: ${unstable_commit_count}"
output=$(jq -n \
--arg text "$text" \
--arg tooltip "$tooltip" \
--unbuffered \
--compact-output \
'{text: $text, tooltip: $tooltip}')
echo "$output"