9 python = python3.override {
12 packageOverrides = self: super: {
13 pydantic = super.pydantic_1;
15 versioningit = super.versioningit.overridePythonAttrs (_: {
19 albumentations = super.albumentations.overridePythonAttrs (old: rec {
21 src = fetchFromGitHub {
22 owner = "albumentations-team";
23 repo = "albumentations";
25 hash = "sha256-JIBwjYaUP4Sc1bVM/zlj45cz9OWpb/LOBsIqk1m+sQA=";
27 dependencies = old.dependencies ++ [
34 python.pkgs.buildPythonApplication rec {
35 pname = "immich-machine-learning";
36 inherit (immich) version;
37 src = "${immich.src}/machine-learning";
41 substituteInPlace pyproject.toml --replace-fail 'fastapi-slim' 'fastapi'
43 # AttributeError: module 'cv2' has no attribute 'Mat'
44 substituteInPlace app/test_main.py --replace-fail ": cv2.Mat" ""
47 pythonRelaxDeps = [ "setuptools" ];
48 pythonRemoveDeps = [ "opencv-python-headless" ];
50 build-system = with python.pkgs; [
74 ++ uvicorn.optional-dependencies.standard;
76 nativeCheckInputs = with python.pkgs; [
84 mkdir -p $out/share/immich
85 cp log_conf.json $out/share/immich
87 cp -r ann $out/${python.sitePackages}/
89 makeWrapper ${lib.getExe python.pkgs.gunicorn} "''${!outputBin}"/bin/machine-learning \
90 --prefix PYTHONPATH : "$out/${python.sitePackages}:${python.pkgs.makePythonPath dependencies}" \
91 --set-default MACHINE_LEARNING_WORKERS 1 \
92 --set-default MACHINE_LEARNING_WORKER_TIMEOUT 120 \
93 --set-default MACHINE_LEARNING_CACHE_FOLDER /var/cache/immich \
94 --set-default IMMICH_HOST "[::]" \
95 --set-default IMMICH_PORT 3003 \
96 --add-flags "app.main:app -k app.config.CustomUvicornWorker \
97 -w \"\$MACHINE_LEARNING_WORKERS\" \
98 -b \"\$IMMICH_HOST:\$IMMICH_PORT\" \
99 -t \"\$MACHINE_LEARNING_WORKER_TIMEOUT\"
100 --log-config-json $out/share/immich/log_conf.json"
104 inherit (nixosTests) immich;
108 description = "Self-hosted photo and video backup solution (machine learning component)";
109 homepage = "https://immich.app/";
110 license = lib.licenses.agpl3Only;
111 maintainers = with lib.maintainers; [ jvanbruegge ];
112 mainProgram = "machine-learning";
113 inherit (immich.meta) platforms;