|
1 | 1 | { |
2 | 2 | lib, |
3 | 3 | stdenv, |
4 | | - fetchurl, |
5 | | - runCommand, |
6 | | - shaka-packager, |
| 4 | + fetchFromGitHub, |
| 5 | + testers, |
| 6 | + cmake, |
| 7 | + ninja, |
| 8 | + python3, |
| 9 | + nix-update-script, |
| 10 | + abseil-cpp, |
| 11 | + curl, |
| 12 | + gtest, |
| 13 | + nlohmann_json, |
| 14 | + libpng, |
| 15 | + libxml2, |
| 16 | + libwebm, |
| 17 | + mbedtls, |
| 18 | + mimalloc, |
| 19 | + protobuf, |
| 20 | + zlib, |
7 | 21 | }: |
8 | 22 |
|
9 | | -let |
10 | | - sources = { |
11 | | - "x86_64-linux" = { |
12 | | - filename = "packager-linux-x64"; |
13 | | - hash = "sha256-MoMX6PEtvPmloXJwRpnC2lHlT+tozsV4dmbCqweyyI0="; |
14 | | - }; |
15 | | - aarch64-linux = { |
16 | | - filename = "packager-linux-arm64"; |
17 | | - hash = "sha256-6+7SfnwVRsqFwI7/1F7yqVtkJVIoOFUmhoGU3P6gdQ0="; |
18 | | - }; |
19 | | - x86_64-darwin = { |
20 | | - filename = "packager-osx-x64"; |
21 | | - hash = "sha256-fFBtOp/Zb37LP7TWAEB0yp0xM88cMT9QS59EwW4MrAY="; |
22 | | - }; |
23 | | - }; |
24 | | - |
25 | | - source = |
26 | | - sources."${stdenv.hostPlatform.system}" |
27 | | - or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); |
28 | | -in |
29 | 23 | stdenv.mkDerivation (finalAttrs: { |
30 | 24 | pname = "shaka-packager"; |
31 | | - version = "2.6.1"; |
| 25 | + version = "3.2.0"; |
32 | 26 |
|
33 | | - src = fetchurl { |
34 | | - url = "https://github.com/shaka-project/shaka-packager/releases/download/v${finalAttrs.version}/${source.filename}"; |
35 | | - inherit (source) hash; |
| 27 | + src = fetchFromGitHub { |
| 28 | + owner = "shaka-project"; |
| 29 | + repo = "shaka-packager"; |
| 30 | + rev = "refs/tags/v${finalAttrs.version}"; |
| 31 | + hash = "sha256-L10IMsc4dTMa5zwYq612F4J+uKOmEEChY8k/m09wuNE="; |
36 | 32 | }; |
37 | 33 |
|
38 | | - dontUnpack = true; |
39 | | - sourceRoot = "."; |
| 34 | + patches = [ |
| 35 | + # By default, the git commit hash and tag are used as version |
| 36 | + # and shaka-packager fails to build if these are not available. |
| 37 | + # This patch makes it possible to pass an external value as version. |
| 38 | + # The value itself is declared further below in `cmakeFlags`. |
| 39 | + ./0001-Allow-external-declaration-of-packager-version.patch |
| 40 | + # Dependencies are vendored as git submodules inside shaka-packager. |
| 41 | + # We want to reuse the dependencies from nixpkgs instead to avoid unnecessary |
| 42 | + # build overhead and to ensure they are up to date. |
| 43 | + # This patch disables the vendored dependencies (by excluding `third-party`), |
| 44 | + # finds them inside the build environment and aliases them so they can be accessed |
| 45 | + # without prefixing namespaces. |
| 46 | + # The last step is necessary to keep the patch size to a minimum, otherwise we'd have |
| 47 | + # to add the namespace identifiers everywhere a dependency is used. |
| 48 | + ./0002-Unvendor-dependencies.patch |
| 49 | + # As nixpkgs ships with a newer version of libcurl than the one vendored in shaka-packager, |
| 50 | + # we have to fix one deprecation. |
| 51 | + # See https://curl.se/libcurl/c/CURLOPT_PUT.html for further information. |
| 52 | + ./0003-Fix-curl-deprecations.patch |
| 53 | + ]; |
| 54 | + |
| 55 | + nativeBuildInputs = [ |
| 56 | + cmake |
| 57 | + ninja |
| 58 | + ]; |
40 | 59 |
|
41 | | - installPhase = '' |
42 | | - runHook preInstall |
| 60 | + buildInputs = [ |
| 61 | + python3 |
| 62 | + abseil-cpp |
| 63 | + curl |
| 64 | + gtest |
| 65 | + nlohmann_json |
| 66 | + libpng |
| 67 | + libxml2 |
| 68 | + libwebm |
| 69 | + mbedtls |
| 70 | + mimalloc |
| 71 | + (protobuf.override { |
| 72 | + # must be the same version as for shaka-packager |
| 73 | + inherit abseil-cpp; |
| 74 | + }) |
| 75 | + zlib |
| 76 | + ]; |
43 | 77 |
|
44 | | - install -m755 -D $src $out/bin/packager |
| 78 | + cmakeFlags = [ |
| 79 | + "-DPACKAGER_VERSION=v${finalAttrs.version}-nixpkgs" |
| 80 | + # Targets are selected below in ninjaFlags |
| 81 | + "-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON" |
| 82 | + ]; |
45 | 83 |
|
46 | | - runHook postInstall |
47 | | - ''; |
| 84 | + ninjaFlags = [ |
| 85 | + "mpd_generator" |
| 86 | + "packager" |
| 87 | + "pssh_box_py" |
| 88 | + ]; |
48 | 89 |
|
49 | | - passthru.tests = { |
50 | | - simple = runCommand "${finalAttrs.pname}-test" { } '' |
51 | | - ${shaka-packager}/bin/packager -version | grep ${finalAttrs.version} > $out |
52 | | - ''; |
| 90 | + passthru = { |
| 91 | + updateScript = nix-update-script { }; |
| 92 | + tests.version = testers.testVersion { |
| 93 | + package = finalAttrs.finalPackage; |
| 94 | + version = "v${finalAttrs.version}-nixpkgs-release"; |
| 95 | + }; |
53 | 96 | }; |
54 | 97 |
|
55 | | - meta = { |
| 98 | + meta = with lib; { |
56 | 99 | description = "Media packaging framework for VOD and Live DASH and HLS applications"; |
57 | 100 | homepage = "https://shaka-project.github.io/shaka-packager/html/"; |
58 | | - license = lib.licenses.bsd3; |
| 101 | + changelog = "https://github.com/shaka-project/shaka-packager/releases/tag/v${finalAttrs.version}"; |
| 102 | + license = licenses.bsd3; |
59 | 103 | mainProgram = "packager"; |
60 | | - maintainers = [ ]; |
61 | | - platforms = builtins.attrNames sources; |
62 | | - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; |
| 104 | + maintainers = with maintainers; [ niklaskorz ]; |
| 105 | + platforms = platforms.all; |
63 | 106 | }; |
64 | 107 | }) |
0 commit comments