Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Running Commands and Command-Scoped FHS

Run an ad hoc command with the active generation on PATH, or launch a declared command with the Linux filesystem layout and host resources it needs.

Choose a command entry point

vug home dev -- hello --version
vug home run --command greet -- --version

home dev puts the active generation’s bin before the inherited PATH. Omit the program to launch $SHELL (or /bin/sh). home run looks up a command ID in the applied declaration, runs its specified executable, and appends the arguments after -- to the declaration’s fixed args. Both hold a generation lease, a shared lock that keeps garbage collection (GC) from pruning the generation while the child runs. See Planning, Applying, Rollback, and Recovery. Runtime implementation

Both entry points evaluate the supplied declaration to find the profile and compare its digest with the saved declaration. Before launch, vug reloads trust.toml and validates the saved lock’s declaration_digest, lock_digest and lock_signature. It also rehashes every locked path for vug-owned and checks the result against its nar_hash. A NAR is Nix’s serialized representation of a store object. For a declared local_executable, vug reads the file beneath the declaration directory, checks its SHA-256 and verifies it is an ELF (Executable and Linkable Format) program. It runs a temporary executable copy of the checked bytes. Runtime implementation Lock validation

What a command-scoped filesystem contains

FHS stands for Filesystem Hierarchy Standard, the familiar Linux layout with paths such as /usr/bin and /lib64. A declared command selects that layout with fhs_profile. Bubblewrap, a Linux sandbox launcher shipped as vug-bwrap with the static release, assembles the filesystem for that command. A new user namespace gives the child a separate view of user and group IDs. A new PID namespace gives it a separate process-ID space. The sandbox has its own /proc, minimal /dev, and private /tmp and /dev/shm (shared-memory files). These options leave the host network namespace available. Home runtime documentation Bubblewrap arguments

The lock supplies the filesystem mappings. The command’s bind list determines which additional host resources it can reach.

  • Runtime mappings. Each runtime_x86_64 entry maps part of a locked output read-only beneath /usr. Its source must stay inside its original locked output when vug follows symlinks. /lib64, /lib, /bin and /sbin link to the corresponding locations under /usr. The profile must map the loader at usr/lib64/ld-linux-x86-64.so.2.
  • Read-only mounts. Vug exposes the generation, and either the full /nix/store for nix-daemon or the locked closure only for vug-owned. It exposes selected /etc entries if present, covering users and groups, host and DNS lookup, time zone, machine ID, certificates and fonts.
  • Home and environment. The real home and host root stay outside the sandbox. Vug creates an empty private directory at the home path and starts there by default. It clears the environment, forwards TERM, COLORTERM, LANG, LC_ALL, LC_CTYPE, TZ, USER and LOGNAME if set, and supplies HOME, PATH and any bind-specific variables. PATH searches the generation’s bin, then /usr/bin, then /bin.

Commands without an FHS profile use the ordinary runtime. With nix-daemon they run directly, while vug-owned maps its private objects to their logical store paths and keeps the host Nix daemon socket directory visible. For 32-bit FHS software such as Steam, use steam-run. Launcher FHS validation and mounts Declaration validation

Add host resources explicitly

bind entryResource and environment
project-roMounts the declaration directory read-only and starts the command there.
project-rwMounts the same directory writable and starts there. Both project modes refuse / and directories that contain the whole home.
x11Mounts /tmp/.X11-unix/X<n> for a local DISPLAY. If XAUTHORITY is set, mounts the private user-owned file and forwards its path.
waylandMounts the socket under XDG_RUNTIME_DIR, using wayland-0 when WAYLAND_DISPLAY is unset. Supplies the absolute socket path as WAYLAND_DISPLAY and forwards XDG_RUNTIME_DIR.
dbusMounts the session bus socket from the path= field of its first unix: address, or defaults to $XDG_RUNTIME_DIR/bus. Sets DBUS_SESSION_BUS_ADDRESS to unix:path=<socket>.
gpuExposes /dev/dri/renderD* and mounts /run/opengl-driver read-only if it exists.
tmuxMounts the socket named by the first field of TMUX and forwards that variable.
ssh-agentMounts the socket named by SSH_AUTH_SOCK and forwards its path.
dockerMounts the socket from a unix:// DOCKER_HOST or /run/docker.sock and sets DOCKER_HOST to the resulting socket URI.
nix-daemonMounts /nix/var/nix/daemon-socket/socket and sets NIX_REMOTE=daemon.
host-tmpCreates or reuses the user’s private vug-<uid> directory under an absolute TMPDIR or /tmp, mounts it writable and sets VUG_HOST_TMP.

Wayland, D-Bus, tmux and SSH agent sockets must be absolute, owned by the invoking UID and sockets in their own right, rather than symlinks at the socket path. X11, Docker and the Nix daemon use a socket-type check after path resolution. The X authority file and host temporary directory must also be private to the UID. A missing socket or a resource with an unexpected type or owner fails before launch with PRECONDITIONS_CHANGED (exit 254). A mounted socket grants the ability to talk to the service according to its permissions, even when the mount itself is read-only. Bind and ownership checks Failure codes