Files
2026-09-28 05:01:41 +00:00

91 lines
2.9 KiB
Nix

{ lib, config, pkgs, ... }:
# Interface only: every option in docs/CONTRACT.md is declared here so tests and
# consumers can be written against a stable surface. The systemd wiring is the
# next piece of work (see docs/CONTRACT.md -> "Services").
let
cfg = config.services.hyprland-headless-stream;
in {
options.services.hyprland-headless-stream = {
enable = lib.mkEnableOption "a headless Hyprland session streamed to a Unix socket";
socketPath = lib.mkOption {
type = lib.types.str;
default = "/run/hyprland-headless-stream/stream.sock";
description = "Where the frame server publishes frames.";
};
user = lib.mkOption {
type = lib.types.str;
default = "hhstream";
description = "User the compositor and frame server run as.";
};
group = lib.mkOption {
type = lib.types.str;
default = "hhstream";
description = "Group owning the socket.";
};
frameRate = lib.mkOption {
type = lib.types.ints.positive;
default = 30;
description = "Target capture rate; becomes `fps` in the protocol Hello.";
};
format = lib.mkOption {
type = lib.types.enum [ "png" "jpeg" ];
default = "png";
description = "Frame encoding.";
};
outputs = lib.mkOption {
type = lib.types.listOf (lib.types.submodule {
options = {
name = lib.mkOption { type = lib.types.str; };
width = lib.mkOption { type = lib.types.ints.positive; default = 1280; };
height = lib.mkOption { type = lib.types.ints.positive; default = 720; };
refresh = lib.mkOption { type = lib.types.ints.positive; default = 30; };
scale = lib.mkOption { type = lib.types.positive; default = 1.0; };
};
});
default = [ { name = "HEADLESS-1"; width = 1280; height = 720; refresh = 30; scale = 1.0; } ];
description = "Virtual monitors the compositor should create.";
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Extra lines appended to hyprland.conf.";
};
hyprlandPackage = lib.mkOption {
type = lib.types.package;
default = pkgs.hyprland;
defaultText = lib.literalExpression "pkgs.hyprland";
description = "Compositor to run.";
};
package = lib.mkOption {
type = lib.types.package;
description = "The frame server / client package.";
};
captureCommand = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "grim" "-t" "png" "-" ];
description = "Command that writes one frame to stdout; overridable for tests.";
};
};
config = lib.mkIf cfg.enable {
# TODO(module): user/group, runtime dir, hyprland.conf rendering, the two
# systemd units named in docs/CONTRACT.md.
assertions = [
{
assertion = cfg.outputs != [ ];
message = "services.hyprland-headless-stream.outputs must not be empty.";
}
];
};
}