feat(audit): address batch 2 of missing scripts

- Implement nomarchy-version, nomarchy-debug, nomarchy-reinstall, nomarchy-rollback, nomarchy-upload-log
- Implement nomarchy-refresh-hyprland and nomarchy-refresh-waybar
- Update docs/SCRIPTS.md with 'kept' status for new scripts
This commit is contained in:
Bernardo Magri
2026-04-25 22:36:19 +01:00
parent 0728da4374
commit 074dc3576c
8 changed files with 183 additions and 11 deletions

View File

@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# Nomarchy Debug Information Script
# Collects system information for troubleshooting.
set -e
# Flags for agent use to avoid hanging
PRINT_ONLY=false
if [[ "$*" == *"--print"* ]]; then
PRINT_ONLY=true
fi
echo "--- Nomarchy Debug Info ---"
echo "Version: $(nomarchy-version)"
echo "Host: $(hostname)"
echo "Kernel: $(uname -r)"
echo "Uptime: $(uptime -p)"
echo ""
echo "--- Graphics ---"
if command -v hyprctl &>/dev/null; then
hyprctl version | head -n 1
fi
if command -v glxinfo &>/dev/null; then
glxinfo | grep "OpenGL renderer" || echo "OpenGL: info not available"
fi
echo ""
echo "--- Nix/NixOS ---"
nix --version
if [[ -f /etc/os-release ]]; then
grep "PRETTY_NAME" /etc/os-release | cut -d'"' -f2
fi
echo ""
echo "--- Nomarchy State ---"
STATE_FILE="$HOME/.config/nomarchy/state.json"
if [[ -f "$STATE_FILE" ]]; then
jq '.' "$STATE_FILE"
else
echo "State file not found at $STATE_FILE"
fi
echo ""
echo "--- Services Status ---"
for svc in waybar hypridle hyprlock walker fprintd fwupd; do
if systemctl is-active --quiet "$svc" 2>/dev/null || systemctl --user is-active --quiet "$svc" 2>/dev/null; then
echo "[ACTIVE] $svc"
else
echo "[INACTIVE] $svc"
fi
done
echo ""
echo "--- End of Debug Info ---"
if [[ "$PRINT_ONLY" == "false" ]]; then
echo ""
echo "Would you like to upload this log to a pastebin? (y/N)"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
if command -v nomarchy-upload-log &>/dev/null; then
nomarchy-debug --print | nomarchy-upload-log
else
echo "Error: nomarchy-upload-log not found."
fi
fi
fi

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Nomarchy Refresh Hyprland Script
# Reloads the Hyprland configuration.
set -e
if command -v hyprctl &>/dev/null; then
hyprctl reload
notify-send -u low " Hyprland configuration reloaded"
else
echo "Error: hyprctl not found."
exit 1
fi

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Nomarchy Refresh Waybar Script
# Restarts Waybar to apply new configuration or theme.
set -e
if command -v nomarchy-restart-waybar &>/dev/null; then
nomarchy-restart-waybar
notify-send -u low "󰍜 Waybar refreshed"
else
echo "Error: nomarchy-restart-waybar not found."
exit 1
fi

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Nomarchy Reinstall Script
# Performs a fresh 'switch' to the current declarative state.
set -e
# Detect the repository location
if [ -f "/etc/nixos/flake.nix" ]; then
REPO_DIR="/etc/nixos"
elif [ -f "/etc/nomarchy/flake.nix" ]; then
REPO_DIR="/etc/nomarchy"
else
echo "Error: Nomarchy flake repository not found in /etc/nixos or /etc/nomarchy."
exit 1
fi
echo "Performing system reinstall from $REPO_DIR..."
# --refresh forces a download of flake inputs if they've changed upstream but not in lock
sudo nixos-rebuild switch --flake "$REPO_DIR#default" --refresh --impure
echo "Reinstall complete."

View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Nomarchy Rollback Script
# Reverts the system to a previous working generation.
set -e
if command -v snapper &>/dev/null; then
echo "BTRFS Snapper detected. Listing snapshots..."
sudo snapper list
echo ""
echo "To rollback to a specific snapshot, run: sudo snapper rollback <number>"
echo "Or to rollback the current NixOS generation only:"
fi
echo "Rolling back NixOS generation..."
sudo nixos-rebuild rollback
echo "Rollback complete. Please reboot if you performed a BTRFS rollback."

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Nomarchy Log Upload Script
# Uploads stdin or a file to a pastebin service.
set -e
if [[ -t 0 ]] && [[ -z $1 ]]; then
echo "Usage: some-command | nomarchy-upload-log"
echo " nomarchy-upload-log <file>"
exit 1
fi
# Use ix.io as the default pastebin
if [[ -n $1 ]]; then
url=$(curl -F "f:1=@$1" ix.io)
else
url=$(curl -F "f:1=@-" ix.io)
fi
echo "Log uploaded to: $url"
if command -v wl-copy &>/dev/null; then
echo "$url" | wl-copy
echo "Link copied to clipboard."
fi

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Nomarchy Version Script
# Prints the current Nomarchy version based on the upstream NixOS channel.
VERSION="25.11.0"
CODENAME="Markhor"
echo "Nomarchy v${VERSION} (${CODENAME})"