Writing vug.star Declarations
A vug.star declaration describes a single target profile as structured data. It selects package outputs and can also describe files, user services and named commands.
Evaluation and target identity
vug invokes configure(ctx) and validates its returned dictionary against schema version 1. The Starlark evaluator runs in a separate process with CPU, memory and evaluation limits. Starlark code has no primitives for arbitrary I/O, networking, clocks, environment variables or subprocesses. A relative load() can read a .star module next to the importing file or in a subdirectory of the declaration root. Absolute paths, parent traversal and symlinked modules are refused.
The ctx struct provides host, user and system. On the client, these come from the lowercased hostname, the account associated with the process’s user ID, and the binary’s architecture and operating system. When locking in CI, --host and --user override the first two fields. The returned profile must agree with those values and specify x86_64-linux. You can use ctx to select configuration data or declare a fixed host and user explicitly. Evaluator process, Starlark loader, Target validation.
Schema version 1
The top-level schema_version, profile and nixpkgs keys are required. The collections below can be omitted when empty. Unknown fields are rejected.
| Key | Shape and constraints |
|---|---|
schema_version | Set to integer 1. |
profile | id, kind, host, user, system, store_backend. Choose home or project for kind, and nix-daemon or vug-owned for storage. Projects cannot manage dotfiles, units or secrets. |
nixpkgs | rev is a full lowercase 40-hex revision. allow_unfree is a Boolean and permitted_insecure is a list of package-version names. |
overlays | List of id, visibility, registry_rev and digest objects. An overlay changes the package definitions imported from Nixpkgs. Visibility is public or private. Private overlays require vug-owned. |
packages | Map from package IDs to attr (a list of Nixpkgs attribute path segments) and outputs (a nonempty list of output names). For a registry overlay add all of overlay, record and version. Optional plugins = [{"output": "lib", "path": "lib/plugin.so"}] names libraries explicitly loaded by the package. Each plugin must be in a declared output. |
dotfiles | Map from clean home-relative destinations to {"owner": "vug", "source": "..."} entries with declaration-relative source paths. Destinations cannot overlap or end in .backup. |
units | Map from vug-*.service names to owner = "vug", package, output, executable, restart_policy and Boolean protected. Optional args and reload_args are argument lists. reload_executable is required for policy reload. Optional credentials lists secret IDs. Policies are reload, restart, next-login and manual. Internal prefixes such as vug-apply- are reserved. |
secrets | Map from IDs to sops_file and key. The file is encrypted YAML relative to the declaration, and key lists the steps to a scalar value in the document. |
commands | Map from command IDs to either package, output and executable, or local_executable and its lowercase SHA-256 sha256. Optional args precede arguments supplied by the caller. fhs_profile selects a named filesystem layout and bind lists allowed host resources to expose within it. |
fhs_profiles | Map of profiles with a runtime_x86_64 list. Every mapping identifies package, output, and a clean relative from and to. Targets must be under usr/ without overlaps. The profile must map usr/lib64/ld-linux-x86-64.so.2. |
os | Optional object with a store-path candidate and optional postprocess recipe ID. See Observing NixOS Candidates for the separate observation command. |
An output is one named result of a Nix package definition, for example out or lib. Executable paths in units and commands are relative to the selected output or, for local_executable, to the declaration directory. Arguments are data passed to a program. vug rejects common shells and env as executable names in these declarations. FHS, the Filesystem Hierarchy Standard, here describes a command-specific Linux layout such as /usr/lib64. The bind list is permitted only with an FHS profile. For allowed resource names and runtime checks, see Running Commands and Command-Scoped FHS. Declaration types and validation.
A declaration with one helper module
Create three files in one directory. The example selects the default output of GNU Hello, installs a small configuration file and names a command for later use.
packages.star
PACKAGES = {
"hello": {"attr": ["hello"], "outputs": ["out"]},
}
vug.star
load("packages.star", "PACKAGES")
def configure(ctx):
return {
"profile": {
"id": "demo",
"kind": "home",
"host": ctx.host,
"user": ctx.user,
"system": ctx.system,
"store_backend": "nix-daemon",
},
"schema_version": 1,
"nixpkgs": {
"rev": "2786a2a72088ecf32aea5b3ec52099e6a7cff78f",
"allow_unfree": False,
"permitted_insecure": [],
},
"packages": PACKAGES,
"dotfiles": {
".config/demo.conf": {"owner": "vug", "source": "demo.conf"},
},
"commands": {
"greet": {
"package": "hello",
"output": "out",
"executable": "bin/hello",
},
},
}
demo.conf
greeting=hello
Use a Nixpkgs revision with cache coverage for the outputs and runtime you intend to lock. In CI, set --host example-host --user example-user for that target. On your own test host, use its actual identity. Once applied, run vug home run --command greet -- --version.
What the declaration digest binds
vug hashes the normalized declaration using SHA-256 over RFC 8785 canonical JSON, a deterministic JSON encoding with defined object key ordering and serialization rules. Moving the tree to another directory leaves the digest unchanged if the returned data stays the same. A different host, user, system or backend changes the returned profile and thus the digest. The saved plan separately records input paths and hashes for the modules, lock and referenced files, so changing demo.conf after planning still invalidates the plan. Canonical digest, Input tracking.