Thanks to metapac for inspiring this project.
Please have a look at it since it is probably more suited to your needs than paclare.
Many package managers end up cluttering your environment. Stuff you don't need anymore is installed and you can't remember why you installed it.
Conversely, when setting up a new machine, you may not remember all you need to install to have a similar setup as on the previous one.
You may also suffer from fragmented configuration : apt, flatpak, pip, it's difficult to have a one size fits all solution.
Paclare, contraction of Package deClare, aims to solve these issues.
For each package manager you use, you put the packages you need in a config.toml file.
[apt]
packages = [
"emacs", # You can add a comment if you want
"vim", # Please don't install this one
"flatpak", # Package manager for portable gui apps
]
[flatpak]
packages = [
"org.mozilla.firefox",
]Here is what paclare will do :
- If a package is not installed yet, paclare will install it
- If a package is installed but not on the list, paclare will uninstall it
- Paclare supports some of the most popular package managers out of the box
- If paclare's does not support your package manager natively, you can add it yourself in the toml file (read-on for a detailed explanation).
Other declarative package managers exist, like nix or guix, they are far more powerful but also far more complex.
Paclare is a python package, it requires python3.12 or later.
Currently, paclare has been packaged on the pypi index, so you can install it through pip, pipx, or uv.
I recommend uv, as it is becoming the defacto modern python package manager.
pip install paclare
pipx install paclare
uv tool install paclareLet's assume that you use package managers already supported by paclare.
mkdir ~/.config/paclare # Or symlink to your dotfiles repo
paclare init ~/.config/paclare/paclare.tomlThis file will only contain your explicitely installed packages. Dependencies should not appear there.
paclare listThis command will read your config file, detect the package managers you have enabled there, and for each one of them list the explicitely installed packages.
paclare syncThis command will read your config file, detect the package managers and the associated packages.
It will then compare these lists to what is actually installed on your machine. The missing packages will be installed, the leftovers uninstalled.
Paclare won't support every package manager out of the box, but you can add your own.
You must provide three variables in your toml config :
[mypackagemgr]
list_cmd = "mypackagemgr --list-user-installed-packages"
install_cmd = "mypackagemgr install"
uninstall_cmd = "mypackagemgr uninstall"
packages = [
"pkg1",
"pkg2"
]The commands specified here will be interpreted by your machine's default shell, /bin/sh.
This means you can use your pipes, cut, sed, and pals to help you here.
You can check out the commands used for the built-in package managers here
You can also override paclare's commands for built-in package managers by defining these variables.
Contributions are of course welcome, especially to add new package managers to the supported list.
New features and PRs will be considered, but I intend to keep paclare as minimal as possible.