Sync a declarative package list with the pacman package manager
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
AI Bot ccf64ce867 Apply coding convention 3 weeks ago
.agents Workaround for skills not loading in opencode for whatever reason 1 month ago
.opencode Apply coding convention 3 weeks ago
cmd/declpac Add --prune flag for explicit marking and orphan cleanup 3 weeks ago
docs Add make-commit skill and AI commit documentation 1 month ago
openspec Fixup: correct log path in add-operation-logging, fix pacman -Rns flag in declpac-cli-tool, update pkg path in fix-sync-dbs-notloaded 1 month ago
pkg Apply coding convention 3 weeks ago
.gitignore Add build, install and uninstall targets to Makefile 1 month ago
AGENTS.md Apply coding convention 3 weeks ago
LICENSE Update .gitignore and add LICENSE file 1 month ago
Makefile Add fmt command to makefile 3 weeks ago
PackageProvides.md Apply coding convention 3 weeks ago
README.md Add --prune flag for explicit marking and orphan cleanup 3 weeks ago
asd Apply coding convention 3 weeks ago
asd2 Apply coding convention 3 weeks ago
command-output Apply coding convention 3 weeks ago
go.mod Integrate dyalpm for local/sync package queries 1 month ago
go.sum Integrate dyalpm for local/sync package queries 1 month ago
output Apply coding convention 3 weeks ago
packages Apply coding convention 3 weeks ago
scenario-dependencies-renamed Apply coding convention 3 weeks ago
skills-lock.json Initial commit 1 month ago

README.md

declpac

Declarative package manager for Arch Linux that syncs your system with a declared package list using pacman.

Features

  • Declarative state management — define your desired package list in files or stdin
  • Explicit package tracking — marks declared packages as explicit (with --prune)
  • Smart orphan cleanup — removes packages no longer needed (with --prune)
  • AUR support — builds and installs AUR packages automatically
  • Machine-readable output — perfect for scripting

Installation

Build from Source

git clone https://github.com/Riyyi/declpac.git
cd declpac
go build -o declpac ./cmd/declpac
sudo mv declpac /usr/local/bin/

Dependencies

  • Go 1.21+
  • pacman
  • makepkg (for AUR support)
  • git (for AUR support)
  • Root privileges

Usage

# Single state file
sudo declpac --state packages.txt

# Multiple state files
sudo declpac --state base.txt --state apps.txt

# From stdin
cat packages.txt | sudo declpac

# Preview changes without applying
sudo declpac --dry-run --state packages.txt

State File Format

One package name per line, lines beginning with # are comments:

bash
vim
git
docker
# this is a comment

Implicit State File

If $XDG_CONFIG_HOME/declpac (or ~/.config/declpac on fallback) exists, its contents are automatically included in the package list.

Options

Flag Alias Description
--state -s State file(s) to read package list from (can be used multiple times)
--nocheck Skip safety check (allow significant package count reductions)
--dry-run Preview changes without applying them
--prune Mark packages as explicit and cleanup orphans
--verbose -v Enable verbose output
--help -h Show help message

How It Works

  1. Read — Collect packages from all state files and stdin
  2. Merge — Combine into single package list
  3. Categorize — Check if packages are in official repos or AUR
  4. Sync — Install/update packages via pacman
  5. Build — Build and install AUR packages via makepkg
  6. Mark (with --prune) — Mark declared packages as explicit, all others as dependencies
  7. Cleanup (with --prune) — Remove orphaned packages

Database Freshness

If the pacman database is older than 24 hours, it is automatically refreshed.

Logging

Operations are logged to /var/log/declpac.log.

Troubleshooting

Permission denied

Use sudo:

sudo declpac --state packages.txt

Package not found

Check if the package exists:

pacman -Ss <package>

Database sync fails

sudo pacman -Syy

File Structure

declpac/
├── cmd/declpac/
│   └── main.go         # Entry point
├── pkg/
│   ├── input/          # State file/stdin reading
│   ├── fetch/          # Package resolution
│   │   ├── aur/        # AUR support
│   │   └── alpm/       # ALPM support
│   ├── pacman/         # Pacman operations
│   │   ├── read/       # Read packages
│   │   └── sync/       # Sync packages
│   ├── log/            # Logging
│   └── output/         # Output formatting
└── README.md

License

GPL-3.0