lol
1{
2 lib,
3 fetchFromGitHub,
4 gitUpdater,
5 stdenv,
6 testers,
7 nasm,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "davs2";
12 version = "1.7";
13
14 src = fetchFromGitHub {
15 owner = "pkuvcl";
16 repo = "davs2";
17 rev = "refs/tags/${finalAttrs.version}";
18 hash = "sha256-SUY3arrVsFecMcbpmQP0+4rtcSRfQc6pzxZDcEuMWPU=";
19 };
20
21 postPatch = ''
22 substituteInPlace ./version.sh \
23 --replace-fail "date" 'date -ud "@$SOURCE_DATE_EPOCH"'
24 '';
25
26 preConfigure = ''
27 # Generate version.h
28 ./version.sh
29 cd build/linux
30
31 # We need to explicitly set AS to nasm on x86, because the assembly code uses NASM-isms,
32 # and to empty string on all other platforms, because the build system erroneously assumes
33 # that assembly code exists for non-x86 platforms, and will not attempt to build it
34 # if AS is explicitly set to empty.
35 export AS=${if stdenv.hostPlatform.isx86 then "nasm" else ""}
36 '';
37
38 configureFlags = [
39 "--cross-prefix=${stdenv.cc.targetPrefix}"
40 ]
41 ++ lib.optionals (!stdenv.hostPlatform.isStatic) [
42 (lib.enableFeature true "shared")
43 "--system-libdavs2"
44 ];
45
46 nativeBuildInputs = [
47 nasm
48 ];
49
50 outputs = [
51 "out"
52 "lib"
53 "dev"
54 ];
55
56 passthru = {
57 updateScript = gitUpdater { };
58 tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
59 };
60
61 meta = {
62 homepage = "https://github.com/pkuvcl/davs2";
63 description = "Open-source decoder of AVS2-P2/IEEE1857.4 video coding standard";
64 license = lib.licenses.gpl2Plus;
65 mainProgram = "davs2";
66 pkgConfigModules = [ "davs2" ];
67 maintainers = with lib.maintainers; [ jopejoe1 ];
68 platforms = lib.platforms.all;
69 };
70})