objectifier/objectifier.nix

40 lines
836 B
Nix
Raw Permalink Normal View History

2023-01-06 14:46:11 -08:00
{ pkgs, lib, ... }:
2023-01-07 14:47:35 -08:00
let
objectifier-src = pkgs.stdenv.mkDerivation {
name = "objectifier";
src = ./src;
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out
cp $src/detector.py $out/detector.py
2023-01-07 15:56:12 -08:00
cp $src/objectifier.py $out/objectifier.py
2023-01-07 14:47:35 -08:00
'';
};
pythonYolo = pkgs.python3.withPackages (pyPkgs:
with pyPkgs; [
gunicorn
fastapi
gunicorn
opencv4
python-multipart
uvicorn
]);
in pkgs.writeShellApplication {
2023-01-06 14:46:11 -08:00
name = "objectifier";
2023-01-07 14:47:35 -08:00
runtimeInputs = [ pythonYolo ];
2023-01-07 15:28:54 -08:00
text = let
script = pkgs.lib.concatStringsSep " " [
"gunicorn"
"objectifier:app"
"-k uvicorn.workers.UvicornWorker"
''"$@"''
];
in ''
2023-01-07 16:16:03 -08:00
export CACHE_DIRECTORY STATE_DIRECTORY
2023-01-07 15:44:12 -08:00
export PYTHONPATH="${objectifier-src}"
2023-01-07 15:28:54 -08:00
${script}
'';
2023-01-06 14:46:11 -08:00
}