This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools: split inline scripts into separate files

- Split wifi-qr script into wifi-qr.sh
- Split menu scripts into menu-darwin.sh and menu-linux.sh
- Remove get-spora-hosts tool
- Update flake-module.nix files to reference external script files

This improves maintainability and readability of the tool configurations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

author
lassulus
co-author
Claude
date (Jun 14, 2025, 11:22 PM CEST) commit cd2bc8f2 parent f8f9ce8b
+82 -104
-22
tools/get-spora-hosts/flake-module.nix
··· 1 - { self, ... }: 2 - { 3 - perSystem = 4 - { system, pkgs, ... }: 5 - { 6 - packages.get-spora-hosts = pkgs.writeScriptBin "get-spora-hosts" '' 7 - set -eu 8 - set -o pipefail 9 - set -x 10 - OUTDIR=$1 11 - for host in ${self}/machines/*; do 12 - if test -e "$host"/facts/mycelium_pubkey; then 13 - if ! test -e "$OUTDIR"/"$(basename "$host")".json; then 14 - ${ 15 - self.packages.${pkgs.system}.mycelium 16 - }/bin/mycelium inspect "$(cat "$host"/facts/mycelium_pubkey)" --json > "$OUTDIR/$(basename "$host").json" 17 - fi 18 - fi 19 - done 20 - ''; 21 - }; 22 - }
+2 -75
tools/menu/flake-module.nix
··· 11 11 pkgs.choose-gui 12 12 pkgs.fzf 13 13 ]; 14 - text = '' 15 - set -efu 16 - 17 - # Create temporary files for input and output 18 - TEMP_DIR=$(mktemp -d) 19 - INPUT_FILE="$TEMP_DIR/input" 20 - OUTPUT_FILE="$TEMP_DIR/output" 21 - 22 - # Set up trap to clean up temp dir on exit 23 - trap 'rm -rf "$TEMP_DIR"' EXIT 24 - 25 - # Save stdin to file 26 - cat > "$INPUT_FILE" 27 - 28 - # Try fzf first with terminal UI - explicitly store exit code 29 - # This avoids issues with losing the exit code in a pipe 30 - set +e 31 - fzf "$@" < "$INPUT_FILE" > "$OUTPUT_FILE" 2>/dev/null 32 - FZF_EXIT=$? 33 - set -e 34 - 35 - # Handle fzf results based on exit code 36 - if [ $FZF_EXIT -eq 0 ]; then 37 - # Success - output result and exit 38 - cat "$OUTPUT_FILE" 39 - exit 0 40 - elif [ $FZF_EXIT -eq 130 ]; then 41 - # User pressed Escape - honor the cancellation 42 - exit 130 43 - fi 44 - 45 - # If we get here, fzf failed with error (not cancellation) 46 - 47 - # Fall back to GUI 48 - choose "$@" < "$INPUT_FILE" 49 - ''; 14 + text = builtins.readFile ./menu-darwin.sh; 50 15 }) 51 16 else if pkgs.stdenv.hostPlatform.isLinux then 52 17 (pkgs.writeShellApplication { ··· 56 21 pkgs.wofi 57 22 pkgs.fzf 58 23 ]; 59 - text = '' 60 - set -efu 61 - # Create temporary files for input and output 62 - TEMP_DIR=$(mktemp -d) 63 - INPUT_FILE="$TEMP_DIR/input" 64 - OUTPUT_FILE="$TEMP_DIR/output" 65 - 66 - # Save stdin to file 67 - cat > "$INPUT_FILE" 68 - 69 - # Try fzf first with terminal UI - explicitly store exit code 70 - # This avoids issues with losing the exit code in a pipe 71 - set +e 72 - fzf "$@" < "$INPUT_FILE" > "$OUTPUT_FILE" 2>/dev/null 73 - FZF_EXIT=$? 74 - set -e 75 - 76 - # Handle fzf results based on exit code 77 - if [ $FZF_EXIT -eq 0 ]; then 78 - # Success - output result and exit 79 - cat "$OUTPUT_FILE" 80 - exit 0 81 - elif [ $FZF_EXIT -eq 130 ]; then 82 - # User pressed Escape - honor the cancellation 83 - exit 130 84 - fi 85 - 86 - # If we get here, fzf failed with error (not cancellation) 87 - 88 - # Fall back to GUI based on available display environment 89 - if [ -n "''${WAYLAND_DISPLAY:-}" ]; then 90 - wofi -d "$@" < "$INPUT_FILE" 91 - elif [ -n "''${DISPLAY:-}" ]; then 92 - rofi -dmenu "$@" < "$INPUT_FILE" 93 - else 94 - echo "Error: No suitable display environment available" >&2 95 - exit 1 96 - fi 97 - ''; 24 + text = builtins.readFile ./menu-linux.sh; 98 25 }) 99 26 else 100 27 throw "unsupported system";
+35
tools/menu/menu-darwin.sh
··· 1 + #!/usr/bin/env bash 2 + set -efu 3 + 4 + # Create temporary files for input and output 5 + TEMP_DIR=$(mktemp -d) 6 + INPUT_FILE="$TEMP_DIR/input" 7 + OUTPUT_FILE="$TEMP_DIR/output" 8 + 9 + # Set up trap to clean up temp dir on exit 10 + trap 'rm -rf "$TEMP_DIR"' EXIT 11 + 12 + # Save stdin to file 13 + cat > "$INPUT_FILE" 14 + 15 + # Try fzf first with terminal UI - explicitly store exit code 16 + # This avoids issues with losing the exit code in a pipe 17 + set +e 18 + fzf "$@" < "$INPUT_FILE" > "$OUTPUT_FILE" 2>/dev/null 19 + FZF_EXIT=$? 20 + set -e 21 + 22 + # Handle fzf results based on exit code 23 + if [ $FZF_EXIT -eq 0 ]; then 24 + # Success - output result and exit 25 + cat "$OUTPUT_FILE" 26 + exit 0 27 + elif [ $FZF_EXIT -eq 130 ]; then 28 + # User pressed Escape - honor the cancellation 29 + exit 130 30 + fi 31 + 32 + # If we get here, fzf failed with error (not cancellation) 33 + 34 + # Fall back to GUI 35 + choose "$@" < "$INPUT_FILE"
+38
tools/menu/menu-linux.sh
··· 1 + #!/usr/bin/env bash 2 + set -efu 3 + # Create temporary files for input and output 4 + TEMP_DIR=$(mktemp -d) 5 + INPUT_FILE="$TEMP_DIR/input" 6 + OUTPUT_FILE="$TEMP_DIR/output" 7 + 8 + # Save stdin to file 9 + cat > "$INPUT_FILE" 10 + 11 + # Try fzf first with terminal UI - explicitly store exit code 12 + # This avoids issues with losing the exit code in a pipe 13 + set +e 14 + fzf "$@" < "$INPUT_FILE" > "$OUTPUT_FILE" 2>/dev/null 15 + FZF_EXIT=$? 16 + set -e 17 + 18 + # Handle fzf results based on exit code 19 + if [ $FZF_EXIT -eq 0 ]; then 20 + # Success - output result and exit 21 + cat "$OUTPUT_FILE" 22 + exit 0 23 + elif [ $FZF_EXIT -eq 130 ]; then 24 + # User pressed Escape - honor the cancellation 25 + exit 130 26 + fi 27 + 28 + # If we get here, fzf failed with error (not cancellation) 29 + 30 + # Fall back to GUI based on available display environment 31 + if [ -n "${WAYLAND_DISPLAY:-}" ]; then 32 + wofi -d "$@" < "$INPUT_FILE" 33 + elif [ -n "${DISPLAY:-}" ]; then 34 + rofi -dmenu "$@" < "$INPUT_FILE" 35 + else 36 + echo "Error: No suitable display environment available" >&2 37 + exit 1 38 + fi
+1 -7
tools/wifi-qr/flake-module.nix
··· 9 9 pkgs.zbar 10 10 pkgs.gawk 11 11 ]; 12 - text = '' 13 - QR_CODE=$(zbarcam --raw --oneshot) 14 - SSID=$(echo "$QR_CODE" | awk -F 'S:' '{print $2}' | awk -F ';' '{print $1}') 15 - PW=$(echo "$QR_CODE" | awk -F 'P:' '{print $2}' | awk -F ';' '{print $1}') 16 - nmcli dev wifi rescan 17 - nmcli dev wifi connect "$SSID" password "$PW" 18 - ''; 12 + text = builtins.readFile ./wifi-qr.sh; 19 13 }; 20 14 }; 21 15 }
+6
tools/wifi-qr/wifi-qr.sh
··· 1 + #!/usr/bin/env bash 2 + QR_CODE=$(zbarcam --raw --oneshot) 3 + SSID=$(echo "$QR_CODE" | awk -F 'S:' '{print $2}' | awk -F ';' '{print $1}') 4 + PW=$(echo "$QR_CODE" | awk -F 'P:' '{print $2}' | awk -F ';' '{print $1}') 5 + nmcli dev wifi rescan 6 + nmcli dev wifi connect "$SSID" password "$PW"