From b15a05706e338ca5bb5c5ef264b10db6130aca01 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 21 Apr 2026 01:23:26 +0100 Subject: refactor: reorganize justfile with sync wrapper and generalized init - 'just sync' now wraps apply + fix for combined dotfile + package reconciliation - 'just init' generalized for first-time machine setup: regenerate chezmoi config, install git hooks, install base packages - Hidden helper recipes (_chezmoi-init, _install-hooks) via [private] so they don't clutter 'just --list' - Section banners organize the justfile into Setup, Day-to-day, Inspection, Package management, and Hidden helpers - Default recipe (bare 'just') shows the list - Doc comments reworded for clarity in the autocomplete menu --- .github/copilot-instructions.md | 4 +- justfile | 109 ++++++++++++++++++++++++++-------------- 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index e5d066b..7fc90a5 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -18,8 +18,8 @@ The repo root is a chezmoi source directory. Files targeting `$HOME` use chezmoi - `firefox/` contains Firefox/LibreWolf hardening overrides (`user-overrides.js`) and custom CSS (`chrome/userChrome.css`). Deployed by `run_onchange_after_deploy-firefox.sh.tmpl`. - `create-efi.sh` is an interactive EFI boot entry creation script using `efibootmgr`. - `.chezmoiignore` excludes non-home files (`etc/`, `meta/`, `firefox/`, docs) from deployment to `$HOME`. -- `.githooks/` contains git hooks (notably `post-commit` which runs `chezmoi apply`). Activate with `just install-hooks`. -- `justfile` provides recipes: `install-hooks`, `apply`, `init`, `install`, `install-all`, `add`, `status`, `groups`, `fix`. +- `.githooks/` contains git hooks (notably `post-commit` which runs `chezmoi apply`). Activated by `just init`. +- `justfile` provides recipes: `init` (first-time setup), `sync` (apply + fix), `apply`, `fix`, `status`, `groups`, `install`, `install-all`, `add`. Run `just` or `just --list` to see them. ## Window manager diff --git a/justfile b/justfile index e201c31..e706508 100644 --- a/justfile +++ b/justfile @@ -1,28 +1,28 @@ -# Install git hooks -install-hooks: - git config core.hooksPath .githooks +# Show available recipes (default) +default: + @just --list -# Deploy dotfiles -apply: - chezmoi apply -S . -# Regenerate chezmoi config from .chezmoi.toml.tmpl (run when the template changes) -init: - chezmoi init -S . +# ═══════════════════════════════════════════════════════════════════ +# Setup +# ═══════════════════════════════════════════════════════════════════ -# Install packages from one or more groups (e.g. just install base dev wayland) -install *groups: - #!/bin/sh - for group in {{ groups }}; do - grep -v '^\s*#' "meta/${group}.txt" | grep -v '^\s*$' | paru -S --needed - - done +# First-time machine setup: regenerate chezmoi config, install git hooks, install base packages +init: _chezmoi-init _install-hooks (install "base") -# Install all package groups -install-all: - #!/bin/sh - cat meta/*.txt | grep -v '^\s*#' | grep -v '^\s*$' | sort -u | paru -S --needed - -# Fill in missing packages for groups that are ≥50% installed +# ═══════════════════════════════════════════════════════════════════ +# Day-to-day +# ═══════════════════════════════════════════════════════════════════ + +# Reconcile everything: deploy dotfiles AND top up partially-installed package groups +sync: apply fix + +# Deploy dotfiles (chezmoi apply) +apply: + chezmoi apply -S . + +# Top up missing packages in groups that are already ≥50% installed (never installs new groups) fix: #!/bin/sh for file in meta/*.txt; do @@ -39,22 +39,10 @@ fix: fi done -# Add a package to a group and install it (e.g. just add dev ripgrep) -add group pkg: - #!/bin/sh - set -eu - file="meta/{{ group }}.txt" - if [ ! -f "$file" ]; then - echo "error: $file does not exist" >&2 - exit 1 - fi - if grep -qxF '{{ pkg }}' "$file"; then - echo "{{ pkg }} already in {{ group }}.txt" - else - echo '{{ pkg }}' >> "$file" - echo "added {{ pkg }} to {{ group }}.txt" - fi - paru -S --needed '{{ pkg }}' + +# ═══════════════════════════════════════════════════════════════════ +# Inspection +# ═══════════════════════════════════════════════════════════════════ # Show package and dotfile drift (only for groups ≥50% installed) status: @@ -86,7 +74,7 @@ status: echo "=== Dotfile drift ===" chezmoi status -S . || true -# Show install coverage for each group (or full breakdown for one group) +# Show per-group install coverage; pass a group name for a per-package breakdown groups group="": #!/bin/sh if [ -n '{{ group }}' ]; then @@ -120,3 +108,50 @@ groups group="": printf ' \033[33m~\033[0m %-10s %d/%d\n' "$group" "$installed" "$total" fi done + + +# ═══════════════════════════════════════════════════════════════════ +# Package management +# ═══════════════════════════════════════════════════════════════════ + +# Install one or more package groups (e.g. just install base dev wayland) +install *groups: + #!/bin/sh + for group in {{ groups }}; do + grep -v '^\s*#' "meta/${group}.txt" | grep -v '^\s*$' | paru -S --needed - + done + +# Install every package group +install-all: + #!/bin/sh + cat meta/*.txt | grep -v '^\s*#' | grep -v '^\s*$' | sort -u | paru -S --needed - + +# Append a package to a group list and install it (e.g. just add dev ripgrep) +add group pkg: + #!/bin/sh + set -eu + file="meta/{{ group }}.txt" + if [ ! -f "$file" ]; then + echo "error: $file does not exist" >&2 + exit 1 + fi + if grep -qxF '{{ pkg }}' "$file"; then + echo "{{ pkg }} already in {{ group }}.txt" + else + echo '{{ pkg }}' >> "$file" + echo "added {{ pkg }} to {{ group }}.txt" + fi + paru -S --needed '{{ pkg }}' + + +# ═══════════════════════════════════════════════════════════════════ +# Hidden helpers (run indirectly via the recipes above) +# ═══════════════════════════════════════════════════════════════════ + +[private] +_chezmoi-init: + chezmoi init -S . + +[private] +_install-hooks: + git config core.hooksPath .githooks -- cgit v1.2.3-70-g09d2