Everything below the CLI was merged and green against fakes; none of it was
reachable and none of it had ever met a compositor. This wires it up and then
puts the compositor in a position to disagree.
CLI (src/hhstream/cli.py, src/hhstream_session/**)
session container [ID], session reconcile [ID], and the seven pointer verbs
from PLAN §9. `start` still prints the bare session id and nothing else.
`list` gains WS / OUTPUT / POINTER, with the gap marker where a value is
genuinely unknown rather than a blank that reads as zero -- the POINTER
column needs a second, read-only `pointer.state` call because the `list`
reply carries no lease state.
The lease id is cached in `hhstream_session.lease` (under
$XDG_RUNTIME_DIR), because PLAN §9's gesture verbs take no --lease and the
wire requires a lease_id on every one of them; --lease and $HHSTREAM_LEASE
override it, and a `no_lease` refusal drops the stale entry.
Exit codes are the contract's: a gesture with no lease is 9 and never
reaches the broker, and a compositor failure is 10 with a message that says
the session is still running. `kill` now warns about
`session.container_survivors` -- windows the compositor still shows -- and
distinguishes `null` ("could not ask") from `[]`.
`shot`/`record --output NAME` capture one container through `grim -o`; the
frame socket publishes the main output only, so it cannot do it.
Module (nix/module.nix)
sessions.containers.{enable,max,mode,workspaceBase},
sessions.pointer.{enable,leaseTtl,leaseMax}, rendered into the generated
TOML with §10's key names. hhstream-pointer.service: the operator's account,
supplementary group hhstream, After=/BindsTo= the compositor,
Restart=on-failure, KillMode=process, and the command line §3.4 freezes.
tmpfiles for /run/hhstream plus RuntimeDirectoryPreserve on the broker,
without which restarting the broker deletes the driver's socket out from
under it. The runtime-directory length assertion is untouched.
And ExecStartPost on the compositor, opening its IPC directory to its own
group: Hyprland creates <runtime>/hypr with S_IRWXU, so the broker -- a
different account by design -- could not reach the request or event socket
at all, and degraded silently exactly as it is built to.
Checks (checks/**)
vm-ipc: both sockets at their frozen names, measured against sun_path's 108
bytes, and a socket2 subscriber that receives an openwindow for a window the
test creates. The subscriber is the shipped HyprlandIPC, not a second
implementation: this check exists to prove that this client hears this
compositor.
vm-containers: one hh-* output per session at the container mode, the window
on it, a second window of the same application beside it, an unmatched
window quarantined, grim -o isolating one container, teardown removing the
output and freeing the slot. PLAN experiment 3 is answered: `hyprctl output
create headless` works.
vm-pointer: a version-2 virtual pointer, a warp and a click whose
coordinates the *application* reports, BUSY naming the holder, an expired
lease swept with its held button lifted, and a broker restart that leaves
the lock free, the bookmark intact and the driver reachable.
checks/lib gains the guest the three share, their test-script helpers (no
assertions live there), an event-socket subscriber and a Wayland client that
says where it was clicked -- nothing in nixpkgs both honours
$HHSTREAM_APP_ID and reports pointer events.
Reported, not worked around: the broker reads none of the container or
pointer config (policy.py takes [defaults] and [apps] only), `start` has no
no_container field so --no-container is refused rather than silently ignored,
and nix/hyprland-conf.nix sets input:follow_mouse = 0, which sends pointer
events to the focused window only -- measured, with the cursor at the aimed
pixel and no client told. README.dev.md has the evidence for each.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQy29x9AfHWyzNd1f7XPGK
126 lines
4.0 KiB
Nix
126 lines
4.0 KiB
Nix
# The guest the three session checks share: compositor, broker, one account.
|
|
#
|
|
# A function rather than a copy in each check, because what the three differ in
|
|
# is the *assertions*, not the machine, and three drifting copies of a machine
|
|
# definition is how a check quietly stops testing what its neighbour tests.
|
|
# Everything that varies is an argument; nothing here relaxes an assertion.
|
|
#
|
|
# It is a machine, not a test. `gpu-session.nix` supplies the two pieces of
|
|
# hardware a bare NixOS test machine lacks (see that file); this adds the
|
|
# module under test, the account applications run as, and the tools the guest
|
|
# needs to interrogate the compositor.
|
|
{
|
|
hhsModule,
|
|
hhstream,
|
|
hyprland,
|
|
testTools,
|
|
sessionTools,
|
|
foot,
|
|
jq,
|
|
procps,
|
|
grim,
|
|
coreutils,
|
|
dejavu_fonts,
|
|
}:
|
|
{
|
|
# The allowlist, as `sessions.apps` takes it.
|
|
apps,
|
|
pointer ? false,
|
|
# Only read when `pointer` is true; the module's own defaults otherwise.
|
|
leaseTtl ? 30,
|
|
leaseMax ? 300,
|
|
width ? 1280,
|
|
height ? 720,
|
|
fps ? 30,
|
|
sessionUser ? "hermes",
|
|
# Long enough that nothing is reaped by surprise mid-check, short enough that
|
|
# the number is visibly the test's and not the module's 3 h default.
|
|
idleTimeout ? 600,
|
|
# The group that owns the compositor's runtime directory. The module's
|
|
# default, named here because this fragment is a plain attribute set (the
|
|
# test driver's `nodes.<name>` does not take a function) and so cannot read
|
|
# it back out of `config`.
|
|
sessionGroup ? "hhstream",
|
|
# Appended to the generated hyprland.conf. Only `vm-pointer` uses it, and
|
|
# only for one line it has to override; see that file for the measurement.
|
|
extraConfig ? "",
|
|
}:
|
|
{
|
|
imports = [
|
|
hhsModule
|
|
./gpu-session.nix
|
|
];
|
|
|
|
services.hyprland-headless-stream = {
|
|
enable = true;
|
|
package = hhstream;
|
|
hyprlandPackage = hyprland;
|
|
inherit extraConfig;
|
|
# No `name`: the wildcard rule applies to whatever connector the virtio GPU
|
|
# gives this guest (see vm-hyprland.nix for why a check must not know it).
|
|
outputs = [
|
|
{
|
|
inherit width height;
|
|
refresh = fps;
|
|
}
|
|
];
|
|
|
|
sessions = {
|
|
enable = true;
|
|
user = sessionUser;
|
|
inherit apps idleTimeout;
|
|
pointer = {
|
|
enable = pointer;
|
|
inherit leaseTtl leaseMax;
|
|
};
|
|
};
|
|
};
|
|
|
|
# The module deliberately does not create this user: launched applications
|
|
# run as it, so it is normally a real person's account. `video` and `render`
|
|
# are what any client of this session needs to reach the GPU; the broker's
|
|
# unit adds the compositor's own group on top.
|
|
users.users.${sessionUser} = {
|
|
isNormalUser = true;
|
|
extraGroups = [
|
|
"video"
|
|
"render"
|
|
# The compositor's own group, on the *account*.
|
|
#
|
|
# The broker does not need this -- its unit has the group as a
|
|
# supplementary one, which is how the applications it launches reach the
|
|
# Wayland socket. This is for the other half of the CLI: `hhstream shot
|
|
# --output hh-<id>` runs grim as whoever typed it, and the frame socket
|
|
# and runtime directory are 0750/0660 owned by this group. The operator
|
|
# account on a real machine is in it for exactly that reason -- it is
|
|
# what `hhstream`'s `sg` re-exec exists to recover when a login predates
|
|
# the membership.
|
|
sessionGroup
|
|
];
|
|
};
|
|
|
|
# foot resolves "monospace" through fontconfig and refuses to start without a
|
|
# usable font; a NixOS test machine has `fonts.enableDefaultPackages = false`.
|
|
# One font, not the default set.
|
|
fonts.packages = [ dejavu_fonts ];
|
|
|
|
environment.systemPackages = [
|
|
testTools # hhs-hyprland-diagnostics
|
|
sessionTools # hhs-ipc-watch, hhs-pointer-target
|
|
hhstream # the CLI under test
|
|
hyprland # hyprctl: the compositor is the source of truth here
|
|
foot
|
|
grim # per-container capture, which is what an output *is* for
|
|
jq # the in-guest predicates the bounded waits poll
|
|
procps
|
|
coreutils
|
|
];
|
|
|
|
virtualisation = {
|
|
memorySize = 2048;
|
|
cores = 2;
|
|
diskSize = 4096;
|
|
graphics = false;
|
|
};
|
|
}
|