diff --git a/pkgs/applications/video/shaka-packager/default.nix b/pkgs/applications/video/shaka-packager/default.nix deleted file mode 100644 index 039648963f75..000000000000 --- a/pkgs/applications/video/shaka-packager/default.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ lib -, stdenv -, fetchurl -, runCommand -, shaka-packager -}: - -let - sources = { - "x86_64-linux" = { - filename = "packager-linux-x64"; - hash = "sha256-MoMX6PEtvPmloXJwRpnC2lHlT+tozsV4dmbCqweyyI0="; - }; - aarch64-linux = { - filename = "packager-linux-arm64"; - hash = "sha256-6+7SfnwVRsqFwI7/1F7yqVtkJVIoOFUmhoGU3P6gdQ0="; - }; - x86_64-darwin = { - filename = "packager-osx-x64"; - hash = "sha256-fFBtOp/Zb37LP7TWAEB0yp0xM88cMT9QS59EwW4MrAY="; - }; - }; - - source = sources."${stdenv.hostPlatform.system}" - or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); -in -stdenv.mkDerivation (finalAttrs: { - pname = "shaka-packager"; - version = "2.6.1"; - - src = fetchurl { - url = "https://github.com/shaka-project/shaka-packager/releases/download/v${finalAttrs.version}/${source.filename}"; - inherit (source) hash; - }; - - dontUnpack = true; - sourceRoot = "."; - - installPhase = '' - runHook preInstall - - install -m755 -D $src $out/bin/packager - - runHook postInstall - ''; - - passthru.tests = { - simple = runCommand "${finalAttrs.pname}-test" { } '' - ${shaka-packager}/bin/packager -version | grep ${finalAttrs.version} > $out - ''; - }; - - meta = { - description = "Media packaging framework for VOD and Live DASH and HLS applications"; - homepage = "https://shaka-project.github.io/shaka-packager/html/"; - license = lib.licenses.bsd3; - mainProgram = "packager"; - maintainers = [ ]; - platforms = builtins.attrNames sources; - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - }; -}) diff --git a/pkgs/by-name/li/libwebm/0001-cmake-exports.patch b/pkgs/by-name/li/libwebm/0001-cmake-exports.patch new file mode 100644 index 000000000000..e4c8358abe12 --- /dev/null +++ b/pkgs/by-name/li/libwebm/0001-cmake-exports.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b0089ee..eb1b1c6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -459,13 +459,20 @@ endif() + # webm_parser headers are rooted at webm/. + set_target_properties(webm PROPERTIES PUBLIC_HEADER + "${webm_parser_public_headers}") ++target_include_directories(webm INTERFACE $) + install( + TARGETS webm ++ EXPORT webmConfig + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm) + ++install(EXPORT webmConfig ++ FILE webmConfig.cmake ++ NAMESPACE webm:: ++ DESTINATION lib/cmake/webm) ++ + # Install common headers into a subdirectory to avoid breaking nested includes. + install(FILES ${libwebm_common_public_headers} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm/common) diff --git a/pkgs/by-name/li/libwebm/package.nix b/pkgs/by-name/li/libwebm/package.nix new file mode 100644 index 000000000000..cfa2e5201ef2 --- /dev/null +++ b/pkgs/by-name/li/libwebm/package.nix @@ -0,0 +1,49 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + nix-update-script, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "libwebm"; + version = "1.0.0.31"; + + src = fetchFromGitHub { + owner = "webmproject"; + repo = "libwebm"; + rev = "refs/tags/libwebm-${finalAttrs.version}"; + hash = "sha256-+ayX33rcX/jkewsW8WrGalTe9X44qFBHOrIYTteOQzc="; + }; + + patches = [ + # libwebm does not generate cmake exports by default, + # which are necessary to find and use it as build-dependency + # in other packages + ./0001-cmake-exports.patch + ]; + + nativeBuildInputs = [ + cmake + ]; + + outputs = [ + "dev" + "out" + ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "WebM file parser"; + homepage = "https://www.webmproject.org/code/"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ niklaskorz ]; + platforms = lib.platforms.all; + }; +}) diff --git a/pkgs/by-name/sh/shaka-packager/0001-Allow-external-declaration-of-packager-version.patch b/pkgs/by-name/sh/shaka-packager/0001-Allow-external-declaration-of-packager-version.patch new file mode 100644 index 000000000000..ef06193a68d7 --- /dev/null +++ b/pkgs/by-name/sh/shaka-packager/0001-Allow-external-declaration-of-packager-version.patch @@ -0,0 +1,32 @@ +From e243cc17f48c5e1b8db29cab85ca98b033d972fb Mon Sep 17 00:00:00 2001 +From: Niklas Korz +Date: Wed, 4 Sep 2024 14:51:30 +0200 +Subject: [PATCH 1/3] Allow external declaration of packager version + +--- + packager/version/CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/packager/version/CMakeLists.txt b/packager/version/CMakeLists.txt +index fba4fb8282..ad56e0a23b 100644 +--- a/packager/version/CMakeLists.txt ++++ b/packager/version/CMakeLists.txt +@@ -4,6 +4,7 @@ + # license that can be found in the LICENSE file or at + # https://developers.google.com/open-source/licenses/bsd + ++if(NOT DEFINED PACKAGER_VERSION) + execute_process( + COMMAND "${Python3_EXECUTABLE}" generate_version_string.py + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" +@@ -14,6 +15,7 @@ execute_process( + if(NOT STATUS EQUAL 0) + message(FATAL_ERROR "Failed to generate Packager version") + endif() ++endif() + + add_library(version STATIC version.cc) + target_compile_definitions(version PRIVATE +-- +2.46.0 + diff --git a/pkgs/by-name/sh/shaka-packager/0002-Unvendor-dependencies.patch b/pkgs/by-name/sh/shaka-packager/0002-Unvendor-dependencies.patch new file mode 100644 index 000000000000..5054862b656c --- /dev/null +++ b/pkgs/by-name/sh/shaka-packager/0002-Unvendor-dependencies.patch @@ -0,0 +1,67 @@ +From 4c7743f4fd231648d7bd1513c9db71a651ef7553 Mon Sep 17 00:00:00 2001 +From: Niklas Korz +Date: Wed, 4 Sep 2024 14:52:23 +0200 +Subject: [PATCH 2/3] Unvendor dependencies + +--- + CMakeLists.txt | 24 ++++++++++++++++++++++++ + packager/CMakeLists.txt | 1 - + 2 files changed, 24 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5b96a2429e..181df0bf2d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -9,6 +9,8 @@ + # Minimum CMake version. This must be in the root level CMakeLists.txt. + cmake_minimum_required(VERSION 3.24) + ++set(CMAKE_CXX_STANDARD 17) ++ + # These policy settings should be included before the project definition. + include("packager/policies.cmake") + +@@ -28,6 +30,28 @@ enable_testing() + + option(SKIP_INTEGRATION_TESTS "Skip the packager integration tests" OFF) + ++find_package(absl REQUIRED) ++find_package(MbedTLS REQUIRED) ++find_package(GTest REQUIRED) ++find_package(CURL REQUIRED) ++find_package(LibXml2 REQUIRED) ++find_package(PNG REQUIRED) ++find_package(nlohmann_json REQUIRED) ++find_package(Protobuf CONFIG REQUIRED) ++find_package(webm REQUIRED) ++ ++# Alias to same names as vendored dependencies ++add_library(mbedtls ALIAS MbedTLS::mbedtls) ++add_library(gmock ALIAS GTest::gmock) ++add_library(gtest ALIAS GTest::gtest) ++add_library(gtest_main ALIAS GTest::gtest_main) ++add_library(libcurl ALIAS CURL::libcurl) ++add_library(LibXml2 ALIAS LibXml2::LibXml2) ++add_library(png_static ALIAS PNG::PNG) # not static but the expected library name ++add_library(libprotobuf ALIAS protobuf::libprotobuf) ++add_executable(protoc ALIAS protobuf::protoc) ++add_library(webm ALIAS webm::webm) ++ + # Subdirectories with their own CMakeLists.txt + add_subdirectory(packager) + add_subdirectory(link-test) +diff --git a/packager/CMakeLists.txt b/packager/CMakeLists.txt +index 7238d243bb..722217bbc4 100644 +--- a/packager/CMakeLists.txt ++++ b/packager/CMakeLists.txt +@@ -78,7 +78,6 @@ add_subdirectory(media) + add_subdirectory(hls) + add_subdirectory(mpd) + add_subdirectory(status) +-add_subdirectory(third_party) + add_subdirectory(tools) + add_subdirectory(utils) + add_subdirectory(version) +-- +2.46.0 + diff --git a/pkgs/by-name/sh/shaka-packager/0003-Fix-curl-deprecations.patch b/pkgs/by-name/sh/shaka-packager/0003-Fix-curl-deprecations.patch new file mode 100644 index 000000000000..59bffb9925ef --- /dev/null +++ b/pkgs/by-name/sh/shaka-packager/0003-Fix-curl-deprecations.patch @@ -0,0 +1,25 @@ +From c8b0b467a140d8a67157f5cee26a8510444706be Mon Sep 17 00:00:00 2001 +From: Niklas Korz +Date: Wed, 4 Sep 2024 14:52:47 +0200 +Subject: [PATCH 3/3] Fix curl deprecations + +--- + packager/file/http_file.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/packager/file/http_file.cc b/packager/file/http_file.cc +index b50fef6f07..dca43e26ca 100644 +--- a/packager/file/http_file.cc ++++ b/packager/file/http_file.cc +@@ -311,7 +311,7 @@ void HttpFile::SetupRequest() { + curl_easy_setopt(curl, CURLOPT_POST, 1L); + break; + case HttpMethod::kPut: +- curl_easy_setopt(curl, CURLOPT_PUT, 1L); ++ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + break; + } + +-- +2.46.0 + diff --git a/pkgs/by-name/sh/shaka-packager/package.nix b/pkgs/by-name/sh/shaka-packager/package.nix new file mode 100644 index 000000000000..6c1cd25bd2e1 --- /dev/null +++ b/pkgs/by-name/sh/shaka-packager/package.nix @@ -0,0 +1,107 @@ +{ + lib, + stdenv, + fetchFromGitHub, + testers, + cmake, + ninja, + python3, + nix-update-script, + abseil-cpp, + curl, + gtest, + nlohmann_json, + libpng, + libxml2, + libwebm, + mbedtls, + mimalloc, + protobuf, + zlib, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "shaka-packager"; + version = "3.2.0"; + + src = fetchFromGitHub { + owner = "shaka-project"; + repo = "shaka-packager"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-L10IMsc4dTMa5zwYq612F4J+uKOmEEChY8k/m09wuNE="; + }; + + patches = [ + # By default, the git commit hash and tag are used as version + # and shaka-packager fails to build if these are not available. + # This patch makes it possible to pass an external value as version. + # The value itself is declared further below in `cmakeFlags`. + ./0001-Allow-external-declaration-of-packager-version.patch + # Dependencies are vendored as git submodules inside shaka-packager. + # We want to reuse the dependencies from nixpkgs instead to avoid unnecessary + # build overhead and to ensure they are up to date. + # This patch disables the vendored dependencies (by excluding `third-party`), + # finds them inside the build environment and aliases them so they can be accessed + # without prefixing namespaces. + # The last step is necessary to keep the patch size to a minimum, otherwise we'd have + # to add the namespace identifiers everywhere a dependency is used. + ./0002-Unvendor-dependencies.patch + # As nixpkgs ships with a newer version of libcurl than the one vendored in shaka-packager, + # we have to fix one deprecation. + # See https://curl.se/libcurl/c/CURLOPT_PUT.html for further information. + ./0003-Fix-curl-deprecations.patch + ]; + + nativeBuildInputs = [ + cmake + ninja + ]; + + buildInputs = [ + python3 + abseil-cpp + curl + gtest + nlohmann_json + libpng + libxml2 + libwebm + mbedtls + mimalloc + (protobuf.override { + # must be the same version as for shaka-packager + inherit abseil-cpp; + }) + zlib + ]; + + cmakeFlags = [ + "-DPACKAGER_VERSION=v${finalAttrs.version}-nixpkgs" + # Targets are selected below in ninjaFlags + "-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON" + ]; + + ninjaFlags = [ + "mpd_generator" + "packager" + "pssh_box_py" + ]; + + passthru = { + updateScript = nix-update-script { }; + tests.version = testers.testVersion { + package = finalAttrs.finalPackage; + version = "v${finalAttrs.version}-nixpkgs-release"; + }; + }; + + meta = with lib; { + description = "Media packaging framework for VOD and Live DASH and HLS applications"; + homepage = "https://shaka-project.github.io/shaka-packager/html/"; + changelog = "https://github.com/shaka-project/shaka-packager/releases/tag/v${finalAttrs.version}"; + license = licenses.bsd3; + mainProgram = "packager"; + maintainers = with maintainers; [ niklaskorz ]; + platforms = platforms.all; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 83304041dc66..83db1322715b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -31337,7 +31337,9 @@ with pkgs; mpvScripts = mpv-unwrapped.scripts; - shaka-packager = callPackage ../applications/video/shaka-packager { }; + shaka-packager = callPackage ../by-name/sh/shaka-packager/package.nix { + abseil-cpp = abseil-cpp_202401; + }; mpvpaper = callPackage ../tools/wayland/mpvpaper { };