{inputs, ...}: { perSystem = { lib, pkgs, ... }: let python = pkgs.python311; workspace = inputs.uv2nix.lib.workspace.loadWorkspace {workspaceRoot = ./.;}; pythonSet = (pkgs.callPackage inputs.pyproject-nix.build.packages {inherit python;}).overrideScope (lib.composeManyExtensions ([ inputs.pyproject-build-systems.overlays.wheel (workspace.mkPyprojectOverlay {sourcePreference = "wheel";}) ] ++ lib.optional (lib.versionAtLeast python.version "3.15") (final: prev: { # The pinned source archive uses the setuptools build backend. dill = prev.dill.overrideAttrs (old: { nativeBuildInputs = (old.nativeBuildInputs or []) ++ final.resolveBuildSystem {setuptools = [];}; }); }))); # A role alias must live beside the venv interpreter for CPython to find # pyvenv.cfg. The daemon cannot create aliases in the immutable store. # pyproject.nix's launcher rewrites argv[0] to pythonX.Y. Use CPython's # normal venv link so named processes retain their role and prefix. venvLinks = '' ln -sfn "${python.interpreter}" "$out/bin/${python.executable}" for role in bridge colab discord hook kernel photon-bridge pty signal spare ssh verifier watchdog zygote; do ln -s python3 "$out/bin/albedo-$role" done ''; # The kernel environment with the test-only dependency groups added. The # development shell puts it first on PATH for the test code. A daemon # started without ALBEDO_KERNEL_PYTHON runs kernels from it, so it takes # the same links. Shipped daemons use albedo-kernel-python, without them. testEnv = (pythonSet.mkVirtualEnv "albedo-kernel-python-test" workspace.deps.all).overrideAttrs { postInstall = venvLinks; }; in { packages.albedo-kernel-python-test = testEnv; packages.albedo-kernel-python = (pythonSet.mkVirtualEnv "albedo-kernel-python" workspace.deps.default).overrideAttrs { # The loopback SSH tests install from these same wheels without network. passthru.testWheels = pkgs.linkFarm "albedo-kernel-test-wheels" ( map (package: { name = package.src.name; path = package.src; }) (builtins.filter (package: lib.hasSuffix ".whl" (package.src.name or "")) (pythonSet.resolveVirtualEnv workspace.deps.default)) ); postInstall = venvLinks; }; }; }