# 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, # The XKB layout the pointer unit uploads as its virtual keyboard's keymap. # There is no `keyboard.enable`: the keyboard is the same unit, the same # process and the same lease as the pointer, so `pointer = true` is what # turns typing on. This is only the layout, and `vm-keyboard` is the only # check that sets it to anything but the default -- it runs twice, once per # layout, because the layout only reaches the keymap through this unit's # argv and a second value is the only way to prove that. keyboardLayout ? "us", keyboardModel ? "pc105", keyboardVariant ? "", keyboardOptions ? "", 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.` 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; }; keyboard = { layout = keyboardLayout; model = keyboardModel; variant = keyboardVariant; options = keyboardOptions; }; }; }; # 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-` 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, hhs-keyboard-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; }; }