# ./overlays/opentrack.nix self: super: { opentrack = super.opentrack.overrideAttrs (oldAttrs: { # 1. Add dependencies for building (onnxruntime) and wrapping (makeWrapper) nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ super.makeWrapper ]; buildInputs = oldAttrs.buildInputs or [] ++ [ self.onnxruntime ]; # 2. Enable the neuralnet tracker feature during compile time cmakeFlags = oldAttrs.cmakeFlags or [] ++ [ "-DSDK_NEURALNET=ON" ]; # 3. After installation, create a wrapper around the main binary postInstall = (oldAttrs.postInstall or "") + '' # Construct the full library path from all runtime dependencies lib_path="${super.lib.makeLibraryPath [ super.qt5.qtbase super.qt5.qtwayland super.opencv self.onnxruntime super.procps super.libevdev ]}" # Construct the full Qt plugin path qt_plugin_path="${super.qt5.qtbase.bin}/lib/qt-${super.qt5.qtbase.version}/plugins:${super.qt5.qtwayland}/lib/qt-${super.qt5.qtwayland.version}/plugins" # Use makeWrapper to prepend the environment variables to the executable # This modifies the binary at $out/bin/opentrack so it ALWAYS runs with this environment wrapProgram $out/bin/opentrack \ --prefix LD_LIBRARY_PATH : "$lib_path" \ --prefix QT_PLUGIN_PATH : "$qt_plugin_path" ''; }); }