Writing a unit
A unit is a folder, units/<layer>/<name>/, with a unit.toml inside. Once it’s there, cc-pkg-mng list shows it and cc-pkg-mng install <name> installs it.
name = "tmux"layer = "apps" # core, apps or configssummary = "tmux, with the clipboard wired to Wayland"requires = ["base"] # installed firstdefault = true # apps: ticked in init's list
[packages]dnf = ["tmux", "wl-clipboard"]copr = [] # COPRs to enable firstrepos = [] # .repo URLs to add first
[links] # checkout path → destination"config/tmux/.tmux.conf" = "~/.tmux.conf"
[services]user = [] # systemd --user units to enablesystem = [] # system units to enable
[[questions]] # asked once, changed later with `set`id = "variant"ask = "Which build?"choices = ["stable", "smear"]default = "stable"
[[hooks]] # a script for what a declaration cannot sayname = "plugins"run_as = "user" # or "root"does = "clone the plugin manager into ~/.tmux/plugins"run = "units/apps/tmux/hooks/plugins.sh"watch = ["config/tmux"] # re-run when any of these changesA few more keys, for less common cases:
| Key | Use |
|---|---|
optional, ask |
Core units only. The unit isn’t installed unless init asks the ask question and the answer is yes |
[links_if] |
unit = ["path", …]: links that are only made when that other unit is installed |
[files] |
Checkout path → system path, copied as root |
[binaries] |
For a Rust app: rpm (its package), source (its crate), bins (what it builds) |
[verify] commands |
Commands that must succeed for the unit to count as working |
A hook runs the first time the unit is installed, and again whenever the unit’s files or its watch paths change. Start it with:
#!/usr/bin/env bash. "$(dirname "$(readlink -f "$0")")/../../../lib/hook.sh"That gives the script a few helpers:
REPO, the path to the checkout;as_root, for steps that need root;once NAME, for steps that should only ever run once;info,okandwarn, to print messages;- the answers, as
CCPKG_ANSWER_<ID>.
To check the manifests before installing anything:
scripts/check-units.py # keys, paths, requirementsscripts/check-units.py --packages # also checks that every package exists in dnf