Title: Managing OpenBSD installed packages declaratively
       Author: Solène
       Date: 05 May 2022
       Tags: openbsd
       Description: I wrote a simple utility to manage my packages using a
       configuration file, installed missing packages and removing the extra
       ones
       
       # Introduction
       
       I wrote a simple utility to manage OpenBSD packages on a system using a
       declarative way.
       
 (HTM) 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.
       
       # 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.
       
       # 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.
       
       ```shell commands
       $ git clone https://tildegit.org/solene/pkgset.git
       $ cd pkgset
       $ doas make install
       ```
       
       # Configuration file example
       
       Here is the /etc/pkgset.conf file on my laptop.
       
       ```configuration file
       borgbackup--%1.2
       bwm-ng
       fish
       fzf
       git
       git-annex
       gnupg
       godot
       kakoune
       musikcube
       ncdu
       rlwrap
       sbcl
       vim--no_x11
       vlc
       xclip
       xfce
       xfce-extras
       yacreader
       ```
       
       # 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.
       
       # Risks
       
       If you use it incorrectly, running pkgset doesn't have more risks than
       losing some or all installed packages.
       
       # 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.