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