3p/nixpkgs: aja

This commit is contained in:
Luke Granger-Brown 2024-12-21 17:04:56 +00:00
parent f85a6c1772
commit d5d40a37e6
9 changed files with 342 additions and 19 deletions

View file

@ -0,0 +1,17 @@
{
"version": 3,
"configurePresets": [
{
"name": "nixpkgs-linux",
"displayName": "Nixpkgs (Linux)",
"inherits": ["ubuntu"],
"binaryDir": "${sourceDir}/build"
},
{
"name": "nixpkgs-darwin",
"displayName": "Nixpkgs (Darwin)",
"inherits": ["macos"],
"binaryDir": "${sourceDir}/build"
}
]
}

View file

@ -2,6 +2,7 @@
, uthash , uthash
, lib , lib
, stdenv , stdenv
, ninja
, nv-codec-headers-12 , nv-codec-headers-12
, fetchFromGitHub , fetchFromGitHub
, fetchpatch , fetchpatch
@ -51,6 +52,8 @@
, asio , asio
, decklinkSupport ? false , decklinkSupport ? false
, blackmagic-desktop-video , blackmagic-desktop-video
, ajaSupport ? false
, libajantv2
, libdatachannel , libdatachannel
, libvpl , libvpl
, qrcodegencpp , qrcodegencpp
@ -107,6 +110,7 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ nativeBuildInputs = [
addDriverRunpath addDriverRunpath
cmake cmake
ninja
pkg-config pkg-config
wrapGAppsHook3 wrapGAppsHook3
wrapQtAppsHook wrapQtAppsHook
@ -148,7 +152,8 @@ stdenv.mkDerivation (finalAttrs: {
++ optional alsaSupport alsa-lib ++ optional alsaSupport alsa-lib
++ optional pulseaudioSupport libpulseaudio ++ optional pulseaudioSupport libpulseaudio
++ optionals pipewireSupport [ pipewire libdrm ] ++ optionals pipewireSupport [ pipewire libdrm ]
++ optional withFdk fdk_aac; ++ optional withFdk fdk_aac
++ optional ajaSupport libajantv2;
# Copied from the obs-linuxbrowser # Copied from the obs-linuxbrowser
postUnpack = '' postUnpack = ''
@ -157,16 +162,22 @@ stdenv.mkDerivation (finalAttrs: {
ln -s $i cef/Release/ ln -s $i cef/Release/
ln -s $i cef/Resources/ ln -s $i cef/Resources/
done done
ln -s ${libcef}/lib/libcef.so cef/Release/ ln -s ${libcef}/lib/*.so* cef/Release/
ln -s ${libcef}/libexec/cef/chrome-sandbox cef/Release/
ln -s ${libcef}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/ ln -s ${libcef}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/
ln -s ${libcef}/include cef/ ln -s ${libcef}/include cef/
''; '';
postPatch = ''
cp ${./CMakeUserPresets.json} ./CMakeUserPresets.json
'';
cmakeFlags = [ cmakeFlags = [
"--preset" "nixpkgs-${if stdenv.hostPlatform.isDarwin then "darwin" else "linux"}"
"-DOBS_VERSION_OVERRIDE=${finalAttrs.version}" "-DOBS_VERSION_OVERRIDE=${finalAttrs.version}"
"-Wno-dev" # kill dev warnings that are useless for packaging "-Wno-dev" # kill dev warnings that are useless for packaging
# Add support for browser source # Add support for browser source
"-DBUILD_BROWSER=ON" "-DENABLE_BROWSER=ON"
"-DCEF_ROOT_DIR=../../cef" "-DCEF_ROOT_DIR=../../cef"
"-DENABLE_JACK=ON" "-DENABLE_JACK=ON"
(lib.cmakeBool "ENABLE_QSV11" stdenv.hostPlatform.isx86_64) (lib.cmakeBool "ENABLE_QSV11" stdenv.hostPlatform.isx86_64)
@ -174,7 +185,7 @@ stdenv.mkDerivation (finalAttrs: {
(lib.cmakeBool "ENABLE_ALSA" alsaSupport) (lib.cmakeBool "ENABLE_ALSA" alsaSupport)
(lib.cmakeBool "ENABLE_PULSEAUDIO" pulseaudioSupport) (lib.cmakeBool "ENABLE_PULSEAUDIO" pulseaudioSupport)
(lib.cmakeBool "ENABLE_PIPEWIRE" pipewireSupport) (lib.cmakeBool "ENABLE_PIPEWIRE" pipewireSupport)
(lib.cmakeBool "ENABLE_AJA" false) # TODO: fix linking against libajantv2 (lib.cmakeBool "ENABLE_AJA" ajaSupport)
]; ];
env.NIX_CFLAGS_COMPILE = toString [ env.NIX_CFLAGS_COMPILE = toString [
@ -193,8 +204,13 @@ stdenv.mkDerivation (finalAttrs: {
blackmagic-desktop-video blackmagic-desktop-video
]; ];
in '' in ''
# Remove libcef before patchelf, otherwise it will fail # Remove cef components before patchelf, otherwise it will fail
rm $out/lib/obs-plugins/libcef.so rm $out/lib/obs-plugins/libcef.so
rm $out/lib/obs-plugins/libEGL.so
rm $out/lib/obs-plugins/libGLESv2.so
rm $out/lib/obs-plugins/libvk_swiftshader.so
rm $out/lib/obs-plugins/libvulkan.so.1
rm $out/lib/obs-plugins/chrome-sandbox
qtWrapperArgs+=( qtWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}" --prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}"
@ -206,8 +222,9 @@ stdenv.mkDerivation (finalAttrs: {
addDriverRunpath $out/lib/lib*.so addDriverRunpath $out/lib/lib*.so
addDriverRunpath $out/lib/obs-plugins/*.so addDriverRunpath $out/lib/obs-plugins/*.so
# Link libcef again after patchelfing other libs # Link cef components again after patchelfing other libs
ln -s ${libcef}/lib/* $out/lib/obs-plugins/ ln -s ${libcef}/lib/* $out/lib/obs-plugins/
ln -s ${libcef}/libexec/cef/* $out/lib/obs-plugins/
''; '';
passthru.updateScript = nix-update-script { }; passthru.updateScript = nix-update-script { };

View file

@ -0,0 +1,126 @@
{
stdenvNoCC,
lib,
fetchzip,
dpkg,
patchelf,
buildFHSEnv,
writeShellScript,
makeBinaryWrapper,
}:
let
pname = "aja-desktop-software";
version = "17.1.3";
meta = {
description = "Graphical utilities for interacting with AJA desktop video cards";
homepage = "https://www.aja.com/products/aja-control-room";
license = lib.licenses.unfree; # https://www.aja.com/software-license-agreement
maintainers = [ lib.maintainers.lukegb ];
platforms = [ "x86_64-linux" ];
sourceProvenance = [
lib.sourceTypes.binaryNativeCode
lib.sourceTypes.binaryFirmware
];
};
unwrapped = stdenvNoCC.mkDerivation {
pname = "${pname}-unwrapped";
inherit version;
src = fetchzip {
url = "https://www.aja.com/assets/support/files/9895/en/AJA-Desktop-Software-Installer_Linux-Ubuntu_v${version}_Release.zip";
hash = "sha256-TxDcYIhEcpPnpoqpey5vSvUltLT/3xwBfOhAP81Q9+E=";
};
unpackCmd = "dpkg -x $curSrc/ajaretail_*.deb source";
nativeBuildInputs = [
dpkg
patchelf
];
installPhase = ''
runHook preInstall
mkdir -p $out/share
mv usr/share/applications $out/share/applications
mv usr/share/doc $out/share/doc
mv etc $out/etc
mv opt $out/opt
ln -s $out/opt/aja/bin $out/bin
# For some reason ajanmos doesn't have /opt/aja/lib in its rpath...
patchelf $out/opt/aja/bin/ajanmos --add-rpath $out/opt/aja/lib
runHook postInstall
'';
dontPatchELF = true;
inherit meta;
};
in
buildFHSEnv {
inherit pname version;
targetPkgs =
pkgs:
[ unwrapped ]
++ (with pkgs; [
ocl-icd
libGL
udev
libpulseaudio
zstd
glib
fontconfig
freetype
xorg.libxcb
xorg.libX11
xorg.xcbutilwm
xorg.xcbutilimage
xorg.xcbutilkeysyms
xorg.xcbutilrenderutil
xorg.libSM
xorg.libICE
libxkbcommon
dbus
avahi
]);
nativeBuildInputs = [
makeBinaryWrapper
];
unshareIpc = false;
unsharePid = false;
runScript = writeShellScript "aja" ''
exec_binary="$1"
shift
export QT_PLUGIN_PATH="${unwrapped}/opt/aja/plugins"
exec "${unwrapped}/opt/aja/bin/$exec_binary" "$@"
'';
extraInstallCommands = ''
mkdir -p $out/libexec/aja-desktop
mv $out/bin/${pname} $out/libexec/aja-desktop/${pname}
for binary in controlpanel controlroom ajanmos systemtest; do
makeWrapper "$out/libexec/aja-desktop/${pname}" "$out/bin/aja-$binary" \
--add-flags "$binary"
done
'';
passthru = {
inherit unwrapped;
};
meta = meta // {
mainProgram = "aja-controlpanel";
};
}

View file

@ -0,0 +1,13 @@
diff --git a/ajantv2/src/ntv2devicescanner.cpp b/ajantv2/src/ntv2devicescanner.cpp
index 448e48d372..6b46f9f69d 100644
--- a/ajantv2/src/ntv2devicescanner.cpp
+++ b/ajantv2/src/ntv2devicescanner.cpp
@@ -137,7 +137,7 @@
}
#endif // !defined(NTV2_DEPRECATE_16_3)
-NTV2DeviceInfoList GetDeviceInfoList (void)
+NTV2DeviceInfoList CNTV2DeviceScanner::GetDeviceInfoList (void)
{
AJAAutoLock tmpLock(&sDevInfoListLock);
return sDevInfoList;

View file

@ -5,21 +5,25 @@
cmake, cmake,
ninja, ninja,
pkg-config, pkg-config,
mbedtls,
udev,
linuxPackages,
}: }:
# Warning: We are aware that the upstream changed and there are new releases,
# this got initally packaged for obs-studio which appears to fail to build even upstream with the new version.
# https://github.com/NixOS/nixpkgs/pull/296191 / https://github.com/obsproject/obs-studio/pull/10037
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "libajantv2"; pname = "libajantv2";
version = "16.2-bugfix5"; version = "17.1.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "aja-video"; owner = "aja-video";
repo = "ntv2"; repo = "libajantv2";
rev = "v${version}"; rev = "ntv2_${builtins.replaceStrings [ "." ] [ "_" ] version}";
sha256 = "sha256-h5PKWMwqTeI5/EaTWkjYojuvDU0FyMpzIjWB98UOJwc="; hash = "sha256-n9j98r1E9E0hv5gA8jCg/eQyqGuyU9JlZYm/zlcTQOo=";
}; };
patches = [
./use-system-mbedtls.patch
./device-info-list.patch
];
outputs = [ outputs = [
"out" "out"
@ -31,27 +35,39 @@ stdenv.mkDerivation rec {
ninja ninja
pkg-config pkg-config
]; ];
buildInputs = [
mbedtls
udev
];
cmakeFlags = [
(lib.cmakeBool "AJANTV2_BUILD_SHARED" true)
];
postInstall = '' postInstall = ''
mkdir -p "$out/lib/pkgconfig" mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/libajantv2.pc" <<EOF cat >"$out/lib/pkgconfig/libajantv2.pc" <<EOF
prefix=$out prefix=$out
libdir=\''${prefix}/lib libdir=\''${prefix}/lib
includedir=\''${prefix}/include/ajalibraries includedir=\''${prefix}/include/libajantv2
Name: libajantv2 Name: libajantv2
Description: Library for controlling AJA NTV2 video devices Description: Library for controlling AJA NTV2 video devices
Version: ${version} Version: ${version}
Libs: -L\''${libdir} -lajantv2 Libs: -L\''${libdir} -lajantv2
Cflags: -I\''${includedir} -I\''${includedir}/ajantv2/includes Cflags: -I\''${includedir} -I\''${includedir}/ajantv2/includes -I\''${includedir}/ajantv2/src/lin
EOF EOF
''; '';
passthru.tests = {
inherit (linuxPackages) ajantv2;
};
meta = with lib; { meta = with lib; {
description = "AJA NTV2 Open Source Static Libs and Headers for building applications that only wish to statically link against"; description = "AJA NTV2 Open Source Static Libs and Headers for building applications that only wish to statically link against";
homepage = "https://github.com/aja-video/ntv2"; homepage = "https://github.com/aja-video/libajantv2";
license = with licenses; [ mit ]; license = with licenses; [ mit ];
maintainers = [ ]; maintainers = [ lib.maintainers.lukegb ];
platforms = platforms.linux; platforms = platforms.linux;
}; };
} }

View file

@ -0,0 +1,86 @@
Commit ID: 1aeee534119a22e717ce3d0e9f62c8791cd825b9
Change ID: pzyrusopmyvtvnwnruvrltqtpqtzxrpo
Author: Luke Granger-Brown <git@lukegb.com> (2024-12-20 18:03:16)
Committer: Luke Granger-Brown <git@lukegb.com> (2024-12-20 18:03:25)
Use system mbedtls, rather than downloading from a random Git branch...
diff --git a/ajantv2/CMakeLists.txt b/ajantv2/CMakeLists.txt
index ffa572e9c8..74c23e8e4e 100644
--- a/ajantv2/CMakeLists.txt
+++ b/ajantv2/CMakeLists.txt
@@ -52,49 +52,13 @@
else()
message(STATUS "NTV2 SDK will load signed 3rd-party plugins")
- set(MBEDTLS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/mbedtls-install)
- set(MBEDTLS_INCLUDE_DIR ${MBEDTLS_INSTALL_DIR}/include)
- set(MBEDTLS_LIBRARY_DIR ${MBEDTLS_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
-
- if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- set(MBEDTLS_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedtls.lib)
- set(MBEDX509_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedx509.lib)
- set(MBEDCRYPTO_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedcrypto.lib)
- set(MBEDTLS_EXTRA_CONFIG_FLAGS
- "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
- "-DMSVC_STATIC_RUNTIME=ON"
- "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
- elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin)$")
- set(MBEDTLS_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedtls.a)
- set(MBEDX509_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedx509.a)
- set(MBEDCRYPTO_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedcrypto.a)
- set(MBEDTLS_C_FLAGS -fPIC)
- endif()
-
- # BUILD_BYPRODUCTS informing CMake where the .a files are located is required to make Ninja build work
- ExternalProject_Add(
- mbedtls
- GIT_REPOSITORY https://github.com/aja-video/mbedtls.git
- GIT_TAG fix-win-dll-cmake
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MBEDTLS_INSTALL_DIR}
- -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- -DENABLE_TESTING=OFF
- -DENABLE_PROGRAMS=OFF
- -DCMAKE_C_FLAGS=${MBEDTLS_C_FLAGS}
- -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
- -DUSE_STATIC_MBEDTLS_LIBRARY=ON
- -DUSE_SHARED_MBEDTLS_LIBRARY=OFF
- ${MBEDTLS_EXTRA_CONFIG_FLAGS}
- BUILD_ALWAYS TRUE
- BUILD_BYPRODUCTS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY}
- )
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(MBEDTLS REQUIRED mbedtls mbedcrypto mbedx509)
list(APPEND TARGET_INCLUDE_DIRS
${MBEDTLS_INCLUDE_DIR})
list(APPEND MBEDTLS_LINK_LIBS
- ${MBEDTLS_LIBRARY}
- ${MBEDCRYPTO_LIBRARY}
- ${MBEDX509_LIBRARY})
+ ${MBEDTLS_LIBRARIES})
endif()
@@ -668,10 +632,6 @@
aja_ntv2_log_build_info()
add_library(${PROJECT_NAME} SHARED ${TARGET_SOURCES})
-
- if (NOT AJANTV2_DISABLE_PLUGIN_LOAD)
- add_dependencies(${PROJECT_NAME} mbedtls)
- endif()
target_compile_definitions(${PROJECT_NAME} PUBLIC
${TARGET_COMPILE_DEFS_DYNAMIC}
@@ -687,10 +647,6 @@
add_library(${PROJECT_NAME} STATIC ${TARGET_SOURCES})
- if (NOT AJANTV2_DISABLE_PLUGIN_LOAD)
- add_dependencies(${PROJECT_NAME} mbedtls)
- endif()
-
target_compile_definitions(${PROJECT_NAME} PUBLIC
${TARGET_COMPILE_DEFS_STATIC}
${AJANTV2_TARGET_COMPILE_DEFS})

View file

@ -93,15 +93,20 @@ stdenv.mkDerivation rec {
dontPatchELF = true; dontPatchELF = true;
installPhase = '' installPhase = ''
mkdir -p $out/lib/ $out/share/cef/ mkdir -p $out/lib/ $out/share/cef/ $out/libexec/cef/
cp libcef_dll_wrapper/libcef_dll_wrapper.a $out/lib/ cp libcef_dll_wrapper/libcef_dll_wrapper.a $out/lib/
cp ../Release/libcef.so $out/lib/ cp ../Release/libcef.so $out/lib/
cp ../Release/libEGL.so $out/lib/ cp ../Release/libEGL.so $out/lib/
cp ../Release/libGLESv2.so $out/lib/ cp ../Release/libGLESv2.so $out/lib/
cp ../Release/libvk_swiftshader.so $out/lib/
cp ../Release/libvulkan.so.1 $out/lib/
cp ../Release/chrome-sandbox $out/libexec/cef/
patchelf --set-rpath "${rpath}" $out/lib/libcef.so patchelf --set-rpath "${rpath}" $out/lib/libcef.so
patchelf --set-rpath "${gl_rpath}" $out/lib/libEGL.so patchelf --set-rpath "${gl_rpath}" $out/lib/libEGL.so
patchelf --set-rpath "${gl_rpath}" $out/lib/libGLESv2.so patchelf --set-rpath "${gl_rpath}" $out/lib/libGLESv2.so
cp ../Release/*.bin $out/share/cef/ patchelf --set-rpath "${gl_rpath}" $out/lib/libvk_swiftshader.so
patchelf --set-rpath "${gl_rpath}" $out/lib/libvulkan.so.1
cp ../Release/*.bin ../Release/*.json $out/share/cef/
cp -r ../Resources/* $out/share/cef/ cp -r ../Resources/* $out/share/cef/
cp -r ../include $out/ cp -r ../include $out/
''; '';

View file

@ -0,0 +1,41 @@
{
lib,
stdenv,
fetchFromGitHub,
kernel,
libajantv2,
}:
stdenv.mkDerivation {
name = "ajantv2-module-${libajantv2.version}-${kernel.version}";
inherit (libajantv2) src;
sourceRoot = "source/driver/linux";
hardeningDisable = [ "pic" ];
nativeBuildInputs = kernel.moduleBuildDependencies;
preBuild = ''
chmod -R +w ../../
'';
enableParallelBuilding = true;
buildFlags = [
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
];
installPhase = ''
install -D ajantv2.ko $out/lib/modules/${kernel.modDirVersion}/misc/ajantv2.ko
install -D ajardma.ko $out/lib/modules/${kernel.modDirVersion}/misc/ajardma.ko
'';
meta = {
inherit (libajantv2.meta) license homepage maintainers;
platforms = [
"x86_64-linux"
"aarch64-linux"
];
description = "AJA video driver";
};
}

View file

@ -321,6 +321,8 @@ in {
acpi_call = callPackage ../os-specific/linux/acpi-call {}; acpi_call = callPackage ../os-specific/linux/acpi-call {};
ajantv2 = callPackage ../os-specific/linux/ajantv2 { };
akvcam = callPackage ../os-specific/linux/akvcam { }; akvcam = callPackage ../os-specific/linux/akvcam { };
amneziawg = callPackage ../os-specific/linux/amneziawg { }; amneziawg = callPackage ../os-specific/linux/amneziawg { };