Wires a `checks` output into the flake, one file per check under checks/, all three asserting docs/CONTRACT.md rather than the implementation: - unit: pytest over tests/unit/ in the build sandbox, against the nix/package.nix build. Refuses an empty suite -- pytest exits 0 when every test was skipped or deselected, so checks/lib/check_report.py parses the JUnit report and fails on zero collected or zero executed. - vm-basic: nixosTest with captureCommand pointed at tests/fake_capture.py, which emits one fixed deterministic PNG. Because the image never changes, "two frames arrived and they are the same bytes" is an assertion about the framing rather than a coincidence. - vm-hyprland: the same machine with no captureCommand override, so grim captures the real compositor. Deliberately impatient -- bounded timeouts, no retry loops, and a full diagnostics dump (compositor log, hyprctl monitors, both journals) before any failure propagates. tests/assert_stream.py is a second, independent reader of the contract: it shares no code with hhstream.client, so a framing bug present in both the server's writer and the shipped client's reader still fails. The unit suite's negative tests use a `rejects` fixture instead of pytest.raises(Exception), which an unimplemented stub's NotImplementedError would otherwise satisfy. Three defects found in code this branch does not own, recorded in README.dev.md rather than worked around: - nix/module.nix has no config side, so neither unit exists and both VM checks fail at their first wait; - services.hyprland-headless-stream.package is declared with no default, against docs/CONTRACT.md; - src/hhstream/*.py is all stubs, so 66 of 70 unit tests fail. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017YXMoCNxzScTaKNr43GQNz
52 lines
1.8 KiB
Nix
52 lines
1.8 KiB
Nix
{
|
|
description = "Stream a headless Hyprland session to a persistent Unix socket";
|
|
|
|
# Matches the nixpkgs this was developed against; consumers can override with
|
|
# inputs.nixpkgs.follows = "nixpkgs" and nothing breaks.
|
|
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
|
|
|
|
outputs = { self, nixpkgs, ... }: let
|
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (import nixpkgs { inherit system; }));
|
|
# `checks` needs the system name as well as the package set, to reach
|
|
# self.packages.<system>; forAllSystems only hands over pkgs.
|
|
forAllSystems' = f: nixpkgs.lib.genAttrs systems (system:
|
|
f { inherit system; pkgs = import nixpkgs { inherit system; }; });
|
|
in {
|
|
packages = forAllSystems (pkgs: rec {
|
|
hhstream = pkgs.callPackage ./nix/package.nix {};
|
|
default = hhstream;
|
|
});
|
|
|
|
nixosModules = rec {
|
|
hyprland-headless-stream = import ./nix/module.nix;
|
|
default = hyprland-headless-stream;
|
|
};
|
|
|
|
# Unit tests + the two VM integration tests. See checks/default.nix and
|
|
# README.dev.md; the interface they assert is docs/CONTRACT.md.
|
|
checks = forAllSystems' ({ pkgs, system }:
|
|
import ./checks { inherit pkgs self system; });
|
|
|
|
devShells = forAllSystems (pkgs: {
|
|
default = pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
python3
|
|
python3.pkgs.pytest
|
|
git
|
|
tmux
|
|
jq
|
|
hyprland
|
|
grim
|
|
ffmpeg
|
|
];
|
|
shellHook = ''
|
|
export PYTHONPATH="$PWD/src''${PYTHONPATH:+:$PYTHONPATH}"
|
|
echo "hhstream dev shell -- python $(python3 --version 2>&1 | cut -d' ' -f2)"
|
|
'';
|
|
};
|
|
});
|
|
|
|
formatter = forAllSystems (pkgs: pkgs.alejandra);
|
|
};
|
|
} |