Files
Nomarchy/features/scripts/utils/nomarchy-update-available
Bernardo Magri 1e6becd42d
All checks were successful
Check / eval-and-lint (push) Successful in 7m5s
fix(scripts): improve offline resilience and restore missing update scripts
2026-06-01 20:07:08 +01:00

30 lines
771 B
Bash

#!/usr/bin/env bash
set -e
# Nomarchy Update Available Script
# Checks if flake updates are available and returns info for Waybar
REPO_DIR=""
if [ -f "/etc/nixos/flake.nix" ]; then
REPO_DIR="/etc/nixos"
elif [ -f "/etc/nomarchy/flake.nix" ]; then
REPO_DIR="/etc/nomarchy"
fi
if [ -z "$REPO_DIR" ]; then
echo "Nomarchy repo not found."
exit 0
fi
# Fast-fail if offline to avoid expensive nix commands.
if ! ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1; then
exit 0
fi
# Get current status
CURRENT_REV=$(nix flake metadata "$REPO_DIR" --json | jq -r '.lock.nodes.root.inputs.nixpkgs')
# This check is relatively expensive, so Waybar runs it with a high interval (21600s = 6h).
# Just return an icon if we are in a system that can be updated.
echo ""