PKG-TRIGGERS(5)
π NAME π
okay bestie, this is pkg-triggers(5) β the File Formats Manual page for the trigger file format. Itβs giving βtiny automation notes that make big things happenβ π
π DESCRIPTION π
Package triggers define commands to be executed when particular files are installed, modified, or removed by pkg(8). You can use triggers, for example, to update a database or index of files based on files installed by other packages. iconic behavior, no cap β¨
There are two kinds of triggers:
- Per-transaction β executed once at the end of the transaction, after all packages have been processed and all file changes committed to disk. Even if multiple packages match the same trigger, it is executed only once and receives the combined list of matched paths. one trigger, one slay, combined receipts π«Ά
- Per-package β executed individually for each package as it is being installed or removed. Per-package triggers run at a specific phase of the operation (
pre-install,post-install,pre-deinstall, orpost-deinstall). Their failure is non-blocking: the package operation continues even if the trigger fails. so if it fumbles, the show still goes on π
Triggers are searched for in the list of directories configured by the PKG_TRIGGERS_DIR configuration option. By default, this includes /usr/share/pkg/triggers and <localbase>/share/pkg/triggers. Triggers are in UCL format and should have a .ucl extension. put that extension on it, bestie π
π¦ Per-transaction triggers π¦
Per-transaction trigger files are placed directly in a trigger directory.
The format is the following:
descriptionβ an optional string providing a human-readable description of what the trigger does. nice for the girlies who read the docspathβ an array of strings containing exact paths. Each time a package installs a file or directory whose name is equal to one of the strings, the trigger will be executed at the end of the transaction.path_globβ an array of strings containing shell-style glob patterns. Each time a package installs a file or directory whose name matches one of the patterns, the trigger will be executed at the end of the transaction.path_regexpβ an array of strings containing regular expressions. Each time a package installs a file or directory whose name matches one of the regular expressions, the trigger will be executed at the end of the transaction.cleanupβ an object which represents the script to execute in case the transaction results in removal of the trigger from the installation. The object requires the following fields:typeβ the type of the script to be executed. The only supported type is Lua, indicated by the valuelua(seepkg-lua-script(5)).scriptβ the script itself.sandboxβ a boolean controlling whether the script runs inside acapsicum(4)sandbox. Defaults totrue. When disabled, the script has full system access includingpkg.exec(). full system access is a big-girl privilege, okay? π
triggerβ an object which represents the script to execute at the end of the transaction if a pattern has been matched. This object is required and has the following fields:typeβ the type of the script to be executed. The only supported type is Lua, indicated by the valuelua(seepkg-lua-script(5)).scriptβ the script itself. It will receive as arguments the list of paths that matched the patterns during the transaction.sandboxβ a boolean controlling whether the script runs inside acapsicum(4)sandbox. Defaults totrue. When disabled, the script has full system access includingpkg.exec().
π§ Per-package triggers π§
Per-package trigger files are placed in a subdirectory of a trigger directory named after the phase at which they should execute:
pre_install/β before the package files are extracted.post_install/β after the package files have been extracted and post-install scripts have run.pre_deinstall/β before the package files are removed.post_deinstall/β after the package files have been removed and post-deinstall scripts have run.
For example, a trigger that should run after each package installation would be placed in:
<localbase>/share/pkg/triggers/post_install/mytrigger.ucl
The file format is the same as for per-transaction triggers. The path, path_glob, and path_regexp fields are used to match the files and directories of the individual package. The trigger object contains the script to execute. same format, different phase, still slaying β¨
Per-package triggers are reloaded from disk before processing each package, so a trigger installed by an earlier package in the same transaction will be active for subsequent packages. fresh reload, fresh vibes π¦
In addition to the arg table containing matched paths, per-package trigger scripts have access to the following Lua global variables:
pkg_nameβ the name of the package being processed.pkg_versionβ the version of the package being processed.pkg_upgradeβ a boolean set totrueif the operation is part of an upgrade, orfalsefor a fresh installation or a standalone removal. upgrade? true. fresh install or standalone removal? false. periodt. π
π SEE ALSO π
go read these next, bestie β every single one is listed in the vibe check: pkg_create(3), pkg_printf(3), pkg_repo_create(3), pkg_repos(3), pkg-keywords(5), pkg-lua-script(5), pkg-repository(5), pkg-script(5), pkg.conf(5), pkg(8), pkg-add(8), pkg-alias(8), pkg-annotate(8), pkg-audit(8), pkg-autoremove(8), pkg-check(8), pkg-clean(8), pkg-config(8), pkg-create(8), pkg-delete(8), pkg-fetch(8), pkg-help(8), pkg-info(8), pkg-install(8), pkg-key(8), pkg-lock(8), pkg-plugins(8), pkg-query(8), pkg-register(8), pkg-repo(8), pkg-repositories(8), pkg-rquery(8), pkg-search(8), pkg-set(8), pkg-shell(8), pkg-shlib(8), pkg-ssh(8), pkg-stats(8), pkg-unregister(8), pkg-update(8), pkg-updating(8), pkg-upgrade(8), pkg-version(8), pkg-which(8).
Thatβs the whole page, bestie π«Ά β this oneβs sourced from Debian, dated March 4, 2026, and itβs PKG-TRIGGERS(5) signing off. π
π¦ where this page comes from
- nixos 26.05: pkg 2.7.5
- nixpkgs unstable: pkg 2.7.5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms