aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/media/screen-recording/screen-recording.sh24
-rw-r--r--modules/networking/usque/usque-warp.sh75
-rw-r--r--modules/security/gopass/gopass-ssh-load.sh13
-rw-r--r--modules/security/gopass/gopass-sync-init.sh13
-rw-r--r--modules/security/gpg/gpg-backup.sh63
-rw-r--r--modules/system/deep-clean/deep-clean.sh26
-rw-r--r--modules/system/nix-update/nix-update.sh43
7 files changed, 141 insertions, 116 deletions
diff --git a/modules/media/screen-recording/screen-recording.sh b/modules/media/screen-recording/screen-recording.sh
index 336c32e..f4e65ab 100644
--- a/modules/media/screen-recording/screen-recording.sh
+++ b/modules/media/screen-recording/screen-recording.sh
@@ -2,11 +2,10 @@
OUT_DIR="$HOME/Videos/Recordings"
mkdir -p "$OUT_DIR"
-# Colors
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-RED='\033[0;31m'
-NC='\033[0m'
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
# Argument parsing
SELECT_MODE=false
@@ -22,15 +21,15 @@ GEOMETRY=""
if [ "$SELECT_MODE" = true ]; then
if command -v slurp >/dev/null 2>&1; then
- echo -e "${YELLOW}Select a window or draw a box...${NC}"
+ info "Select a window or draw a box..."
GEOMETRY=$(slurp)
if [ -z "$GEOMETRY" ]; then
- echo "Selection cancelled. Exiting."
+ info "Selection cancelled. Exiting."
exit 1
fi
else
- echo -e "${RED}Error: 'slurp' not found.${NC} Recording full screen..."
+ warn "slurp not found. Recording full screen..."
sleep 1
fi
fi
@@ -38,10 +37,9 @@ fi
# Start recording
FILENAME="$OUT_DIR/recording-$(date +%Y%m%d-%H%M%S).mp4"
-echo -e "${GREEN}Recording started!${NC}"
-echo -e "Press ${YELLOW}'q'${NC} in this terminal to stop."
-echo "File: $FILENAME"
-echo "------------------------------------------------"
+info "Recording started!"
+echo " Press 'q' in this terminal to stop."
+echo " File: $FILENAME"
if [ -n "$GEOMETRY" ]; then
wf-recorder -g "$GEOMETRY" -f "$FILENAME"
@@ -49,4 +47,4 @@ else
wf-recorder -f "$FILENAME"
fi
-echo -e "\n${GREEN}Done!${NC} Video saved to $FILENAME"
+info "Done! Video saved to $FILENAME" \ No newline at end of file
diff --git a/modules/networking/usque/usque-warp.sh b/modules/networking/usque/usque-warp.sh
index 9d32872..8531859 100644
--- a/modules/networking/usque/usque-warp.sh
+++ b/modules/networking/usque/usque-warp.sh
@@ -1,5 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
+
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
+
CONFIG_DIR="$HOME/.cache/usque"
CONFIG="$CONFIG_DIR/config.json"
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp}"
@@ -29,22 +35,21 @@ is_running() {
}
ensure_config() {
- echo "Creating $CONFIG_DIR..."
+ info "Creating $CONFIG_DIR..."
mkdir -p "$CONFIG_DIR"
- echo "Registering Cloudflare WARP account..."
+ info "Registering Cloudflare WARP account..."
usque -c "$CONFIG" register < <(yes)
if [[ ! -f "$CONFIG" ]]; then
- echo "Failed to create config file: $CONFIG"
- exit 1
+ die "Failed to create config file: $CONFIG"
fi
- echo "Config created successfully."
+ info "Config created successfully."
}
remove_tun_default_routes() {
local dev="$1"
while ip route show | grep -qE "^default .*dev $dev"; do
ROUTE=$(ip route show | grep -E "^default .*dev $dev" | head -n1)
- echo "Removing route: $ROUTE"
+ info "Removing route: $ROUTE"
sudo ip route del "$ROUTE" || break
done
}
@@ -55,30 +60,28 @@ connect() {
if [[ -f "$PID_FILE" ]]; then
OLD_PID=$(cat "$PID_FILE")
if sudo kill -0 "$OLD_PID" 2>/dev/null; then
- echo "usque-warp is already running (PID $OLD_PID)"
- exit 1
+ die "usque-warp is already running (PID $OLD_PID)"
else
- echo "Removing stale PID file..."
+ info "Removing stale PID file..."
rm -f "$PID_FILE"
fi
fi
- echo "Saving current default route..."
+ info "Saving current default route..."
DEFAULT_ROUTE=$(ip route show default | grep -vE 'dev tun[0-9]+' | head -n1)
if [[ -z "$DEFAULT_ROUTE" ]]; then
- echo "Could not determine current default route"
- exit 1
+ die "Could not determine current default route"
fi
echo "$DEFAULT_ROUTE" > "$STATE_FILE"
- echo "Recording pre-existing tun interfaces..."
+ info "Recording pre-existing tun interfaces..."
BEFORE_IFACES=$(list_tun_ifaces)
- echo "Starting usque..."
+ info "Starting usque..."
sudo usque nativetun -c "$CONFIG" 2>&1 | sudo tee "$LOG_FILE" >/dev/null &
echo $! > "$PID_FILE"
- echo "Waiting for MASQUE connection..."
+ info "Waiting for MASQUE connection..."
MASQUE_IP=""
for _ in {1..30}; do
MASQUE_IP=$(grep -oP 'MASQUE connection to \K[0-9.]+(?=:443)' "$LOG_FILE" 2>/dev/null || true)
@@ -88,13 +91,13 @@ connect() {
sleep 1
done
if [[ -z "$MASQUE_IP" ]]; then
- echo "Failed to detect MASQUE endpoint"
+ error "Failed to detect MASQUE endpoint"
sudo kill "$(cat "$PID_FILE")" 2>/dev/null || true
rm -f "$PID_FILE"
exit 1
fi
- echo "Waiting for usque interface..."
+ info "Waiting for usque interface..."
TUN_DEV=""
for _ in {1..30}; do
AFTER_IFACES=$(list_tun_ifaces)
@@ -103,39 +106,38 @@ connect() {
sleep 1
done
if [[ -z "$TUN_DEV" ]]; then
- echo "Failed to detect usque interface"
+ error "Failed to detect usque interface"
sudo kill "$(cat "$PID_FILE")" 2>/dev/null || true
rm -f "$PID_FILE"
exit 1
fi
echo "$TUN_DEV" > "$IFACE_FILE"
- echo "Detected interface: $TUN_DEV"
+ info "Detected interface: $TUN_DEV"
GATEWAY=$(echo "$DEFAULT_ROUTE" | awk '{for(i=1;i<=NF;i++) if($i=="via") print $(i+1)}')
INTERFACE=$(echo "$DEFAULT_ROUTE" | awk '{for(i=1;i<=NF;i++) if($i=="dev") print $(i+1)}')
if [[ -z "$GATEWAY" || -z "$INTERFACE" ]]; then
- echo "Cannot determine gateway/interface"
- exit 1
+ die "Cannot determine gateway/interface"
fi
echo "MASQUE_IP=$MASQUE_IP GATEWAY=$GATEWAY INTERFACE=$INTERFACE" >> "$STATE_FILE"
- echo "Allowing MASQUE endpoint outside tunnel..."
+ info "Allowing MASQUE endpoint outside tunnel..."
sudo ip route replace \
"$MASQUE_IP" \
via "$GATEWAY" \
dev "$INTERFACE"
- echo "Removing old tun routes..."
+ info "Removing old tun routes..."
remove_tun_default_routes "$TUN_DEV"
- echo "Switching default route to $TUN_DEV..."
+ info "Switching default route to $TUN_DEV..."
sudo ip route add default dev "$TUN_DEV" metric 1
- echo "Connected"
+ info "Connected."
}
disconnect() {
sudo -v
- echo "Disconnecting..."
+ info "Disconnecting..."
local dev
if [[ -f "$IFACE_FILE" ]]; then
dev=$(cat "$IFACE_FILE")
@@ -149,7 +151,7 @@ disconnect() {
if [[ -f "$PID_FILE" ]]; then
PID=$(cat "$PID_FILE")
if sudo kill -0 "$PID" 2>/dev/null; then
- echo "Stopping usque..."
+ info "Stopping usque..."
sudo kill "$PID" 2>/dev/null || true
for _ in {1..20}; do
sudo kill -0 "$PID" 2>/dev/null || break
@@ -162,7 +164,7 @@ disconnect() {
# Belt-and-braces: if the interface (or any of its routes) somehow
# survived, clean them up explicitly. No-ops if tun0 is already gone.
if [[ -n "${dev:-}" ]]; then
- echo "Flushing $dev routes..."
+ info "Flushing $dev routes..."
sudo ip route flush dev "$dev" 2>/dev/null || true
remove_tun_default_routes "$dev"
fi
@@ -170,7 +172,7 @@ disconnect() {
if [[ -f "$STATE_FILE" ]]; then
MASQUE_IP=$(grep -oP 'MASQUE_IP=\K[0-9.]+' "$STATE_FILE" || true)
if [[ -n "$MASQUE_IP" ]]; then
- echo "Removing MASQUE route: $MASQUE_IP"
+ info "Removing MASQUE route: $MASQUE_IP"
sudo ip route del "$MASQUE_IP" 2>/dev/null || true
fi
@@ -178,16 +180,16 @@ disconnect() {
# assuming it's still intact. 'replace' is idempotent.
ORIGINAL_DEFAULT=$(head -n1 "$STATE_FILE")
if [[ "$ORIGINAL_DEFAULT" == default* ]]; then
- echo "Restoring original default route..."
+ info "Restoring original default route..."
sudo ip route replace "$ORIGINAL_DEFAULT" \
- || echo "Warning: could not restore original default route"
+ || warn "could not restore original default route"
fi
rm -f "$STATE_FILE"
fi
rm -f "$IFACE_FILE"
- echo "Disconnected"
+ info "Disconnected."
}
status() {
@@ -217,7 +219,12 @@ case "${1:-}" in
status
;;
*)
- echo "Usage: $0 {connect|disconnect|status}"
+ echo "Usage: $0 <connect|disconnect|status>"
+ echo ""
+ echo "Commands:"
+ echo " connect Start the WARP tunnel"
+ echo " disconnect Stop the WARP tunnel and restore routes"
+ echo " status Print Waybar status JSON"
exit 1
;;
-esac
+esac \ No newline at end of file
diff --git a/modules/security/gopass/gopass-ssh-load.sh b/modules/security/gopass/gopass-ssh-load.sh
index b9a06e9..8c1b11f 100644
--- a/modules/security/gopass/gopass-ssh-load.sh
+++ b/modules/security/gopass/gopass-ssh-load.sh
@@ -28,11 +28,15 @@ set -o pipefail
export GNUPGHOME="@@GNUPGHOME@@"
export GOPASS_SSH_KEYS="@@GOPASS_SSH_KEYS@@"
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
+
SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
export SSH_AUTH_SOCK
if [ -z "$SSH_AUTH_SOCK" ] || [ ! -S "$SSH_AUTH_SOCK" ]; then
- echo "Error: SSH_AUTH_SOCK is not set or valid." >&2
- exit 1
+ die "SSH_AUTH_SOCK is not set or valid."
fi
if ssh-add -l 2>/dev/null | grep -qE "(ED25519|RSA|ECDSA)"; then
@@ -41,8 +45,7 @@ fi
# GOPASS_SSH_KEYS holds a space-separated list of gopass entry names under ssh
if [ -z "${GOPASS_SSH_KEYS:-}" ]; then
- echo "Error: GOPASS_SSH_KEYS is not set. Example: GOPASS_SSH_KEYS=\"github gitlab\"" >&2
- exit 1
+ die "GOPASS_SSH_KEYS is not set. Example: GOPASS_SSH_KEYS=\"github gitlab\""
fi
# shellcheck disable=SC2086
@@ -63,6 +66,6 @@ for key in "${keys[@]}"; do
ssh-add "$keyfile" 2>/dev/null
rm -rf "$tmpdir"
else
- echo "Warning: no gopass entry ssh/$key" >&2
+ warn "no gopass entry ssh/$key"
fi
done
diff --git a/modules/security/gopass/gopass-sync-init.sh b/modules/security/gopass/gopass-sync-init.sh
index c7767f9..e00ce73 100644
--- a/modules/security/gopass/gopass-sync-init.sh
+++ b/modules/security/gopass/gopass-sync-init.sh
@@ -11,19 +11,24 @@
STORE_DIR="@@PASSWORD_STORE_DIR@@"
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
+
mkdir -p "$STORE_DIR"
-cd "$STORE_DIR" || { echo "Failed to enter $STORE_DIR"; exit 1; }
+cd "$STORE_DIR" || die "Failed to enter $STORE_DIR"
# Check if the directory is already a git repository; initialize if not
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
- echo "Initializing git repository in $STORE_DIR..."
+ info "Initializing git repository in $STORE_DIR..."
git init
fi
# Check if the remote 'origin' is set; add it if not
if ! git remote | grep -q "^origin$"; then
- echo "Adding remote origin..."
+ info "Adding remote origin..."
git remote add origin "@@REMOTE_REPO_URL@@"
fi
-echo "Password store git setup complete."
+info "Password store git setup complete."
diff --git a/modules/security/gpg/gpg-backup.sh b/modules/security/gpg/gpg-backup.sh
index 57c216b..c1b6c25 100644
--- a/modules/security/gpg/gpg-backup.sh
+++ b/modules/security/gpg/gpg-backup.sh
@@ -1,6 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
+
WORKDIR="$(mktemp -d)"
cleanup() {
@@ -12,9 +17,11 @@ cleanup() {
trap cleanup EXIT
usage() {
- echo "Usage:"
- echo " $0 export <filename> Export all GPG keys to an encrypted file"
- echo " $0 import <filename> Decrypt and import keys from a backup file"
+ echo "Usage: $0 <export|import> <filename>"
+ echo ""
+ echo "Commands:"
+ echo " export Export all GPG keys to an encrypted file"
+ echo " import Decrypt and import keys from a backup file"
exit 1
}
@@ -22,29 +29,28 @@ do_export() {
local outfile="$1"
if [[ -e "$outfile" ]]; then
- echo "!! Refusing to overwrite existing file: $outfile" >&2
- exit 1
+ die "Refusing to overwrite existing file: $outfile"
fi
- echo "==> Exporting public keys..."
+ info "Exporting public keys..."
gpg --export --armor > "$WORKDIR/public-keys.asc"
- echo "==> Exporting secret keys..."
+ info "Exporting secret keys..."
gpg --export-secret-keys --armor > "$WORKDIR/secret-keys.asc"
- echo "==> Exporting secret subkeys (if any)..."
+ info "Exporting secret subkeys (if any)..."
gpg --export-secret-subkeys --armor > "$WORKDIR/secret-subkeys.asc" || true
- echo "==> Exporting owner trust database..."
+ info "Exporting owner trust database..."
gpg --export-ownertrust > "$WORKDIR/ownertrust.txt"
- echo "==> Exporting revocation certificates..."
+ info "Exporting revocation certificates..."
mkdir -p "$WORKDIR/revocation-certs"
if [[ -d "$HOME/.gnupg/openpgp-revocs.d" ]]; then
cp "$HOME"/.gnupg/openpgp-revocs.d/*.rev "$WORKDIR/revocation-certs/" 2>/dev/null || true
fi
- echo "==> Bundling everything into a single archive..."
+ info "Bundling everything into a single archive..."
tar -C "$WORKDIR" -cf "$WORKDIR/gpg-full-backup.tar" \
public-keys.asc \
secret-keys.asc \
@@ -52,7 +58,7 @@ do_export() {
ownertrust.txt \
revocation-certs
- echo "==> Encrypting with GPG (AES256, SHA512, max S2K iteration count)..."
+ info "Encrypting with GPG (AES256, SHA512, max S2K iteration count)..."
echo " You will be prompted for a passphrase — use a strong one."
gpg --symmetric \
--cipher-algo AES256 \
@@ -63,21 +69,19 @@ do_export() {
--output "$outfile" \
"$WORKDIR/gpg-full-backup.tar"
- echo "==> Verifying: attempting decryption to confirm it works..."
+ info "Verifying: attempting decryption to confirm it works..."
if gpg --decrypt "$outfile" > "$WORKDIR/verify.tar" 2>/dev/null; then
if cmp -s "$WORKDIR/gpg-full-backup.tar" "$WORKDIR/verify.tar"; then
- echo "==> Verification succeeded: backup decrypts correctly."
+ info "Verification succeeded: backup decrypts correctly."
else
- echo "!! WARNING: decrypted content does not match original. Investigate before trusting this backup." >&2
- exit 1
+ die "Decrypted content does not match original. Investigate before trusting this backup."
fi
else
- echo "!! WARNING: decryption test failed." >&2
- exit 1
+ die "Decryption test failed."
fi
echo
- echo "==> Done."
+ info "Done."
echo " Encrypted backup: $outfile"
echo " Store this file somewhere safe (offline media, encrypted drive)."
echo " The S2K iteration count only helps if your passphrase itself"
@@ -88,42 +92,41 @@ do_import() {
local infile="$1"
if [[ ! -f "$infile" ]]; then
- echo "!! File not found: $infile" >&2
- exit 1
+ die "File not found: $infile"
fi
- echo "==> Decrypting $infile ..."
+ info "Decrypting $infile ..."
echo " You will be prompted for the backup's passphrase."
echo " Note: this may take a while due to the high S2K iteration count."
gpg --decrypt "$infile" > "$WORKDIR/gpg-full-backup.tar"
- echo "==> Extracting archive..."
+ info "Extracting archive..."
tar -C "$WORKDIR" -xf "$WORKDIR/gpg-full-backup.tar"
- echo "==> Importing public keys..."
+ info "Importing public keys..."
gpg --import "$WORKDIR/public-keys.asc"
- echo "==> Importing secret keys..."
+ info "Importing secret keys..."
gpg --import "$WORKDIR/secret-keys.asc"
if [[ -s "$WORKDIR/secret-subkeys.asc" ]]; then
- echo "==> Importing secret subkeys..."
+ info "Importing secret subkeys..."
gpg --import "$WORKDIR/secret-subkeys.asc" || true
fi
if [[ -f "$WORKDIR/ownertrust.txt" ]]; then
- echo "==> Importing owner trust database..."
+ info "Importing owner trust database..."
gpg --import-ownertrust "$WORKDIR/ownertrust.txt"
fi
if [[ -d "$WORKDIR/revocation-certs" ]] && [[ -n "$(ls -A "$WORKDIR/revocation-certs" 2>/dev/null)" ]]; then
- echo "==> Restoring revocation certificates..."
+ info "Restoring revocation certificates..."
mkdir -p "$HOME/.gnupg/openpgp-revocs.d"
cp "$WORKDIR"/revocation-certs/*.rev "$HOME/.gnupg/openpgp-revocs.d/" 2>/dev/null || true
fi
echo
- echo "==> Done. Keys imported into your GPG keyring."
+ info "Done. Keys imported into your GPG keyring."
echo " Run 'gpg --list-secret-keys' to confirm."
}
@@ -146,4 +149,4 @@ case "$command" in
*)
usage
;;
-esac
+esac \ No newline at end of file
diff --git a/modules/system/deep-clean/deep-clean.sh b/modules/system/deep-clean/deep-clean.sh
index bb28182..d698bfd 100644
--- a/modules/system/deep-clean/deep-clean.sh
+++ b/modules/system/deep-clean/deep-clean.sh
@@ -1,35 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
-echo "--- Starting Nix Deep Clean (keeping only current generations) ---"
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
+
+info "Starting Nix Deep Clean (keeping only current generations)"
if [[ $EUID -eq 0 ]]; then
- echo "Error: Do not run this script with sudo."
- echo "Run it as your normal user; it will ask for sudo when required."
- exit 1
+ die "Do not run this script with sudo.
+Run it as your normal user; it will ask for sudo when required."
fi
-echo "Removing old NixOS system generations..."
+info "Removing old NixOS system generations..."
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations +1
-echo "Removing old Home Manager generations..."
+info "Removing old Home Manager generations..."
if command -v home-manager &> /dev/null; then
home-manager generations | \
awk 'NR>1 {print $1}' | \
xargs -r home-manager remove-generations
fi
-echo "Removing old user profile generations..."
+info "Removing old user profile generations..."
nix-env --delete-generations +1
-echo "Removing result symlinks..."
+info "Removing result symlinks..."
find . -name "result" -type l -delete
-echo "Running garbage collector..."
+info "Running garbage collector..."
sudo nix-collect-garbage -d
nix-collect-garbage -d
-echo "Optimising Nix store..."
+info "Optimising Nix store..."
nix store optimise
-echo "--- Cleanup Complete ---"
+info "Cleanup Complete." \ No newline at end of file
diff --git a/modules/system/nix-update/nix-update.sh b/modules/system/nix-update/nix-update.sh
index 0f499db..943a1d8 100644
--- a/modules/system/nix-update/nix-update.sh
+++ b/modules/system/nix-update/nix-update.sh
@@ -2,6 +2,11 @@
set -euo pipefail
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
+die() { error "$*"; exit 1; }
+
HM_DIR="$HOME/.config/home-manager"
NIXOS_DIR="/etc/nixos"
ONLY_FLAKE=false
@@ -9,14 +14,14 @@ ONLY_SWITCH=false
TARGET=""
usage() {
- echo "Usage: nix-update <home-manager|nixos|both> [--only-flake|--only-switch]"
+ echo "Usage: $0 <home-manager|nixos|both> [--only-flake|--only-switch]"
echo ""
- echo "Options:"
+ echo "Commands:"
echo " home-manager Update and switch home-manager configuration"
echo " nixos Update and switch NixOS configuration"
echo " both Update and switch both configurations"
echo ""
- echo "Flags:"
+ echo "Options:"
echo " --only-flake Only run nix flake update, skip switch commands"
echo " --only-switch Only run switch commands, skip nix flake update"
exit 1
@@ -27,7 +32,7 @@ parse_args() {
case "$1" in
home-manager | nixos | both)
if [[ -n "$TARGET" ]]; then
- echo "Error: only one target allowed"
+ error "only one target allowed"
usage
fi
TARGET="$1"
@@ -45,63 +50,63 @@ parse_args() {
usage
;;
*)
- echo "Error: unknown option '$1'"
+ error "unknown option '$1'"
usage
;;
esac
done
if [[ -z "$TARGET" ]]; then
- echo "Error: no target specified"
+ error "no target specified"
usage
fi
}
update_home_manager() {
- echo "==> Updating home-manager..."
+ info "Updating home-manager..."
cd "$HM_DIR"
- echo " Staging users/arpit/private.nix..."
+ info "Staging users/arpit/private.nix..."
git add users/arpit/private.nix -f
if [[ "$ONLY_SWITCH" == false ]]; then
- echo " Running nix flake update..."
+ info "Running nix flake update..."
nix flake update
fi
if [[ "$ONLY_FLAKE" == false ]]; then
- echo " Running home-manager switch..."
+ info "Running home-manager switch..."
home-manager switch --flake "$HM_DIR#arpit"
fi
- echo " Unstaging users/arpit/private.nix..."
+ info "Unstaging users/arpit/private.nix..."
git rm --cached users/arpit/private.nix
- echo "==> home-manager update complete"
+ info "home-manager update complete"
}
update_nixos() {
- echo "==> Updating NixOS..."
+ info "Updating NixOS..."
sudo -v
cd "$NIXOS_DIR"
- echo " Staging hardware-configuration.nix..."
+ info "Staging hardware-configuration.nix..."
git add hardware-configuration.nix -f
if [[ "$ONLY_SWITCH" == false ]]; then
- echo " Running nix flake update..."
+ info "Running nix flake update..."
nix flake update
fi
if [[ "$ONLY_FLAKE" == false ]]; then
- echo " Running nixos-rebuild switch..."
+ info "Running nixos-rebuild switch..."
sudo nixos-rebuild switch
fi
- echo " Unstaging hardware-configuration.nix..."
+ info "Unstaging hardware-configuration.nix..."
git rm --cached hardware-configuration.nix
- echo "==> NixOS update complete"
+ info "NixOS update complete"
}
parse_args "$@"
@@ -117,4 +122,4 @@ case "$TARGET" in
update_nixos
update_home_manager
;;
-esac
+esac \ No newline at end of file