nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 gitUpdater,
5 stdenv,
6 testers,
7 nasm,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "xavs2";
12 version = "1.4";
13
14 src = fetchFromGitHub {
15 owner = "pkuvcl";
16 repo = "xavs2";
17 tag = finalAttrs.version;
18 hash = "sha256-4w/WTXvRQbohKL+YALQCCYglHQKVvehlUYfitX/lLPw=";
19 };
20
21 env.NIX_CFLAGS_COMPILE = toString (
22 [
23 "-Wno-incompatible-pointer-types"
24 ]
25 ++ lib.optionals (stdenv.cc.isClang || stdenv.cc.isZig) [
26 "-Wno-incompatible-function-pointer-types"
27 ]
28 );
29
30 postPatch = ''
31 substituteInPlace ./version.sh \
32 --replace-fail "date" 'date -ud "@$SOURCE_DATE_EPOCH"'
33 '';
34
35 preConfigure = ''
36 # Generate version.h
37 ./version.sh
38 cd build/linux
39
40 # We need to explicitly set AS to nasm on x86, because the assembly code uses NASM-isms,
41 # and to empty string on all other platforms, because the build system erroneously assumes
42 # that assembly code exists for non-x86 platforms, and will not attempt to build it
43 # if AS is explicitly set to empty.
44 export AS=${if stdenv.hostPlatform.isx86 then "nasm" else ""}
45 '';
46
47 configureFlags = [
48 "--cross-prefix=${stdenv.cc.targetPrefix}"
49 ]
50 ++ lib.optionals (!stdenv.hostPlatform.isStatic) [
51 (lib.enableFeature true "shared")
52 "--system-libxavs2"
53 ];
54
55 postInstall = lib.optionalString (!stdenv.hostPlatform.isStatic) ''
56 rm $lib/lib/*.a
57 '';
58
59 nativeBuildInputs = [
60 nasm
61 ];
62
63 outputs = [
64 "out"
65 "lib"
66 "dev"
67 ];
68
69 passthru = {
70 updateScript = gitUpdater { };
71 tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
72 };
73
74 meta = {
75 homepage = "https://github.com/pkuvcl/xavs2";
76 description = "Open-source encoder of AVS2-P2/IEEE1857.4 video coding standard";
77 license = lib.licenses.gpl2Plus;
78 mainProgram = "xavs2";
79 pkgConfigModules = [ "xavs2" ];
80 maintainers = with lib.maintainers; [ jopejoe1 ];
81 platforms = lib.platforms.all;
82 };
83})