nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 155 lines 3.9 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 writeTextFile, 6 7 pkg-config, 8 cmake, 9 ninja, 10 cargo, 11 rustc, 12 corrosion, 13 rustPlatform, 14 15 gpac, 16 protobufc, 17 libpng, 18 zlib, 19 utf8proc, 20 freetype, 21 ffmpeg, 22 libarchive, 23 curl, 24 libiconv, 25 26 enableOcr ? true, 27 leptonica, 28 tesseract, 29}: 30 31stdenv.mkDerivation (finalAttrs: { 32 pname = "ccextractor"; 33 version = "0.94-unstable-2025-05-20"; 34 35 src = fetchFromGitHub { 36 owner = "CCExtractor"; 37 repo = "ccextractor"; 38 rev = "407d0f4e93611c5b0ceb14b7fc01d4a4c2e90433"; 39 hash = "sha256-BfsQmCNB4HRafqJ3pC2ECiwhOgwKuIqiLjr2/bvHr7Q="; 40 }; 41 42 patches = [ 43 ./remove-default-commit-hash.patch 44 ./remove-vendored-libraries.patch 45 ./fix-avcodec-close.patch 46 ] 47 ++ finalAttrs.cargoDeps.vendorStaging.patches; 48 49 cmakeDir = "../src"; 50 51 cargoRoot = "src/rust"; 52 53 cargoDeps = rustPlatform.fetchCargoVendor { 54 inherit (finalAttrs) src cargoRoot; 55 patches = [ ./use-rsmpeg-0.15.patch ]; 56 hash = "sha256-68Y8nzPHxhVIRHoPXOy9tc71177lCBuOf//z3cqyDGQ="; 57 }; 58 59 nativeBuildInputs = [ 60 pkg-config 61 cmake 62 ninja 63 cargo 64 rustc 65 corrosion 66 rustPlatform.cargoSetupHook 67 rustPlatform.bindgenHook 68 ]; 69 70 buildInputs = [ 71 gpac 72 protobufc 73 libpng 74 zlib 75 utf8proc 76 freetype 77 ffmpeg 78 libarchive 79 curl 80 libiconv 81 ] 82 ++ lib.optionals enableOcr [ 83 leptonica 84 tesseract 85 ]; 86 87 cmakeFlags = [ 88 # The tests are all part of one `cargo test` invocation, so let’s 89 # get the output from it. 90 (lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--verbose") 91 92 # TODO: This (and the corresponding patch) should probably be 93 # removed for the next stable release. 94 (lib.cmakeFeature "GIT_COMMIT_HASH" finalAttrs.src.rev) 95 ] 96 ++ lib.optionals enableOcr [ 97 (lib.cmakeBool "WITH_OCR" true) 98 (lib.cmakeBool "WITH_HARDSUBX" true) 99 ]; 100 101 env = { 102 FFMPEG_INCLUDE_DIR = "${lib.getDev ffmpeg}/include"; 103 104 # Upstream’s FFmpeg binding crate needs an explicit path to a shared 105 # object to do dynamic linking. The key word is *an* explicit path; 106 # they don’t support passing more than one. This linker script hack 107 # pulls in all the FFmpeg libraries they bind to. 108 # 109 # See: <https://github.com/CCExtractor/rusty_ffmpeg/pull/69> 110 FFMPEG_DLL_PATH = 111 let 112 ffmpegLibNames = [ 113 "avcodec" 114 "avdevice" 115 "avfilter" 116 "avformat" 117 "avutil" 118 "swresample" 119 "swscale" 120 ]; 121 ffmpegLibDir = "${lib.getLib ffmpeg}/lib"; 122 ffmpegLibExt = stdenv.hostPlatform.extensions.library; 123 ffmpegLibPath = ffmpegLibName: "${ffmpegLibDir}/lib${ffmpegLibName}.${ffmpegLibExt}"; 124 ffmpegLinkerScript = writeTextFile { 125 name = "ccextractor-ffmpeg-linker-script"; 126 destination = "/lib/ffmpeg.ld"; 127 text = "INPUT(${lib.concatMapStringsSep " " ffmpegLibPath ffmpegLibNames})"; 128 }; 129 in 130 "${ffmpegLinkerScript}/lib/ffmpeg.ld"; 131 }; 132 133 doCheck = true; 134 135 postPatch = lib.optionalString enableOcr '' 136 substituteInPlace src/lib_ccx/ocr.c \ 137 --replace-fail 'getenv("TESSDATA_PREFIX")' '"${tesseract}/share"' 138 ''; 139 140 meta = { 141 homepage = "https://www.ccextractor.org/"; 142 changelog = "${finalAttrs.src.meta.homepage}/blob/${finalAttrs.src.rev}/docs/CHANGES.TXT"; 143 description = "Tool that produces subtitles from closed caption data in videos"; 144 longDescription = '' 145 A tool that analyzes video files and produces independent subtitle files from 146 closed captions data. CCExtractor is portable, small, and very fast. 147 It works on Linux, Windows, and OSX. 148 ''; 149 platforms = lib.platforms.unix; 150 sourceProvenance = [ lib.sourceTypes.fromSource ]; 151 license = lib.licenses.gpl2Only; 152 maintainers = [ lib.maintainers.emily ]; 153 mainProgram = "ccextractor"; 154 }; 155})