-
-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] WIP address feedback on finalize yadm stow setup PR #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5d878d6
356f7d7
f02576b
18a5669
4e2ff99
8fb42f0
e65be90
2263b7a
75fcfca
8570eb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck enable=all shell=bash source-path=SCRIPTDIR | ||
| set -euo pipefail; shopt -s nullglob globstar | ||
| export LC_ALL=C; IFS=$'\n\t' | ||
| has(){ command -v -- "$1" &>/dev/null; } | ||
| info(){ printf '==> %s\n' "$*"; } | ||
| warn(){ printf '==> WARNING: %s\n' "$*"; } | ||
| die(){ printf '==> ERROR: %s\n' "$*" >&2; exit 1; } | ||
|
|
||
| # Get repository directory | ||
| get_repo_dir(){ | ||
| if yadm rev-parse --show-toplevel &>/dev/null; then | ||
| yadm rev-parse --show-toplevel | ||
| elif [[ -d "${HOME}/.local/share/yadm/repo.git" ]]; then | ||
| echo "${HOME}" | ||
| elif git rev-parse --show-toplevel &>/dev/null; then | ||
| git rev-parse --show-toplevel | ||
| else | ||
| die "Cannot determine repository location" | ||
| fi | ||
| } | ||
|
|
||
| usage(){ | ||
| cat <<'EOF' | ||
| deploy-system-configs - Deploy system configs using tuckr or stow | ||
|
|
||
| Usage: deploy-system-configs [OPTIONS] [PACKAGES...] | ||
|
|
||
| Options: | ||
| -h, --help Show this help | ||
| -d, --dir DIR Repository directory (auto-detected if omitted) | ||
| -u, --unlink Unlink/unstow packages instead of linking | ||
|
|
||
| Packages: | ||
| etc Deploy /etc configs | ||
| usr Deploy /usr configs | ||
| (default: etc usr) | ||
|
|
||
| This script automatically uses tuckr if available, otherwise falls back to stow. | ||
|
|
||
| Examples: | ||
| sudo deploy-system-configs # Deploy both etc and usr | ||
| sudo deploy-system-configs etc # Deploy only etc | ||
| sudo deploy-system-configs --unlink # Unlink all packages | ||
| EOF | ||
| } | ||
|
|
||
| REPO_DIR="" | ||
| UNLINK=false | ||
| PACKAGES=() | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) usage; exit 0 ;; | ||
| -d|--dir) | ||
| if [[ -z ${2:-} ]]; then die "Option '$1' requires an argument."; fi | ||
| REPO_DIR="$2"; shift | ||
| ;; | ||
| -u|--unlink) UNLINK=true ;; | ||
| -*) die "Unknown option: $1" ;; | ||
| *) PACKAGES+=("$1") ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| # Auto-detect repo dir if not provided | ||
| [[ -z $REPO_DIR ]] && REPO_DIR="$(get_repo_dir)" | ||
| [[ -d $REPO_DIR ]] || die "Repository not found: $REPO_DIR" | ||
|
|
||
| # Default to etc and usr if no packages specified | ||
| ((${#PACKAGES[@]} == 0)) && PACKAGES=(etc usr) | ||
|
|
||
| # Check if running as root | ||
| [[ $EUID -eq 0 ]] || die "This script must be run as root (use sudo)" | ||
|
|
||
| # Deploy using tuckr or stow | ||
| if has tuckr; then | ||
| info "Using tuckr for deployment" | ||
| local hooks_file="${REPO_DIR}/hooks.toml" | ||
|
||
| for pkg in "${PACKAGES[@]}"; do | ||
| local src="${REPO_DIR}/${pkg}" | ||
|
||
| [[ -d $src ]] || { warn "Directory not found: $src"; continue; } | ||
|
|
||
| if [[ $UNLINK == true ]]; then | ||
| info "Unlinking ${pkg}/" | ||
| tuckr unlink -d "$REPO_DIR" -t / "$pkg" || warn "Failed to unlink $pkg" | ||
| else | ||
| info "Linking ${pkg}/ → / (tuckr)" | ||
| local cmd=(tuckr link -d "$REPO_DIR" -t / "$pkg") | ||
|
||
| [[ -f $hooks_file ]] && cmd+=(-H "$hooks_file") | ||
| "${cmd[@]}" || warn "Failed to link $pkg" | ||
| fi | ||
| done | ||
| elif has stow; then | ||
| info "Using stow for deployment (tuckr not available)" | ||
| for pkg in "${PACKAGES[@]}"; do | ||
| local src="${REPO_DIR}/${pkg}" | ||
|
||
| [[ -d $src ]] || { warn "Directory not found: $src"; continue; } | ||
|
|
||
| if [[ $UNLINK == true ]]; then | ||
| info "Unstowing ${pkg}/" | ||
| (cd "$REPO_DIR" && stow -t / -d . -D "$pkg") || warn "Failed to unstow $pkg" | ||
| else | ||
| info "Stowing ${pkg}/ → / (stow)" | ||
| (cd "$REPO_DIR" && stow -t / -d . "$pkg") || warn "Failed to stow $pkg" | ||
| fi | ||
| done | ||
| else | ||
| die "Neither tuckr nor stow is installed. Install one of them: | ||
| Arch: paru -S tuckr OR paru -S stow | ||
| Debian: apt install stow" | ||
| fi | ||
|
|
||
| info "Deployment complete" | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,8 +8,8 @@ clean, hierarchical folder structure. | |||||||||
| ``` | ||||||||||
| dotfiles/ | ||||||||||
| ├── Home/ # User-level dotfiles (~/.*) [Managed by yadm] | ||||||||||
| ├── etc/ # System configs (/etc/*) [Managed by tuckr] | ||||||||||
| ├── usr/ # System configs (/usr/*) [Managed by tuckr] | ||||||||||
| ├── etc/ # System configs (/etc/*) [Managed by tuckr/stow] | ||||||||||
| ├── usr/ # System configs (/usr/*) [Managed by tuckr/stow] | ||||||||||
| ├── .yadm/ # YADM configuration | ||||||||||
| │ ├── bootstrap # Main bootstrap script | ||||||||||
| │ └── config # Repository-wide yadm config | ||||||||||
|
|
@@ -20,9 +20,10 @@ dotfiles/ | |||||||||
|
|
||||||||||
| - **Separation of concerns**: User configs vs. system configs | ||||||||||
| - **Easy to understand**: Mirrors Linux filesystem structure | ||||||||||
| - **Flexible deployment**: yadm for user files, tuckr for system files | ||||||||||
| - **Flexible deployment**: yadm for user files, tuckr/stow for system files | ||||||||||
| - **Git-friendly**: Clean repository with minimal clutter | ||||||||||
| - **Portable**: Works across different systems | ||||||||||
| - **Fallback support**: Automatically uses stow if tuckr is unavailable | ||||||||||
|
|
||||||||||
| --- | ||||||||||
|
|
||||||||||
|
|
@@ -169,7 +170,7 @@ yadm push | |||||||||
|
|
||||||||||
| ### Update System Configs (etc/, usr/) | ||||||||||
|
|
||||||||||
| System configs are managed separately with **tuckr**: | ||||||||||
| System configs are managed separately with **tuckr** (or **stow** as fallback): | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| # Navigate to repository | ||||||||||
|
|
@@ -184,8 +185,14 @@ git commit -m "Update pacman configuration" | |||||||||
| git push | ||||||||||
|
|
||||||||||
| # Re-link system configs (creates symlinks) | ||||||||||
| sudo tuckr link -d $(yadm rev-parse --show-toplevel) -t / etc | ||||||||||
| sudo tuckr link -d $(yadm rev-parse --show-toplevel) -t / usr | ||||||||||
| # Option 1: Using tuckr (preferred) | ||||||||||
| sudo tuckr link -d $(yadm rev-parse --show-toplevel) -t / etc usr | ||||||||||
|
|
||||||||||
| # Option 2: Using stow (fallback) | ||||||||||
| cd $(yadm rev-parse --show-toplevel) && sudo stow -t / etc usr | ||||||||||
|
||||||||||
| cd $(yadm rev-parse --show-toplevel) && sudo stow -t / etc usr | |
| cd $(yadm rev-parse --show-toplevel) && sudo stow -t / -d . etc usr |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command examples show inconsistent usage. Line 189 shows etc usr as separate arguments, line 192 also shows etc usr as separate arguments, but line 195 shows sudo deploy-system-configs without arguments (which would default to both). For consistency and clarity, all examples should explicitly show the arguments when demonstrating multi-package deployment: sudo deploy-system-configs etc usr.
| sudo deploy-system-configs | |
| sudo deploy-system-configs etc usr |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation refers to the script as deploy-system-configs (lines 195, 280, 403) but the actual filename is deploy-system-configs.sh. Users would need to type deploy-system-configs.sh to execute it unless a symlink or alias without the .sh extension is created. Consider either: (1) renaming the file to remove the .sh extension to match the documentation, or (2) updating the documentation to include the .sh extension in all command examples.
| sudo deploy-system-configs | |
| sudo deploy-system-configs.sh |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command sudo stow -t / etc usr at line 400 is incorrect. The stow syntax requires being in the repository directory or specifying it with -d. The correct command would be: sudo stow -t / -d . etc usr (when already in the repo directory) or the cd command should be shown first like in line 395: cd "$PWD" && sudo stow -t / etc usr.
| sudo stow -t / etc usr | |
| sudo stow -t / -d "$PWD" etc usr |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,15 +48,19 @@ main(){ | |
| install_packages(){ | ||
| info "Installing packages..." | ||
| local paru_opts=(--needed --noconfirm --skipreview --sudoloop --batchinstall --combinedupgrade) | ||
| local pkgs=(git gitoxide aria2 curl zsh fd sd ripgrep bat jq zoxide starship fzf yadm tuckr konsave) | ||
| local pkgs=(git gitoxide aria2 curl zsh fd sd ripgrep bat jq zoxide starship fzf yadm konsave) | ||
| if ! has paru; then | ||
| die "paru not found." | ||
| fi | ||
| if [[ $DRY_RUN == true ]]; then | ||
| info "[DRY-RUN] Would install: ${pkgs[*]}" | ||
| info "[DRY-RUN] Would install: ${pkgs[*]} tuckr (or stow)" | ||
| return 0 | ||
| fi | ||
| paru -Syuq "${paru_opts[@]}" "${pkgs[@]}" || die "Failed to install packages" | ||
| # Try installing with tuckr first | ||
| if ! paru -Syuq "${paru_opts[@]}" "${pkgs[@]}" tuckr; then | ||
| warn "tuckr install failed, using stow as fallback" | ||
| paru -Syuq "${paru_opts[@]}" "${pkgs[@]}" stow || die "Failed to install packages" | ||
| fi | ||
| } | ||
| setup_dotfiles(){ | ||
| if ! has yadm; then | ||
|
|
@@ -83,23 +87,39 @@ deploy_home(){ | |
| fi | ||
| } | ||
| link_system_configs(){ | ||
| if ! has tuckr; then | ||
| warn "tuckr not found; skipping etc/usr deploy" | ||
| local pkg | ||
| if has tuckr; then | ||
| info "Using tuckr for system config deployment" | ||
| local hooks_file="${WORKTREE}/hooks.toml" | ||
| for pkg in etc usr; do | ||
| local src="${WORKTREE}/${pkg}" | ||
| [[ -d $src ]] || { warn "Directory not found: $src"; continue; } | ||
| info "Linking ${pkg}/ → / (tuckr)" | ||
| local cmd=(sudo tuckr link -d "$WORKTREE" -t / "$pkg") | ||
| [[ -f $hooks_file ]] && cmd+=(-H "$hooks_file") | ||
| "${cmd[@]}" || warn "Failed to link ${pkg}" | ||
| done | ||
| elif has stow; then | ||
| info "tuckr not found, using stow as fallback" | ||
| for pkg in etc usr; do | ||
| local src="${WORKTREE}/${pkg}" | ||
| [[ -d $src ]] || { warn "Directory not found: $src"; continue; } | ||
| info "Linking ${pkg}/ → / (stow)" | ||
| (cd "$WORKTREE" && sudo stow -t / -d . "$pkg") || warn "Failed to stow ${pkg}" | ||
| done | ||
| else | ||
| warn "Neither tuckr nor stow found; skipping etc/usr deploy" | ||
| warn "Install with: paru -S tuckr OR paru -S stow" | ||
| return 0 | ||
| fi | ||
| local hooks_file="${WORKTREE}/hooks.toml" pkg | ||
| for pkg in etc usr; do | ||
| local src="${WORKTREE}/${pkg}" | ||
| [[ -d $src ]] || { warn "Directory not found: $src"; continue; } | ||
| info "Linking ${pkg}/ → /" | ||
| local cmd=(sudo tuckr link -d "$WORKTREE" -t / "$pkg") | ||
| [[ -f $hooks_file ]] && cmd+=(-H "$hooks_file") | ||
| "${cmd[@]}" || warn "Failed to link ${pkg}" | ||
| done | ||
| } | ||
|
Comment on lines
89
to
115
|
||
| final_steps(){ | ||
| info "Run 'yadm status' to review." | ||
| info "For system configs: sudo tuckr link -d $WORKTREE -t / etc usr" | ||
| if has tuckr; then | ||
| info "For system configs: sudo tuckr link -d $WORKTREE -t / etc usr" | ||
| elif has stow; then | ||
| info "For system configs: cd $WORKTREE && sudo stow -t / etc usr" | ||
| fi | ||
| info "Validate /etc/fstab with: sudo systemd-analyze verify /etc/fstab" | ||
| info "Setup complete." | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # This directory is managed by tuckr and deployed to /usr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
use_tuckr=trueis declared but never used in the function. This unused variable should be removed to keep the code clean.