From c7368a7fc63fbcaef0d120f3497070f915a749ce Mon Sep 17 00:00:00 2001 From: Philippe Laflamme Date: Mon, 18 May 2026 11:00:46 -0400 Subject: [PATCH 1/4] ustreamer: make available as python package Makes `ustreamer`'s python module available as `pythonPackages.ustreamer`. --- pkgs/top-level/python-packages.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 23139cad77a1..08cdb1066173 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -21662,6 +21662,13 @@ self: super: with self; { usort = callPackage ../development/python-modules/usort { }; + ustreamer = toPythonModule ( + pkgs.ustreamer.override { + python3Packages = self; + withPython = true; + } + ); + utils = callPackage ../development/python-modules/utils { }; utitools = callPackage ../development/python-modules/utitools { }; From 160f8ff34ca796fdbc784d32be2c8bd482a94324 Mon Sep 17 00:00:00 2001 From: Philippe Laflamme Date: Tue, 28 Jul 2026 16:22:51 -0400 Subject: [PATCH 2/4] ustreamer: include `python` executable in nativeBuildInputs This seems necessary when cross-compiling. --- pkgs/by-name/us/ustreamer/package.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/us/ustreamer/package.nix b/pkgs/by-name/us/ustreamer/package.nix index 296f2b34a4f8..de7f2be8d506 100644 --- a/pkgs/by-name/us/ustreamer/package.nix +++ b/pkgs/by-name/us/ustreamer/package.nix @@ -62,7 +62,13 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ pkg-config which - ]; + ] + ++ lib.optionals withPython ( + with python3Packages; + [ + python + ] + ); makeFlags = [ "PREFIX=${placeholder "out"}" From 69264c54f0167d34e3003434c6425ab8a439aa38 Mon Sep 17 00:00:00 2001 From: Philippe Laflamme <484152+plaflamme@users.noreply.github.com> Date: Wed, 29 Jul 2026 18:41:15 +0000 Subject: [PATCH 3/4] ustreamer: apply format suggestion Co-authored-by: Jacek Galowicz --- pkgs/by-name/us/ustreamer/package.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/by-name/us/ustreamer/package.nix b/pkgs/by-name/us/ustreamer/package.nix index de7f2be8d506..61abe3c6adea 100644 --- a/pkgs/by-name/us/ustreamer/package.nix +++ b/pkgs/by-name/us/ustreamer/package.nix @@ -63,12 +63,7 @@ stdenv.mkDerivation (finalAttrs: { pkg-config which ] - ++ lib.optionals withPython ( - with python3Packages; - [ - python - ] - ); + ++ lib.optional withPython python3Packages.python; makeFlags = [ "PREFIX=${placeholder "out"}" From f79911170920d361fd42cc1509748ab2f2d296fa Mon Sep 17 00:00:00 2001 From: Philippe Laflamme Date: Sat, 1 Aug 2026 12:05:25 -0400 Subject: [PATCH 4/4] ustreamer: add test for ustreamer's python package --- nixos/tests/ustreamer.nix | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/nixos/tests/ustreamer.nix b/nixos/tests/ustreamer.nix index a9cf7150915e..8a1820d19d06 100644 --- a/nixos/tests/ustreamer.nix +++ b/nixos/tests/ustreamer.nix @@ -1,4 +1,7 @@ { pkgs, ... }: +let + test-output-filename = "snapshot.jpeg"; +in { name = "ustreamer-vmtest"; nodes = { @@ -43,13 +46,35 @@ formats/2/height = 480 formats/2/fps = 20/1, 15/2 ''; + + test-stream-name = "test_stream.jpeg"; + + test-ustreamer-python = + pkgs.writers.writePython3Bin "test-ustreamer-python" + { + libraries = [ pkgs.python3Packages.ustreamer ]; + } + '' + import ustreamer + + with ustreamer.Memsink("${test-stream-name}") as sink: + frame = sink.wait_frame() + with open("${test-output-filename}", "wb") as file: + file.write(frame["data"]) + ''; in { services.ustreamer = { enable = true; device = "/dev/video9"; - extraArgs = [ "--device-timeout=8" ]; + extraArgs = [ + "--device-timeout=8" + "--sink=${test-stream-name}" + ]; }; + environment.systemPackages = [ + test-ustreamer-python + ]; networking.firewall.allowedTCPPorts = [ 8080 ]; boot.extraModulePackages = [ config.boot.kernelPackages.akvcam ]; @@ -68,5 +93,8 @@ client.wait_for_unit("multi-user.target") client.succeed("curl http://camera:8080") + + camera.succeed("test-ustreamer-python") + camera.wait_for_file('${test-output-filename}') ''; }