AI BotandRiyyi 83de6acc74 Refactor fetch and pacman packages into subpackages
Split fetch into alpm and aur subpackages for better organization.
Rename state to log. Split pacman into read and sync subpackages.
Remove validation in favor of read.DBFreshness.
2026-04-18 18:18:23 +02:00
2026-04-15 22:44:44 +02:00
2026-04-13 19:31:19 +02:00
2026-04-16 22:24:36 +02:00
2026-04-13 09:58:28 +02:00

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
  • Smart orphan cleanup — removes packages no longer needed
  • Explicit package tracking — marks declared packages as explicit
  • 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

Options

Flag Alias Description
--state -s State file to read package list from (can be used multiple times)
--dry-run Preview changes without applying them
--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 — Mark declared packages as explicit, all others as dependencies
  7. Cleanup — 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.

Output

# Packages installed/removed
Installed 5 packages, removed 2 packages

# No changes needed
Installed 0 packages, removed 0 packages

# Dry-run preview
Installed 3 packages, removed 1 packages
Would install: vim, git, docker
Would remove: python2

# Error
error: package not found: <package-name>

Exit Codes

Code Meaning
0 Success
1 Error

Examples

Minimal System

echo -e "base\nbase-devel\nlinux-headers\nvim\ngit\ncurl" > ~/.config/declpac/minimal.txt
sudo declpac --state ~/.config/declpac/minimal.txt

Development Environment

# development.txt
go
nodejs
python
rust
docker

sudo declpac --state development.txt

Dry-Run

sudo declpac --dry-run --state packages.txt

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
│   ├── merge/          # Package merging
│   ├── 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

S
Description
Sync a declarative package list with the pacman package manager
Readme
1.2 MiB
Languages
Go 96.7%
Makefile 3.3%