-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
81 lines (69 loc) · 2.97 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { nixpkgs, ... }:
let
forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" ];
in
{
devShells = forAllSystems (system: {
default = with (import nixpkgs {
inherit system;
config = { allowUnfree = true; };
}); mkShell {
buildInputs = [
gcc-unwrapped
glib
azure-cli
azure-functions-core-tools
python311
python311Packages.virtualenv
];
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.libGL}/lib/:${pkgs.glib.out}/lib";
DONT_PROMPT_WSL_INSTALL="true";
shellHook = ''
extensions="ms-python.python ms-azuretools.vscode-azurefunctions humao.rest-client"
if ! command -v code &> /dev/null; then
echo "VSCode could not be found. Please install VSCode and the missing plugins '$extensions' manually."
else
echo "VSCode is installed. Checking for required extensions..."
for extension in $extensions; do
if ! code --list-extensions | grep -q "$extension"; then
code --install-extension "$extension"
fi
done
fi
echo "Creating directory structure..."
mkdir -p ./HttpTrigger/models
echo "Navigating to HttpTrigger directory..."
pushd ./HttpTrigger
if [ ! -d ".venv" ]; then
echo "Creating virtual environment..."
python3.11 -m venv .venv
fi
source .venv/bin/activate
echo "Upgrading pip..."
pip3 install --upgrade pip
echo "Installing required Python packages..."
pip3 install azure-functions opencv-python onnxruntime numpy
echo "Setting PYTHONPATH..."
export PYTHONPATH=$(pwd)/.venv/lib/python3.11/site-packages
echo "Navigating to models directory..."
pushd ./models
echo "Downloading model files..."
curl -L https://media.githubusercontent.com/media/onnx/models/refs/heads/main/validated/vision/body_analysis/ultraface/models/version-RFB-640.onnx?download=true -O
curl -L https://media.githubusercontent.com/media/onnx/models/refs/heads/main/validated/vision/body_analysis/age_gender/models/vgg_ilsvrc_16_age_imdb_wiki.onnx?download=true -O
curl -L https://media.githubusercontent.com/media/onnx/models/refs/heads/main/validated/vision/body_analysis/emotion_ferplus/model/emotion-ferplus-8.onnx?download=true -O
echo "Returning to previous directory..."
popd
popd
if command -v code &> /dev/null; then
echo "Opening VSCode..."
code .
fi
'';
};
});
};
}