Ask for config repo URL instead of grapho flake URL
- setup_new: asks for Tier 2 config repo URL (personal/private) - Automatically sets up git remote with provided URL - Simplified join flow - no grapho URL prompt needed - Copy config URL + age key to clipboard (not nix run commands) The grapho flake URL is already known (user ran nix run from it). The config repo is where personal secrets/config get stored. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
144
setup
144
setup
@@ -72,17 +72,14 @@ setup_new() {
|
|||||||
echo -e "${BOLD}Setting up first device...${NC}"
|
echo -e "${BOLD}Setting up first device...${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Ask for grapho repo URL and branch
|
# Ask for config repo URL (Tier 2: personal config/secrets)
|
||||||
echo -n "Your grapho flake repo URL (e.g., https://github.com/you/grapho): "
|
echo "Where should your personal config be stored? (private git repo)"
|
||||||
read -r grapho_url
|
echo -n "Config repo URL (e.g., git@github.com:you/my-config.git): "
|
||||||
[[ -z "$grapho_url" ]] && { err "Repo URL is required"; exit 1; }
|
read -r config_url
|
||||||
|
|
||||||
echo -n "Branch [master]: "
|
echo -n "Branch [master]: "
|
||||||
read -r grapho_branch
|
read -r config_branch
|
||||||
grapho_branch="${grapho_branch:-master}"
|
config_branch="${config_branch:-master}"
|
||||||
|
|
||||||
# Build nix run command
|
|
||||||
local nix_run_cmd="nix run 'git+${grapho_url}?ref=${grapho_branch}'"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
mkdir -p "$USYNC_DIR"
|
mkdir -p "$USYNC_DIR"
|
||||||
@@ -124,16 +121,19 @@ EOF
|
|||||||
git -C "$config_dir" commit -q --no-gpg-sign -m "Initial setup"
|
git -C "$config_dir" commit -q --no-gpg-sign -m "Initial setup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set up remote if URL provided
|
||||||
|
if [[ -n "$config_url" ]]; then
|
||||||
|
step "Setting up git remote..."
|
||||||
|
git -C "$config_dir" remote remove origin 2>/dev/null || true
|
||||||
|
git -C "$config_dir" remote add origin "$config_url"
|
||||||
|
git -C "$config_dir" branch -M "$config_branch"
|
||||||
|
fi
|
||||||
|
|
||||||
local age_key
|
local age_key
|
||||||
age_key=$(grep 'AGE-SECRET-KEY' "$AGE_KEY_FILE")
|
age_key=$(grep 'AGE-SECRET-KEY' "$AGE_KEY_FILE")
|
||||||
|
|
||||||
# Build instructions
|
# Build join command for other devices
|
||||||
local instructions
|
local join_cmd="nix run '<grapho-flake>' -- '${config_url}' '${age_key}'"
|
||||||
instructions="# On other devices, run:
|
|
||||||
${nix_run_cmd} -- <config-git-url> '${age_key}'
|
|
||||||
|
|
||||||
# To pair mobile:
|
|
||||||
${nix_run_cmd} -- mobile"
|
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
echo ""
|
echo ""
|
||||||
@@ -146,29 +146,41 @@ ${nix_run_cmd} -- mobile"
|
|||||||
echo "Device ID: ${device_id:0:20}..."
|
echo "Device ID: ${device_id:0:20}..."
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "Next steps:"
|
if [[ -n "$config_url" ]]; then
|
||||||
echo " 1. Push config to git server:"
|
echo "Next steps:"
|
||||||
echo " cd $config_dir && git remote add origin <your-git-url> && git push -u origin main"
|
echo " 1. Push config:"
|
||||||
|
echo " cd $config_dir && git push -u origin $config_branch"
|
||||||
|
echo ""
|
||||||
|
echo " 2. On other devices, run this flake and choose 'Join':"
|
||||||
|
echo " Config URL: ${config_url}"
|
||||||
|
echo " Age key: ${age_key}"
|
||||||
|
else
|
||||||
|
echo "Next steps:"
|
||||||
|
echo " 1. Create a private git repo and push config:"
|
||||||
|
echo " cd $config_dir"
|
||||||
|
echo " git remote add origin <your-repo-url>"
|
||||||
|
echo " git push -u origin $config_branch"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo " 2. On other devices, run:"
|
echo "To pair mobile: run this flake and choose 'mobile'"
|
||||||
echo " ${nix_run_cmd} -- <config-git-url> <age-key>"
|
|
||||||
echo ""
|
|
||||||
echo " 3. To pair mobile:"
|
|
||||||
echo " ${nix_run_cmd} -- mobile"
|
|
||||||
|
|
||||||
# Copy to clipboard if possible
|
# Copy join info to clipboard if URL provided
|
||||||
if has xclip; then
|
if [[ -n "$config_url" ]]; then
|
||||||
echo "$instructions" | xclip -selection clipboard
|
local clipboard_text="Config URL: ${config_url}
|
||||||
echo ""
|
Age key: ${age_key}"
|
||||||
ok "Instructions copied to clipboard!"
|
if has xclip; then
|
||||||
elif has wl-copy; then
|
echo "$clipboard_text" | xclip -selection clipboard
|
||||||
echo "$instructions" | wl-copy
|
echo ""
|
||||||
echo ""
|
ok "Config URL and age key copied to clipboard!"
|
||||||
ok "Instructions copied to clipboard!"
|
elif has wl-copy; then
|
||||||
elif has pbcopy; then
|
echo "$clipboard_text" | wl-copy
|
||||||
echo "$instructions" | pbcopy
|
echo ""
|
||||||
echo ""
|
ok "Config URL and age key copied to clipboard!"
|
||||||
ok "Instructions copied to clipboard!"
|
elif has pbcopy; then
|
||||||
|
echo "$clipboard_text" | pbcopy
|
||||||
|
echo ""
|
||||||
|
ok "Config URL and age key copied to clipboard!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,18 +195,6 @@ setup_join() {
|
|||||||
echo -e "${BOLD}Joining existing setup...${NC}"
|
echo -e "${BOLD}Joining existing setup...${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Ask for grapho repo URL and branch
|
|
||||||
echo -n "Your grapho flake repo URL (e.g., https://github.com/you/grapho): "
|
|
||||||
read -r grapho_url
|
|
||||||
[[ -z "$grapho_url" ]] && { err "Repo URL is required"; exit 1; }
|
|
||||||
|
|
||||||
echo -n "Branch [master]: "
|
|
||||||
read -r grapho_branch
|
|
||||||
grapho_branch="${grapho_branch:-master}"
|
|
||||||
|
|
||||||
local nix_run_cmd="nix run 'git+${grapho_url}?ref=${grapho_branch}'"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
mkdir -p "$USYNC_DIR"
|
mkdir -p "$USYNC_DIR"
|
||||||
|
|
||||||
# Handle @file syntax
|
# Handle @file syntax
|
||||||
@@ -235,40 +235,36 @@ setup_join() {
|
|||||||
local devices_file="$USYNC_DIR/devices.json"
|
local devices_file="$USYNC_DIR/devices.json"
|
||||||
echo "{\"devices\":{\"$(hostname)\":{\"id\":\"$device_id\",\"added\":\"$(date -Iseconds)\"}}}" > "$devices_file"
|
echo "{\"devices\":{\"$(hostname)\":{\"id\":\"$device_id\",\"added\":\"$(date -Iseconds)\"}}}" > "$devices_file"
|
||||||
|
|
||||||
# Build instructions
|
|
||||||
local instructions
|
|
||||||
instructions="# Add this device on your other machines:
|
|
||||||
${nix_run_cmd} -- add $device_id $(hostname)
|
|
||||||
|
|
||||||
# To pair mobile:
|
|
||||||
${nix_run_cmd} -- mobile"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${G}=== Joined! ===${NC}"
|
echo -e "${G}=== Joined! ===${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
if [[ -n "$device_id" ]]; then
|
if [[ -n "$device_id" ]]; then
|
||||||
echo "This device: ${device_id:0:20}..."
|
echo "This device: ${device_id:0:20}..."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Add this device on your other machines:"
|
echo "Run 'add' on other machines to connect this device:"
|
||||||
echo -e " ${BOLD}${nix_run_cmd} -- add $device_id $(hostname)${NC}"
|
echo -e " ${BOLD}Device ID: $device_id${NC}"
|
||||||
|
echo -e " ${BOLD}Name: $(hostname)${NC}"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "To pair mobile: ${nix_run_cmd} -- mobile"
|
echo "To pair mobile: run this flake with 'mobile' option"
|
||||||
echo "To sync: ./scripts/usync"
|
|
||||||
|
|
||||||
# Copy to clipboard if possible
|
# Copy device info to clipboard
|
||||||
if has xclip; then
|
if [[ -n "$device_id" ]]; then
|
||||||
echo "$instructions" | xclip -selection clipboard
|
local clipboard_text="Device ID: $device_id
|
||||||
echo ""
|
Name: $(hostname)"
|
||||||
ok "Instructions copied to clipboard!"
|
if has xclip; then
|
||||||
elif has wl-copy; then
|
echo "$clipboard_text" | xclip -selection clipboard
|
||||||
echo "$instructions" | wl-copy
|
echo ""
|
||||||
echo ""
|
ok "Device info copied to clipboard!"
|
||||||
ok "Instructions copied to clipboard!"
|
elif has wl-copy; then
|
||||||
elif has pbcopy; then
|
echo "$clipboard_text" | wl-copy
|
||||||
echo "$instructions" | pbcopy
|
echo ""
|
||||||
echo ""
|
ok "Device info copied to clipboard!"
|
||||||
ok "Instructions copied to clipboard!"
|
elif has pbcopy; then
|
||||||
|
echo "$clipboard_text" | pbcopy
|
||||||
|
echo ""
|
||||||
|
ok "Device info copied to clipboard!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user