One install recipe: just install installs everything
CI / test (push) Successful in 2m25s

just install now builds as you, then asks for root once and installs the
whole thing: the login session (wasm compositor on the MoonBit host,
modules, chandra-ctl, KDE colors, portal) and face unlock (helper, PAM
module, config, models). The alternatives are flags instead of recipes:
--link (was install-dev), --rust (install-rust), --native
(install-native), --pam (install-face --pam), --no-face, --no-models.
The PAM module is compiled as you into build/, so root only copies it;
without a compiler or libpam headers face unlock is skipped with a warning.
just uninstall removes face unlock too (--purge: enrolled faces).

Removed: install-dev, install-rust, install-native, install-face,
uninstall-face and the old install-session* / uninstall-session aliases.
New docs/install.md; README, docs and installer hints updated. Also drops
a committed __pycache__ file and ignores __pycache__/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkA52AocBmJHipFRqb
This commit is contained in:
Claude committed 2026-11-26 01:38:58 +00:00
1 parent e6be3825d0
commit 3e35c4dfa5
16 files changed
+171 -108

No files matched your search

+1
View File
@@ -13,3 +13,4 @@ host-wasm/target/
# (app, gfx, renderer, scene) were committed early and stay tracked; the rest are not. # (app, gfx, renderer, scene) were committed early and stay tracked; the rest are not.
compositor/*/pkg.generated.mbti compositor/*/pkg.generated.mbti
wasmhost/*/pkg.generated.mbti wasmhost/*/pkg.generated.mbti
__pycache__/
+6 -6
View File
@@ -77,11 +77,11 @@ just client # start foot inside it (or: just client konsol
| `just run` | Nested in a window on your Wayland session, MoonBit host | | `just run` | Nested in a window on your Wayland session, MoonBit host |
| `just run-drm` | As a login session on the real screen (from a text console, as yourself) | | `just run-drm` | As a login session on the real screen (from a text console, as yourself) |
| `just run-x11` | On the X server in `$DISPLAY` (NVIDIA on Xorg; the whole screen when no window manager runs) | | `just run-x11` | On the X server in `$DISPLAY` (NVIDIA on Xorg; the whole screen when no window manager runs) |
| `just install` | Install the "Chandra" display-manager session, and "Chandra (X11)" for Xorg (asks for root once) | | `just install` | Install everything: the "Chandra" display-manager session, "Chandra (X11)" for Xorg, and face unlock (asks for root once). `--link` symlinks into this checkout (later just rebuild), `--rust` / `--native` pick the Rust host / native compositor, `--pam` turns face unlock on, `--no-face` skips it |
| `just install-dev` | Same, but symlinked into this checkout: later just rebuild | | `just uninstall` | Remove it all again (`--purge` also deletes enrolled faces) |
| `just reload` | Reload the running session's panel modules from disk (`chandra-ctl reload [NAME]`) | | `just reload` | Reload the running session's panel modules from disk (`chandra-ctl reload [NAME]`) |
| `just run-rust`, `run-drm-rust`, `install-rust` | The same with the Rust host | | `just run-rust`, `run-drm-rust` | The same with the Rust host |
| `just run-native`, `run-drm-native`, `install-native` | The native (non-wasm) build | | `just run-native`, `run-drm-native` | The native (non-wasm) build |
| `just compositor-wasm`, `wasmhost`, `host-wasm`, `modules` | Build one piece | | `just compositor-wasm`, `wasmhost`, `host-wasm`, `modules` | Build one piece |
| `just test` | Native compositor tests and lib tests | | `just test` | Native compositor tests and lib tests |
| `just frame` | Render one composed frame to `_build/e2e_frame.png` | | `just frame` | Render one composed frame to `_build/e2e_frame.png` |
@@ -98,11 +98,11 @@ sizes, for an app that draws at the wrong size.
The installed session logs to `~/.local/state/chandra/session.log`. Start it as yourself, never The installed session logs to `~/.local/state/chandra/session.log`. Start it as yourself, never
as root: `chandra-session` refuses to run as root (`CHANDRA_ALLOW_ROOT=1` overrides). Installing as root: `chandra-session` refuses to run as root (`CHANDRA_ALLOW_ROOT=1` overrides). Installing
goes through `scripts/as-root`, which prefers run0 and falls back to sudo, doas or pkexec goes through `scripts/as-root`, which prefers run0 and falls back to sudo, doas or pkexec
(`CHANDRA_AS_ROOT` picks one). To run a graphical app as root inside Chandra, use (`CHANDRA_AS_ROOT` picks one). What it installs and its flags: [docs/install.md](docs/install.md). To run a graphical app as root inside Chandra, use
`chandra-root gparted`. Details, including polkit agents (`CHANDRA_POLKIT_AGENT`), are in `chandra-root gparted`. Details, including polkit agents (`CHANDRA_POLKIT_AGENT`), are in
[docs/run0.md](docs/run0.md). [docs/run0.md](docs/run0.md).
Face unlock, in the style of Howdy: `just install-face`, then Settings > Session > Face unlock to Face unlock, in the style of Howdy, comes with `just install`: then Settings > Session > Face unlock to
add a face and use it for the password dialog and sudo (a PAM module; the password always still add a face and use it for the password dialog and sudo (a PAM module; the password always still
works). See [docs/face-unlock.md](docs/face-unlock.md), including what 2D face recognition can't works). See [docs/face-unlock.md](docs/face-unlock.md), including what 2D face recognition can't
protect against. protect against.
+2 -2
View File
@@ -104,11 +104,11 @@ test "Settings > Session: face unlock lists faces, adds one, turns it on, remove
test "face unlock status lines" { test "face unlock status lines" {
let f = @shell.FaceUnlock::new() let f = @shell.FaceUnlock::new()
f.apply_status([ f.apply_status([
"backend opencv", "device /dev/video0", "problem OpenCV is missing: run just install-face", "pam polkit-1,sudo", "backend opencv", "device /dev/video0", "problem OpenCV is missing: run just install", "pam polkit-1,sudo",
"howdy login,gdm-password", "face 3\tGlasses\t2026-11-01", "howdy login,gdm-password", "face 3\tGlasses\t2026-11-01",
]) ])
assert_true(f.installed) assert_true(f.installed)
assert_eq(f.problem, "OpenCV is missing: run just install-face") assert_eq(f.problem, "OpenCV is missing: run just install")
assert_true(f.in_use()) assert_true(f.in_use())
assert_eq(f.howdy, "login, gdm-password") assert_eq(f.howdy, "login, gdm-password")
assert_eq(f.faces, [("3", "Glasses", "2026-11-01")]) assert_eq(f.faces, [("3", "Glasses", "2026-11-01")])
+10 -6
View File
@@ -11,20 +11,24 @@ any other service you add it to.
## Setting it up ## Setting it up
```sh ```sh
just install-face # PAM module, chandra-face, settings, face models (asks for root once) just install # comes with the rest of Chandra (asks for root once)
just install --pam # ... and turns it on for polkit-1 and sudo right away
``` ```
`just install` installs the PAM module, `chandra-face`, its settings and the face models along
with the session; `--no-face` leaves them out. Without a C compiler or the PAM headers it warns
and installs everything else.
Nothing from the distro is needed beyond a C compiler and the PAM headers (`libpam0g-dev` / Nothing from the distro is needed beyond a C compiler and the PAM headers (`libpam0g-dev` /
`pam-devel`) and [pixi](https://pixi.sh): Python, OpenCV and numpy come from a pixi environment `pam-devel`) and [pixi](https://pixi.sh): Python, OpenCV and numpy come from a pixi environment
(`face/pixi.toml` + `face/pixi.lock`) that install-face makes in `/usr/local/lib/chandra/face-env`, (`face/pixi.toml` + `face/pixi.lock`) that `just install` makes in `/usr/local/lib/chandra/face-env`,
owned by root. It is deliberately not the checkout's `.pixi`: the PAM module runs that Python as owned by root. It is deliberately not the checkout's `.pixi`: the PAM module runs that Python as
root, so it must not be anywhere a user can write. The models (OpenCV's YuNet face detector and root, so it must not be anywhere a user can write. The models (OpenCV's YuNet face detector and
SFace recognizer, 37 MB) are downloaded from the opencv_zoo repository and checked against their SFace recognizer, 37 MB) are downloaded from the opencv_zoo repository and checked against their
SHA-256 sums. The environment takes about 450 MB. SHA-256 sums. The environment takes about 450 MB.
The Settings rows are part of the session, not of `install-face`: after updating Chandra, run The Settings rows are part of the session: after `just install`, log in again so the
`just install` (or `just install-dev`) and log in again so the compositor, its host and the compositor, its host and the Settings module are the new ones. (`just reload` alone isn't enough: an older host doesn't serve
Settings module are the new ones. (`just reload` alone isn't enough: an older host doesn't serve
the `face-unlock` capability.) Then in **Settings > Session > Face unlock**: the `face-unlock` capability.) Then in **Settings > Session > Face unlock**:
- **Add a face…** asks for your password (in the password dialog), then looks through the - **Add a face…** asks for your password (in the password dialog), then looks through the
@@ -46,7 +50,7 @@ chandra-face clear # forget every face
chandra-face pam enable polkit-1 sudo chandra-face pam enable polkit-1 sudo
chandra-face pam disable # polkit-1 and sudo by default chandra-face pam disable # polkit-1 and sudo by default
chandra-face status # what is set up, what is missing chandra-face status # what is set up, what is missing
just uninstall-face # takes it out of every PAM service first just uninstall [--purge] # takes it out of every PAM service first (--purge: faces too)
``` ```
## In the password dialog ## In the password dialog
+40
View File
@@ -0,0 +1,40 @@
# Installing
One recipe installs everything:
```sh
just install
```
It builds as you first (the compositor as a wasm component, the MoonBit host, the panel modules
and face unlock's PAM module), then asks for root once, through `scripts/as-root` (run0, else
sudo, doas or pkexec; see [run0.md](run0.md)), and installs:
- the "Chandra" login session: `chandra-host`, `compositor.wasm`, `chandra-session`,
`chandra-root`, `chandra-ctl` and the display-manager entries ("Chandra", and "Chandra (X11)"
for Xorg, see [x11.md](x11.md));
- the panel modules, the theme, fonts and wit files under `/usr/local/share/chandra`;
- dark mode for apps: the xdg-desktop-portal backend ([dark-mode.md](dark-mode.md)) and
`chandra-kde-colors` with its KDE color schemes;
- face unlock: `chandra-face`, `pam_chandra_face.so`, `/etc/chandra/face.conf` and the face
models ([face-unlock.md](face-unlock.md)). PAM services are only changed with `--pam`.
Running it again replaces what is there, so it is also how you update. Log in again afterwards
for a new compositor or host; `just reload` picks up new panel modules in a running session
([reloading.md](reloading.md)).
| Flag | What it changes |
|---|---|
| `--link` | Symlink the session into this checkout instead of copying: after that, rebuilding (`just compositor-wasm wasmhost modules`) is all the next login needs, no root. The checkout must stay where it is. Face unlock is copied either way. |
| `--rust` | Use the Rust host (`host-wasm`, about 2 minutes to build cold) instead of the MoonBit one |
| `--native` | Install the native compositor (system-cc release build) instead of the wasm one |
| `--pam` | Also turn face unlock on for `polkit-1` and `sudo` (Settings > Session can do it later) |
| `--no-face` | Leave face unlock out |
| `--no-models` | Don't download the face models now |
Flags combine: `just install --link --pam`. Without a C compiler or the PAM headers
(`libpam0g-dev` / `pam-devel`) face unlock is skipped with a warning and everything else is
installed.
To remove it all: `just uninstall` (face unlock is taken out of every PAM service first).
`just uninstall --purge` also deletes the enrolled faces and `/etc/chandra/face.conf`.
+1 -1
View File
@@ -19,7 +19,7 @@ that: without the handler the signal's default action ends the session.
## Reloading panel modules ## Reloading panel modules
``` ```
just install # or: just modules, with install-dev just install # or: just modules, after `just install --link`
just reload # reload every panel module from disk just reload # reload every panel module from disk
just reload clock-digital # just one just reload clock-digital # just one
``` ```
+1 -1
View File
@@ -15,7 +15,7 @@ Everything below works with sudo, doas or pkexec too; run0 is only preferred whe
## Installing the login session ## Installing the login session
```bash ```bash
just install # or install-dev / install-native / uninstall just install # flags: --link, --rust, --native, --pam, --no-face; and `just uninstall`
``` ```
These go through `scripts/as-root`, which uses run0 if systemd is PID 1 and run0 is installed, These go through `scripts/as-root`, which uses run0 if systemd is PID 1 and run0 is installed,
+2 -2
View File
@@ -248,7 +248,7 @@ class OpenCVRecognizer:
import cv2 # noqa import cv2 # noqa
import numpy # noqa import numpy # noqa
except ImportError: except ImportError:
raise Fail("OpenCV is missing: run just install-face", 2) raise Fail("OpenCV is missing: run just install", 2)
import cv2 import cv2
import numpy as np import numpy as np
@@ -622,7 +622,7 @@ def cmd_status(cfg, user, out):
try: try:
import cv2 # noqa import cv2 # noqa
except ImportError: except ImportError:
problem = "OpenCV is missing: run just install-face" problem = "OpenCV is missing: run just install"
if not problem: if not problem:
for m in MODELS: for m in MODELS:
if not os.path.exists(os.path.join(cfg.models, m)): if not os.path.exists(os.path.join(cfg.models, m)):
+29 -18
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Install (or remove) face unlock. Run as root (`just install-face` does this through """Install (or remove) face unlock. `just install` runs this (through session/install.py, as
scripts/as-root): root) along with the rest of Chandra; `just install --pam` adds --pam, `just uninstall` --remove.
By hand, as root:
run0 python3 face/install.py # install, fetch the face models run0 python3 face/install.py # install, fetch the face models
run0 python3 face/install.py --pam # ... and use it for polkit-1 and sudo run0 python3 face/install.py --pam # ... and use it for polkit-1 and sudo
run0 python3 face/install.py --no-models run0 python3 face/install.py --no-models
run0 python3 face/install.py --pixi PATH # the pixi binary (`just install-face` passes it) run0 python3 face/install.py --pixi PATH # the pixi binary (`just install` passes it)
run0 python3 face/install.py --remove # take it out of every PAM service, uninstall run0 python3 face/install.py --remove # take it out of every PAM service, uninstall
run0 python3 face/install.py --remove --purge # ... and delete the enrolled faces run0 python3 face/install.py --remove --purge # ... and delete the enrolled faces
@@ -14,7 +15,8 @@ Installs:
face/pixi.toml + pixi.lock (root's; nothing from the distro) face/pixi.toml + pixi.lock (root's; nothing from the distro)
/usr/local/lib/chandra/chandra-face the helper (enroll, compare, ...), root's /usr/local/lib/chandra/chandra-face the helper (enroll, compare, ...), root's
/usr/local/bin/chandra-face -> the helper /usr/local/bin/chandra-face -> the helper
<PAM module dir>/pam_chandra_face.so the PAM module (built here with cc; needs libpam headers) <PAM module dir>/pam_chandra_face.so the PAM module (`just install` builds it as you into
build/; else it's built here with cc and the libpam headers)
/etc/chandra/face.conf settings (kept when it exists) /etc/chandra/face.conf settings (kept when it exists)
/var/lib/chandra-face/ enrolled faces /var/lib/chandra-face/ enrolled faces
/usr/local/share/chandra/face/*.onnx the YuNet and SFace models (downloaded, checksummed) /usr/local/share/chandra/face/*.onnx the YuNet and SFace models (downloaded, checksummed)
@@ -61,7 +63,7 @@ def make_env():
pixi = find_pixi() pixi = find_pixi()
if not pixi: if not pixi:
sys.exit("pixi not found: install it (https://pixi.sh) or pass --pixi PATH; " sys.exit("pixi not found: install it (https://pixi.sh) or pass --pixi PATH; "
"`just install-face` passes the one on your PATH") "`just install` passes the one on your PATH")
os.makedirs(env_dir, 0o755, exist_ok=True) os.makedirs(env_dir, 0o755, exist_ok=True)
for f in ("pixi.toml", "pixi.lock"): for f in ("pixi.toml", "pixi.lock"):
shutil.copyfile(os.path.join(here, f), os.path.join(env_dir, f)) shutil.copyfile(os.path.join(here, f), os.path.join(env_dir, f))
@@ -85,7 +87,7 @@ def pam_dir():
if os.geteuid() != 0: if os.geteuid() != 0:
sys.exit("run as root: run0 python3 face/install.py (or sudo), or `just install-face`") sys.exit("run as root: run0 python3 face/install.py (or sudo), or `just install`")
mod = os.path.join(pam_dir(), "pam_chandra_face.so") mod = os.path.join(pam_dir(), "pam_chandra_face.so")
@@ -104,6 +106,10 @@ if "--remove" in sys.argv:
if os.path.isdir(models): if os.path.isdir(models):
shutil.rmtree(models) shutil.rmtree(models)
print("removed", models) print("removed", models)
try:
os.rmdir(os.path.dirname(helper)) # /usr/local/lib/chandra, if nothing else is in it
except OSError:
pass
if "--purge" in sys.argv: if "--purge" in sys.argv:
for p in (store,): for p in (store,):
if os.path.isdir(p): if os.path.isdir(p):
@@ -112,6 +118,10 @@ if "--remove" in sys.argv:
if os.path.exists(conf): if os.path.exists(conf):
os.remove(conf) os.remove(conf)
print("removed", conf) print("removed", conf)
try:
os.rmdir(os.path.dirname(conf)) # /etc/chandra, if nothing else is in it
except OSError:
pass
sys.exit(0) sys.exit(0)
os.umask(0o022) os.umask(0o022)
@@ -130,13 +140,17 @@ if os.path.lexists(link):
os.symlink(helper, link) os.symlink(helper, link)
print("linked", link, "->", helper) print("linked", link, "->", helper)
cc = shutil.which("cc") or shutil.which("gcc") or shutil.which("clang") src = os.path.join(here, "pam_chandra_face.c")
if not cc: built = os.path.join(os.path.dirname(here), "build", "pam_chandra_face.so") # from `just install` (same helper and python paths)
sys.exit("no C compiler: install gcc (and the libpam headers: libpam0g-dev / pam-devel)") if os.path.exists(built) and os.path.getmtime(built) >= os.path.getmtime(src):
subprocess.check_call([cc, "-O2", "-Wall", "-shared", "-fPIC", "-o", mod + ".new", shutil.copyfile(built, mod + ".new")
"-DCHANDRA_FACE_HELPER=\"%s\"" % helper, else:
"-DCHANDRA_FACE_PYTHON=\"%s\"" % py, cc = shutil.which("cc") or shutil.which("gcc") or shutil.which("clang")
os.path.join(here, "pam_chandra_face.c"), "-lpam"]) if not cc:
sys.exit("no C compiler: install gcc (and the libpam headers: libpam0g-dev / pam-devel)")
subprocess.check_call([cc, "-O2", "-Wall", "-shared", "-fPIC", "-o", mod + ".new",
"-DCHANDRA_FACE_HELPER=\"%s\"" % helper,
"-DCHANDRA_FACE_PYTHON=\"%s\"" % py, src, "-lpam"])
os.chmod(mod + ".new", 0o644) os.chmod(mod + ".new", 0o644)
os.replace(mod + ".new", mod) os.replace(mod + ".new", mod)
print("installed", mod) print("installed", mod)
@@ -153,8 +167,5 @@ if "--no-models" not in sys.argv:
subprocess.check_call([py, "-I", helper, "--no-elevate", "fetch-models"]) subprocess.check_call([py, "-I", helper, "--no-elevate", "fetch-models"])
if "--pam" in sys.argv: if "--pam" in sys.argv:
subprocess.check_call([py, "-I", helper, "--no-elevate", "pam", "enable"]) subprocess.check_call([py, "-I", helper, "--no-elevate", "pam", "enable"])
print(""" print("face unlock: add a face in Settings > Session > Face unlock (after logging in to the new "
Settings > Session > Face unlock comes with the session itself (the compositor, its host and the "session), or now with `chandra-face enroll`, then `chandra-face pam enable`")
Settings module), not with this install: if Settings doesn't show it yet, run `just install`
(or `just install-dev`) and log out and in again. Or enroll now from a terminal:
`chandra-face enroll`, then `chandra-face pam enable`.""")
+1 -1
View File
@@ -1,4 +1,4 @@
# Face unlock's Python environment (docs/face-unlock.md): `just install-face` installs it, as # Face unlock's Python environment (docs/face-unlock.md): `just install` installs it, as
# root, into /usr/local/lib/chandra/face-env from this manifest and pixi.lock, so neither # root, into /usr/local/lib/chandra/face-env from this manifest and pixi.lock, so neither
# python3-opencv nor any other distro package is needed. It is root's on purpose: the PAM module # python3-opencv nor any other distro package is needed. It is root's on purpose: the PAM module
# runs this Python as root, so it must not live anywhere a user can write (like this checkout). # runs this Python as root, so it must not live anywhere a user can write (like this checkout).
+38 -53
View File
@@ -44,12 +44,12 @@ run: compositor-wasm wasmhost modules
rm -f {{socket}} rm -f {{socket}}
build/wasmhost build/compositor.wasm --socket {{socket}} --theme {{theme}} --window build/wasmhost build/compositor.wasm --socket {{socket}} --theme {{theme}} --window
# The same on the Rust host (host-wasm), kept as a fallback while the MoonBit host settles in.
# On an X server (NVIDIA's proprietary driver, docs/x11.md): a window under a window manager, or the whole screen without one. # On an X server (NVIDIA's proprietary driver, docs/x11.md): a window under a window manager, or the whole screen without one.
run-x11: compositor-wasm wasmhost modules run-x11: compositor-wasm wasmhost modules
rm -f {{socket}} rm -f {{socket}}
build/wasmhost build/compositor.wasm --socket {{socket}} --theme {{theme}} --x11 build/wasmhost build/compositor.wasm --socket {{socket}} --theme {{theme}} --x11
# The same on the Rust host (host-wasm), kept as a fallback while the MoonBit host settles in.
run-rust: compositor-wasm host-wasm modules run-rust: compositor-wasm host-wasm modules
rm -f {{socket}} rm -f {{socket}}
host-wasm/target/release/chandra-host build/compositor.wasm --socket {{socket}} --theme {{theme}} --window host-wasm/target/release/chandra-host build/compositor.wasm --socket {{socket}} --theme {{theme}} --window
@@ -99,68 +99,53 @@ run-drm-native: build-release modules
-dbus-update-activation-environment --systemd WAYLAND_DISPLAY=$(basename {{socket}}) XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=chandra 2>/dev/null -dbus-update-activation-environment --systemd WAYLAND_DISPLAY=$(basename {{socket}}) XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=chandra 2>/dev/null
{{release_exe}} --drm --socket {{socket}} --theme {{theme}} {{release_exe}} --drm --socket {{socket}} --theme {{theme}}
# Install the Chandra login session (display-manager entry): the wasm compositor + its host (the MoonBit host). Asks for root once. # Install everything (login session, panel modules, KDE colors, portal, face unlock); builds as you, then asks for root once. Flags: --link, --rust, --native, --pam, --no-face (docs/install.md).
install: compositor-wasm wasmhost modules install *flags:
scripts/as-root python3 "{{justfile_directory()}}/session/install.py" #!/usr/bin/env bash
set -euo pipefail
# Dev install: symlink the session into this checkout, so after one root install `just compositor-wasm wasmhost modules` is all a rebuild needs. builds="compositor-wasm wasmhost modules"
install-dev: compositor-wasm wasmhost modules face=1
scripts/as-root python3 "{{justfile_directory()}}/session/install.py" --link for f in {{flags}}; do
case "$f" in
# Install the login session with the Rust host (host-wasm) instead of the MoonBit one. --rust|--native)
install-rust: compositor-wasm host-wasm modules [ -z "${host:-}" ] || [ "$host" = "$f" ] || { echo "just install: --rust and --native exclude each other" >&2; exit 2; }
scripts/as-root python3 "{{justfile_directory()}}/session/install.py" --rust-host host=$f
if [ "$f" = --rust ]; then builds="compositor-wasm host-wasm modules"; else builds="build-release modules"; fi ;;
# Install the login session with the native compositor instead. --no-face) face=0 ;;
install-native: build-release modules --link|--pam|--no-models) ;;
scripts/as-root python3 "{{justfile_directory()}}/session/install.py" --native *) echo "just install: unknown flag $f (--link, --rust, --native, --pam, --no-face, --no-models)" >&2; exit 2 ;;
esac
done
{{just_executable()}} --justfile "{{justfile()}}" $builds
extra=""
if [ "$face" = 1 ]; then
# Build the PAM module as you, so root only copies it.
cc=$(command -v cc || command -v gcc || command -v clang || true)
mkdir -p build
if [ -n "$cc" ] && "$cc" -O2 -Wall -shared -fPIC -o build/pam_chandra_face.so \
-DCHANDRA_FACE_HELPER='"/usr/local/lib/chandra/chandra-face"' face/pam_chandra_face.c -lpam; then
:
else
echo "warning: skipping face unlock: building its PAM module needs a C compiler and the libpam headers (libpam0g-dev / pam-devel)" >&2
extra="--no-face"
fi
fi
# Face unlock's Python + OpenCV come from a root-owned pixi environment: hand root our pixi.
scripts/as-root python3 "{{justfile_directory()}}/session/install.py" {{flags}} $extra \
--pixi "$(command -v pixi || echo "$HOME/.pixi/bin/pixi")"
# Reload the running session's panel modules from disk (after install or `just modules`), keeping their order and settings. `just reload clock-digital` reloads one. See docs/reloading.md. # Reload the running session's panel modules from disk (after install or `just modules`), keeping their order and settings. `just reload clock-digital` reloads one. See docs/reloading.md.
reload *name: reload *name:
python3 session/chandra-ctl reload {{name}} python3 session/chandra-ctl reload {{name}}
# Remove the login session again. # Remove everything `just install` installed (face unlock is taken out of every PAM service first). `just uninstall --purge` also deletes the enrolled faces and /etc/chandra/face.conf.
uninstall: uninstall *flags:
scripts/as-root python3 "{{justfile_directory()}}/session/install.py" --remove scripts/as-root python3 "{{justfile_directory()}}/session/install.py" --remove {{flags}}
# Install face unlock (PAM module + chandra-face + models; docs/face-unlock.md). `just install-face --pam` also turns it on for polkit-1 and sudo. The Settings rows come with the session: `just install` and log in again.
install-face *args:
scripts/as-root python3 "{{justfile_directory()}}/face/install.py" --pixi "$(command -v pixi || echo "$HOME/.pixi/bin/pixi")" {{args}}
# Remove face unlock (from every PAM service first). `just uninstall-face --purge` also deletes the enrolled faces.
uninstall-face *args:
scripts/as-root python3 "{{justfile_directory()}}/face/install.py" --remove {{args}}
# Face unlock tests (fake camera; add --pam as root with pamtester to test the PAM module too). # Face unlock tests (fake camera; add --pam as root with pamtester to test the PAM module too).
test-face *args: test-face *args:
python3 face/test_face.py {{args}} python3 face/test_face.py {{args}}
# Old names, kept so existing habits and scripts still work.
[private]
install-session:
@echo "note: install-session is now 'just install'" >&2
{{just_executable()}} --justfile "{{justfile()}}" install
[private]
install-session-dev:
@echo "note: install-session-dev is now 'just install-dev'" >&2
{{just_executable()}} --justfile "{{justfile()}}" install-dev
[private]
install-session-rust:
@echo "note: install-session-rust is now 'just install-rust'" >&2
{{just_executable()}} --justfile "{{justfile()}}" install-rust
[private]
install-session-native:
@echo "note: install-session-native is now 'just install-native'" >&2
{{just_executable()}} --justfile "{{justfile()}}" install-native
[private]
uninstall-session:
@echo "note: uninstall-session is now 'just uninstall'" >&2
{{just_executable()}} --justfile "{{justfile()}}" uninstall
# Start a Wayland client inside the running compositor (default: foot). # Start a Wayland client inside the running compositor (default: foot).
client *cmd="foot": client *cmd="foot":
WAYLAND_DISPLAY={{socket}} {{cmd}} WAYLAND_DISPLAY={{socket}} {{cmd}}
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Run one command as root with whatever this system uses for that: run0 (systemd 256+), else # Run one command as root with whatever this system uses for that: run0 (systemd 256+), else
# sudo, doas, or pkexec. Used by `just install` and friends. # sudo, doas, or pkexec. Used by `just install` and `just uninstall`.
# #
# scripts/as-root python3 session/install.py # scripts/as-root python3 session/install.py
# #
+1 -1
View File
@@ -21,7 +21,7 @@ if [ -d "$PIXI/lib" ]; then
fi fi
moon build --target native --release --warn-list -a wasmhost/bin moon build --target native --release --warn-list -a wasmhost/bin
mkdir -p build mkdir -p build
# Replace it by renaming, so a running session (install-dev links to it) keeps its copy. # Replace it by renaming, so a running session (`just install --link` links to it) keeps its copy.
cp _build/native/release/build/wasmhost/bin/bin.exe build/wasmhost.new cp _build/native/release/build/wasmhost/bin/bin.exe build/wasmhost.new
mv -f build/wasmhost.new build/wasmhost mv -f build/wasmhost.new build/wasmhost
echo "build/wasmhost $(stat -c %s build/wasmhost) bytes" echo "build/wasmhost $(stat -c %s build/wasmhost) bytes"
+36 -14
View File
@@ -1,19 +1,23 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Install (or remove) the Chandra login session. Run as root, once (`just install` etc. do """Install (or remove) Chandra: the login session and face unlock. `just install` is the way in:
this through scripts/as-root, which uses run0 and falls back to sudo, doas or pkexec): it builds everything as you, then runs this as root once (through scripts/as-root, which uses
run0 and falls back to sudo, doas or pkexec). Running it is idempotent: it replaces what is there.
run0 python3 session/install.py # install: the compositor as a wasm component just install # the compositor as a wasm component on the MoonBit host
run0 python3 session/install.py --link # dev: symlink into this checkout (see below) just install --link # dev: symlink into this checkout (see below)
run0 python3 session/install.py --native # install the native compositor instead just install --rust # the wasm compositor on the Rust host (host-wasm)
run0 python3 session/install.py --rust-host # the wasm compositor on the Rust host (host-wasm) just install --native # the native compositor instead
run0 python3 session/install.py --remove # uninstall just install --pam # also turn face unlock on for polkit-1 and sudo
just install --no-face # leave face unlock out
just uninstall [--purge] # remove it all (--purge: the enrolled faces too)
(`sudo python3 session/install.py` works the same. run0 keeps the working directory when the By hand, from the checkout's root, after building: `run0 python3 session/install.py [FLAGS]`
target is root, so the relative path is fine from the checkout's root.) (`sudo` works the same; run0 keeps the working directory when the target is root).
With --link nothing is copied: the installed files are symlinks to the build outputs in this With --link nothing is copied: the installed files are symlinks to the build outputs in this
checkout, so after one root install, `just compositor-wasm wasmhost modules` is all it takes for the checkout, so after one root install, `just compositor-wasm wasmhost modules` is all it takes for the
next login to run your latest build (no root, no reinstall). The checkout must stay where it is. next login to run your latest build (no root, no reinstall). The checkout must stay where it is.
Face unlock is copied either way (PAM loads it as root: it must not point into a user's checkout).
Installs: Installs:
/usr/local/bin/chandra-host host that runs the compositor component (build/wasmhost) /usr/local/bin/chandra-host host that runs the compositor component (build/wasmhost)
@@ -33,6 +37,7 @@ Installs:
/usr/share/xsessions/chandra-x11.desktop display-manager entry on Xorg (NVIDIA; docs/x11.md) /usr/share/xsessions/chandra-x11.desktop display-manager entry on Xorg (NVIDIA; docs/x11.md)
/usr/share/xdg-desktop-portal/portals/chandra.portal xdg-desktop-portal backend: the compositor /usr/share/xdg-desktop-portal/portals/chandra.portal xdg-desktop-portal backend: the compositor
/usr/share/xdg-desktop-portal/chandra-portals.conf serves Settings (apps' dark/light preference) /usr/share/xdg-desktop-portal/chandra-portals.conf serves Settings (apps' dark/light preference)
face unlock face/install.py (chandra-face, pam_chandra_face.so, models)
""" """
import os, shutil, subprocess, sys import os, shutil, subprocess, sys
@@ -40,9 +45,9 @@ root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
native = "--native" in sys.argv native = "--native" in sys.argv
linked = "--link" in sys.argv linked = "--link" in sys.argv
exe = os.path.join(root, "_build/native/release/build/compositor/bin/bin.exe") exe = os.path.join(root, "_build/native/release/build/compositor/bin/bin.exe")
rust_host = "--rust-host" in sys.argv rust_host = "--rust" in sys.argv or "--rust-host" in sys.argv
# The host that runs the compositor component: the MoonBit one (just wasmhost), or the Rust # The host that runs the compositor component: the MoonBit one (just wasmhost), or the Rust
# one (just host-wasm) with --rust-host. Either is installed as chandra-host. # one (just host-wasm) with --rust. Either is installed as chandra-host.
host_build = "just host-wasm" if rust_host else "just wasmhost" host_build = "just host-wasm" if rust_host else "just wasmhost"
host = os.path.join(root, "host-wasm/target/release/chandra-host" if rust_host else "build/wasmhost") host = os.path.join(root, "host-wasm/target/release/chandra-host" if rust_host else "build/wasmhost")
component = os.path.join(root, "build/compositor.wasm") component = os.path.join(root, "build/compositor.wasm")
@@ -65,7 +70,21 @@ targets = [
if os.geteuid() != 0: if os.geteuid() != 0:
sys.exit("run as root: run0 python3 session/install.py (or sudo), or `just install`") sys.exit("run as root: run0 python3 session/install.py (or sudo), or `just install`")
face_flags = [f for f in sys.argv[1:] if f in ("--pam", "--no-models", "--purge")]
if "--pixi" in sys.argv and sys.argv.index("--pixi") + 1 < len(sys.argv):
face_flags += ["--pixi", sys.argv[sys.argv.index("--pixi") + 1]]
def face(*flags):
"""Face unlock has its own installer (face/install.py); run it as part of this one. Its failure
(no network for the models, say) doesn't undo the session: say so, and fail at the end."""
rc = subprocess.call([sys.executable, os.path.join(root, "face/install.py")] + list(flags) + face_flags)
if rc != 0:
print("warning: face unlock: face/install.py %s failed (exit %d)" % (" ".join(flags + tuple(face_flags)), rc),
file=sys.stderr)
return rc
if "--remove" in sys.argv: if "--remove" in sys.argv:
face_rc = face("--remove")
for t in targets: for t in targets:
if os.path.lexists(t): if os.path.lexists(t):
os.remove(t) os.remove(t)
@@ -76,7 +95,7 @@ if "--remove" in sys.argv:
if os.path.isdir(share) and not os.path.islink(share): if os.path.isdir(share) and not os.path.islink(share):
shutil.rmtree(share) # removes symlinks, never what they point at shutil.rmtree(share) # removes symlinks, never what they point at
print("removed", share) print("removed", share)
sys.exit(0) sys.exit(1 if face_rc else 0)
if native: if native:
if not os.path.exists(exe): if not os.path.exists(exe):
@@ -169,9 +188,10 @@ mods = os.path.join(root, "build/components")
dst = os.path.join(share, "modules") dst = os.path.join(share, "modules")
if linked: if linked:
link(mods, dst) link(mods, dst)
face_rc = face() if "--no-face" not in sys.argv else 0
print("done: pick 'Chandra' in the session menu; rebuild with `just compositor-wasm %s modules`" % host_build.split()[1]) print("done: pick 'Chandra' in the session menu; rebuild with `just compositor-wasm %s modules`" % host_build.split()[1])
print("(in a running session, `just modules reload` picks up rebuilt panel modules)") print("(in a running session, `just reload` picks up rebuilt panel modules)")
sys.exit(0) sys.exit(1 if face_rc else 0)
if os.path.lexists(dst): if os.path.lexists(dst):
shutil.rmtree(dst) if os.path.isdir(dst) and not os.path.islink(dst) else os.remove(dst) shutil.rmtree(dst) if os.path.isdir(dst) and not os.path.islink(dst) else os.remove(dst)
os.makedirs(dst, exist_ok=True) os.makedirs(dst, exist_ok=True)
@@ -183,6 +203,8 @@ for f in sorted(os.listdir(mods)) if os.path.isdir(mods) else []:
if n == 0: if n == 0:
sys.exit("no modules in build/components - run `just modules` first") sys.exit("no modules in build/components - run `just modules` first")
print("installed", n, "modules in", dst) print("installed", n, "modules in", dst)
face_rc = face() if "--no-face" not in sys.argv else 0
print("done: pick 'Chandra' in the session menu of your login screen") print("done: pick 'Chandra' in the session menu of your login screen")
print("already in a Chandra session? `just reload` (chandra-ctl reload) picks up the new panel modules;") print("already in a Chandra session? `just reload` (chandra-ctl reload) picks up the new panel modules;")
print("the compositor and host themselves need a new session (docs/reloading.md)") print("the compositor and host themselves need a new session (docs/reloading.md)")
sys.exit(1 if face_rc else 0)
+1 -1
View File
@@ -2,7 +2,7 @@
The host that runs the compositor component (`build/compositor.wasm`): `just run`, `just run-drm` The host that runs the compositor component (`build/compositor.wasm`): `just run`, `just run-drm`
and `just install` use it. It replaces the Rust `host-wasm/`, which stays as a fallback and `just install` use it. It replaces the Rust `host-wasm/`, which stays as a fallback
(`just run-rust`, `just run-drm-rust`, `just install-rust`). (`just run-rust`, `just run-drm-rust`, `just install --rust`).
It links wasmtime as the prebuilt C API library (`libwasmtime.a` from the upstream It links wasmtime as the prebuilt C API library (`libwasmtime.a` from the upstream
`wasmtime-v$WASMTIME_VERSION-x86_64-linux-c-api` release, fetched by `scripts/setup-toolchain.sh` `wasmtime-v$WASMTIME_VERSION-x86_64-linux-c-api` release, fetched by `scripts/setup-toolchain.sh`
+1 -1
View File
@@ -348,7 +348,7 @@ interface face-unlock {
/// What the running change said last ("Look at the camera… 3/5"), or how the last one /// What the running change said last ("Look at the camera… 3/5"), or how the last one
/// ended; empty when none ran. /// ended; empty when none ran.
message: string, message: string,
/// chandra-face is installed (`just install-face`). /// chandra-face is installed (`just install`).
installed: bool, installed: bool,
/// The password dialog (PAM service polkit-1) and sudo try the face first. /// The password dialog (PAM service polkit-1) and sudo try the face first.
in-use: bool, in-use: bool,