nitrocli
supports user-provided extensions that are executable
files whose filename starts with "nitrocli-" and that are
discoverable through lookup via the PATH
environment variable.
The program conveys basic configuration information to any
extension being started this way. Specifically, it will set each
environment variable as described in the Configuration subsection
of the Environment section above, if the corresponding nitrocli
program configuration was set. In addition, the following
variables will be set:
NITROCLI_BINARY
The absolute path to the nitrocli
binary through which the
extension was invoked. This path may be used to
recursively invoke nitrocli
to implement certain
functionality.
NITROCLI_RESOLVED_USB_PATH
The USB path of the device that nitrocli
would connect to
based on the --model
, --serial-number
, and --usb-path
options. If there is no matching Nitrokey device, or if
multiple devices match the options, the environment
variable is not set.
All other variables present in the environment will be passed
through to the extension verbatim.
Newer versions of the program reserve the right to set additional
environment variables inside the "NITROCLI_" namespace. As such,
extensions are advised to not define custom variables with this
prefix. However, "NITROCLI_EXT_" is provided specifically for
this purpose. To further avoid conflicts between extensions, it
is recommended that this prefix be followed by the extension's
name (uppercased).
Extensions may optionally read or write persistent data of
various forms. Similar to the main program, extensions should
follow the XDG Base Directory Specification as a guideline where
to store such data. More specifically, the following conventions
should be followed:
For configuration data, ${XDG_CONFIG_HOME}/
extension/ is the
preferred directory, where extension is the full extension name,
including the "nitrocli-" prefix. The recommended configuration
format is TOML. If only a single configuration file is used,
config.toml
is the recommended name.
Similarly, regular data should reside in
${XDG_DATA_HOME}/
extension/ and cached data be stored in
${XDG_CACHE_HOME}/
extension/.