1. Introduction §
I wrote a simple utility to manage OpenBSD packages on a system using a declarative way.
pkgset git repository
Instead of running many pkg_add or pkg_delete commands to manage my packages, now I can use a configuration file (allowing includes) to define which package should be installed, and the installed but not listed packages should be removed.
After using NixOS too long, it's a must have for me to manage packages this way.
2. How does it work? §
pkgset works by marking extra packages as "auto installed" (the opposite is manually installed, see pkg_info -m), and by installing missing packages. After those steps, pkgset runs "pkg_delete -a" to remove unused packages (the one marked as auto installed) if they are not a dependency of another required package.
3. How to install? §
The installation is easy, download the sources and run make install as root, it will install pkgset and its man page on your system.
$ git clone https://tildegit.org/solene/pkgset.git
$ cd pkgset
$ doas make install
4. Configuration file example §
Here is the /etc/pkgset.conf file on my laptop.
5. Limitations §
The only "issue" with pkgset is that for some packages that "pkg_add" may find ambiguous due to multiples versions or favors available without a default one, you must define the exact package version/flavor you want to install.
6. Risks §
If you use it incorrectly, running pkgset doesn't have more risks than losing some or all installed packages.
7. Why not use pkg_add -l ? §
I know pkg_add as an option to install packages from a list, but it won't remove the extra packages. I may look at adding the "pkgset" feature to pkg_add one day maybe.