check

pacdef

multi-backend declarative package manager for Linux

Installation

Arch Linux

pacdef is available in the AUR as stable release or development version The AUR package will also provide completions for zsh.

other

Install it from crates.io using this command. bash $ cargo install [-F <backend>[,...]] pacdef

See below ("supported backends") for the feature flags you will need for your distribution.

To get zsh completion to work you must copy the _completion.zsh file to the right folder manually and rename it to _pacdef.

Use-case

pacdef allows the user to have consistent packages among multiple Linux machines and different backends by managing packages in group files. The idea is that (1) any package in the group files ("managed packages") will be installed explicitly, and (2) explicitly installed packages not found in any of the group files ("unmanaged packages") will be removed. The group files are maintained outside of pacdef by any VCS, like git.

If you work with multiple Linux machines and have asked yourself "Why do I have the program that I use every day on my other machine not installed here?", then pacdef is the tool for you.

Of groups, sections, and packages

pacdef manages multiple package groups (group files) that, e.g., may be tied to a specific use-case. Each group has one or more section(s) which correspond to a specific backend, like your system's package manager (pacman, apt, ...), or your programming languages package manger (cargo, pip, ...). Each section contains one or more packages that can be installed respective package manager.

This image illustrates the relationship. 1 n 1 n 1 n pacdef ----> group ----> section ----> package

Example

Let's assume you have the following group files.

base:

```ini [arch] paru zsh

[rust] pacdef topgrade ```

development:

```ini [arch] rustup rust-analyzer

[rust] cargo-tree flamegraph ```

Pacdef will make sure you have the following packages installed for each package manager:

Note that the name of the section corresponds to the ecosystem it relates to, rather than the package manager it uses.

Supported backends

At the moment, supported backends are the following. Pull requests for additional backends are welcome!

| Application | Package Manager | Section | feature flag | Notes | |-------------|-----------------|-----------|--------------|-----------------------------------------------------------------------------------------------------------| | Arch Linux | pacman | [arch] | arch | includes pacman-wrapping AUR helpers (configurable) | | Debian | apt | [debian]| debian | minimum supported apt-version unknown (upstream issue) | | Python | pip | [python]| built-in | | | Rust | cargo | [rust] | built-in | |

Backends that have a feature flag require setting the respective flag for the build process. The appropriate system libraries and their header files must be present on the machine and be detectable by pkg-config. For backends that state "built-in", they are always supported during compile time. Any backend can be disabled during runtime (see below, "Configuration").

For example, to build pacdef with support for Debian Linux, you can run one of the two commands. * (recommended) cargo install -F debian pacdef, this downloads and builds it from https://crates.io * in a clone of this repository, cargo install --path . -F debian

Example

This tree shows my pacdef repository (not the pacdef config dir). . ├── generic │ ├── audio │ ├── base │ ├── desktop │ ├── private │ ├── rust │ ├── wayland │ ├── wireless │ ├── work │ └── xorg ├── hosts │ ├── hostname_a │ ├── hostname_b │ └── hostname_c └── pacdef.yaml

Usage on different machines:

Commands

| Subcommand | Description | |-----------------------------------|-----------------------------------------------------------------------| | group import [<group>...] | import one or more groups, which creates managed packages | | group list | list names of all groups |
| group new [-e] [<group>...] | create new groups, use -e to edit them immediately after creation | | group remove [<group>...] | remove a previously imported group | | group show [<group>...] | show contents of a group |
| package clean [--noconfirm] | remove all unmanaged packages | | package review | for each unmanaged package interactively decide what to do | | package search <regex> | search for managed packages that match the search string | | package sync [--noconfirm] | install managed packages | | package unmanaged | show all unmanaged packages | | version | show version information, supported backends |

Aliases

Most subcommands have aliases. For example, instead of pacdef package sync you can write pacdef p sy, and pacdef group show would become pacdef g s.

Use --help or the zsh completion to find the right aliases.

Configuration

On first execution, it will create a basic config file under $XDG_CONFIG_HOME/pacdef/pacdef.yaml.

```yaml aurhelper: paru # AUR helper to use on Arch Linux (paru, yay, ...) aurrmargs: null # additional args to pass to AUR helper when removing packages (optional) warnnot_symlinks: true # warn if a group file is not a symlink

disabled_backends: [] # backends that pacdef should not manage, e.g. ["python"], this can reduce runtime if the package manager is notoriously slow (like pip) ```

Group file syntax

Group files loosely follow the syntax for ini-files.

  1. Sections begin by their name in brackets.
  2. One package per line.
  3. Anything after a # is ignored.
  4. Empty lines are ignored.
  5. If a package exists in multiple repositories, the repo can be specified as prefix followed by a forward slash. The package manager must understand this notation.

Example: ```ini [arch] alacritty firefox # this comment is ignored libreoffice-fresh mycustomrepo/zsh-theme-powerlevel10k

[rust] cargo-update topgrade ```

Misc.

Naming

pacdef combines the words "package" and "define".

minimum supported rust version (MSRV)

MSRV is 1.65.0. Development is conducted against the latest stable version.