{ description = "motionlab - realtime camera + motion graphics playground"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; outputs = { self, nixpkgs }: let systems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); # not in nixpkgs; sends frames to the OBS virtual camera (macOS) or v4l2loopback (Linux) pyvirtualcamFor = ps: ps.buildPythonPackage rec { pname = "pyvirtualcam"; version = "0.15.0"; pyproject = true; src = nixpkgs.legacyPackages.${ps.python.stdenv.hostPlatform.system}.fetchFromGitHub { owner = "letmaik"; repo = "pyvirtualcam"; tag = "v${version}"; fetchSubmodules = true; hash = "sha256-JtFchhuvVYYhrYOOcsHPC79/Iezyo5QppV4tY9nrjgQ="; }; build-system = [ ps.setuptools ps.pybind11 ]; dependencies = [ ps.numpy ]; doCheck = false; pythonImportsCheck = [ "pyvirtualcam" ]; }; pythonFor = pkgs: pkgs.python3.withPackages (ps: [ ps.numpy ps.moderngl (pyvirtualcamFor ps) # macOS gets a Cocoa window out of the box; Linux needs GTK for cv2.imshow (if pkgs.stdenv.hostPlatform.isLinux then ps.opencv4.override { enableGtk3 = true; } else ps.opencv4) ]); in { devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = [ (pythonFor pkgs) ]; }; }); apps = forAllSystems (pkgs: { default = { type = "app"; program = toString (pkgs.writeShellScript "motionlab" '' exec ${pythonFor pkgs}/bin/python ${self}/main.py "$@" ''); }; }); }; }