Skip to content

[extension]

extension

A native extension is a compiled library the owner of a machine adds to Novis, and this is where they say which ones there are and where each one lives.

An extension brings new classes with it — an image codec, a driver, something one deployment needs that the language does not ship. Because it is native code running inside every request on the host, only the account that owns the configuration file may name one, and every entry carries the checksum its file is required to have. A binary that changed underneath its checksum is refused, and the refusal takes the whole set rather than loading the rest of it.

The set can change on a running server. Nothing compiled against the old one is ever reused against the new one, so an extension is added, replaced or removed without dropping a request. An application can neither add one nor read the list: what it sees is the classes.

Only nvs.toml sets this key. A request may not change it.

A change in the file takes effect a few seconds after you save it. The server does not restart.

What an extension is and who may add one

<?nvs
// An extension is a compiled WebAssembly file. The owner of the machine lists it in `nvs.toml`,
// with the checksum the file must have:
//
// [[extension]]
// path = "/srv/extensions/geo.nvsx"
// sha256 = "…"
//
// This file lists none. A program cannot add an extension, so this prints `no`.
// `Core\Config::set('extension', ...)` does not compile,
// because a program may not change `extension`.
// This program keeps the name in a variable. The compiler does not check a variable, so `set` runs and returns `false`.
string $name = 'extension';
echo 'add one from code: ', Core\Config::set($name, '/tmp/anything.nvsx') ? 'yes' : 'no', "\n";
// A program cannot read the list either, so `Core\Config::get` returns `null`.
// A program sees only the classes that an extension adds.
echo 'read the list: ', Core\Config::get('extension') ?? "(nothing — the list is not a program's to see)", "\n";
// `Core\Program::id` returns the identity of this program. It includes every loaded extension,
// so a change to the extensions gives a new identity. It is the same for the whole run.
string $id = Core\Program::id();
echo 'identity: ', Core\Str::length($id), " characters, and the same for the whole run\n";
echo 'asked twice: ', $id == Core\Program::id() ? 'the same answer' : 'a different one', "\n";
Output
add one from code: no
read the list: (nothing — the list is not a program's to see)
identity: 64 characters, and the same for the whole run
asked twice: the same answer

Changelog

VersionChange
0.0.6The page of each setting says whether a request may change it with Core\Config::set. A page for a block lists the settings in it that a request may change.