nixos/home/hyprland/waybar/flakestat.sh
Torjus Håkestad 17fd93c88e
Some checks failed
pre-commit / pre-commit (push) Failing after 16s
Update flakestat
2024-04-23 00:48:45 +02:00

22 lines
960 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)
stable_input=$(echo "$flake_metadata" | jq '.locks.nodes.root.inputs.nixpkgs')
stable_rev=$(echo "$flake_metadata" | jq -r ".locks.nodes.$stable_input.locked.rev")
stable_branch=$(echo "$flake_metadata" | jq -r ".locks.nodes.$stable_input.original.ref")
unstable_input=$(echo "$flake_metadata" | jq '.locks.nodes.root.inputs."nixpkgs-unstable"')
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
stable_commit_count=$(git rev-list --count "$stable_rev..origin/$stable_branch")
unstable_commit_count=$(git rev-list --count "$unstable_rev..origin/$unstable_branch")
echo "$stable_commit_count|$unstable_commit_count"