Add camera SDK Nix derivation and remove Docker-based SDK installation
This commit is contained in:
111
default.nix
111
default.nix
@@ -30,6 +30,44 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# Camera SDK derivation - extracts and installs the SDK
|
||||||
|
camera-sdk = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "mindvision-camera-sdk";
|
||||||
|
version = "2.1.0.49";
|
||||||
|
|
||||||
|
src = ./usda-vision/camera-management-api/camera_sdk/linuxSDK_V2.1.0.49(250108).tar.gz;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
|
buildInputs = [ pkgs.libusb1 ];
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
tar xzf $src
|
||||||
|
cd "linuxSDK_V2.1.0.49(250108)"
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib $out/include
|
||||||
|
|
||||||
|
# Copy library files
|
||||||
|
if [ -d lib ]; then
|
||||||
|
cp -r lib/* $out/lib/ || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy header files
|
||||||
|
if [ -d include ]; then
|
||||||
|
cp -r include/* $out/include/ || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make libraries executable
|
||||||
|
chmod +x $out/lib/*.so* 2>/dev/null || true
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "MindVision Camera SDK";
|
||||||
|
platforms = pkgs.lib.platforms.linux;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Create a derivation that packages the usda-vision directory
|
# Create a derivation that packages the usda-vision directory
|
||||||
usda-vision-app = pkgs.stdenv.mkDerivation {
|
usda-vision-app = pkgs.stdenv.mkDerivation {
|
||||||
pname = "usda-vision";
|
pname = "usda-vision";
|
||||||
@@ -64,21 +102,58 @@ let
|
|||||||
echo "Source directory contents:"
|
echo "Source directory contents:"
|
||||||
ls -la $src/ || true
|
ls -la $src/ || true
|
||||||
|
|
||||||
# Process docker-compose.yml first and create it in a temp location
|
# Process docker-compose.yml - replace paths, hostnames, and configure SDK from Nix
|
||||||
# Replace .env paths, volume mount paths, and hostnames
|
|
||||||
if [ -f $src/docker-compose.yml ]; then
|
if [ -f $src/docker-compose.yml ]; then
|
||||||
${pkgs.gnused}/bin/sed \
|
# Use Python for multi-line block removal
|
||||||
-e 's|env_file:.*management-dashboard-web-app/\.env|env_file: /var/lib/usda-vision/.env|g' \
|
${pkgs.python3}/bin/python3 <<PYTHON_SCRIPT > $TMPDIR/docker-compose.yml
|
||||||
-e 's|\./management-dashboard-web-app/\.env|/var/lib/usda-vision/.env|g' \
|
import re
|
||||||
-e 's|\./management-dashboard-web-app|/var/lib/usda-vision/management-dashboard-web-app|g' \
|
|
||||||
-e 's|\./media-api|/var/lib/usda-vision/media-api|g' \
|
with open('$src/docker-compose.yml', 'r') as f:
|
||||||
-e 's|\./video-remote|/var/lib/usda-vision/video-remote|g' \
|
content = f.read()
|
||||||
-e 's|\./scheduling-remote|/var/lib/usda-vision/scheduling-remote|g' \
|
|
||||||
-e 's|\./vision-system-remote|/var/lib/usda-vision/vision-system-remote|g' \
|
# Replace paths and hostnames
|
||||||
-e 's|\./camera-management-api|/var/lib/usda-vision/camera-management-api|g' \
|
replacements = [
|
||||||
-e 's|exp-dash|192.168.1.156|g' \
|
(r'env_file:.*management-dashboard-web-app/\\.env', 'env_file: /var/lib/usda-vision/.env'),
|
||||||
-e 's|localhost|192.168.1.156|g' \
|
(r'\\./management-dashboard-web-app/\\.env', '/var/lib/usda-vision/.env'),
|
||||||
$src/docker-compose.yml > $TMPDIR/docker-compose.yml
|
(r'\\./management-dashboard-web-app', '/var/lib/usda-vision/management-dashboard-web-app'),
|
||||||
|
(r'\\./media-api', '/var/lib/usda-vision/media-api'),
|
||||||
|
(r'\\./video-remote', '/var/lib/usda-vision/video-remote'),
|
||||||
|
(r'\\./scheduling-remote', '/var/lib/usda-vision/scheduling-remote'),
|
||||||
|
(r'\\./vision-system-remote', '/var/lib/usda-vision/vision-system-remote'),
|
||||||
|
(r'\\./camera-management-api', '/var/lib/usda-vision/camera-management-api'),
|
||||||
|
('exp-dash', '192.168.1.156'),
|
||||||
|
('localhost', '192.168.1.156'),
|
||||||
|
('LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib', 'LD_LIBRARY_PATH=/lib/camera-sdk:/usr/local/lib:/lib:/usr/lib'),
|
||||||
|
]
|
||||||
|
|
||||||
|
for pattern, replacement in replacements:
|
||||||
|
content = re.sub(pattern, replacement, content)
|
||||||
|
|
||||||
|
# Add SDK volume mount after timezone mount
|
||||||
|
content = re.sub(
|
||||||
|
r'( - /etc/timezone:/etc/timezone:ro)',
|
||||||
|
r'\\1\\n - \${camera-sdk}/lib:/lib/camera-sdk:ro',
|
||||||
|
content
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove SDK installation blocks (first block)
|
||||||
|
content = re.sub(
|
||||||
|
r' # Only install system packages if not already installed.*?else\\n.*?echo.*?System dependencies already installed.*?fi\\n',
|
||||||
|
'',
|
||||||
|
content,
|
||||||
|
flags=re.DOTALL
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove SDK installation blocks (second block)
|
||||||
|
content = re.sub(
|
||||||
|
r' # Install camera SDK if not already installed.*?fi;\\n',
|
||||||
|
'',
|
||||||
|
content,
|
||||||
|
flags=re.DOTALL
|
||||||
|
)
|
||||||
|
|
||||||
|
print(content, end='')
|
||||||
|
PYTHON_SCRIPT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy all application files using rsync with chmod, excluding files we'll provide separately
|
# Copy all application files using rsync with chmod, excluding files we'll provide separately
|
||||||
@@ -155,9 +230,17 @@ in
|
|||||||
# Supabase
|
# Supabase
|
||||||
supabase-cli
|
supabase-cli
|
||||||
|
|
||||||
|
# Camera SDK
|
||||||
|
camera-sdk
|
||||||
|
|
||||||
# USDA Vision application package with convenience scripts
|
# USDA Vision application package with convenience scripts
|
||||||
usda-vision-app
|
usda-vision-app
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Make camera SDK libraries available system-wide
|
||||||
|
environment.variables = {
|
||||||
|
LD_LIBRARY_PATH = "${camera-sdk}/lib";
|
||||||
|
};
|
||||||
|
|
||||||
# Enable Docker service with LXC-compatible settings
|
# Enable Docker service with LXC-compatible settings
|
||||||
virtualisation.docker = {
|
virtualisation.docker = {
|
||||||
|
|||||||
Reference in New Issue
Block a user