summary refs log tree commit diff
path: root/pkgs/servers/sunshine/libcbs.nix
blob: 566c28123ae46e143f54c5a9fe7001f6e2356236 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{ stdenv
, fetchFromGitHub
, cmake
, nasm
}:
stdenv.mkDerivation {
  pname = "libcbs";
  version = "unstable-2022-02-07";

  src = fetchFromGitHub {
    owner = "LizardByte";
    repo = "build-deps";
    # repo is not versioned -- used latest commit combined with sunshine release
    rev = "d6e889188ca10118d769ee1ee3cddf9cf485642b";
    fetchSubmodules = true;
    sha256 = "sha256-6xQDJey5JrZXyZxS/yhUBvFi6UD5MsQ3uVtUFrG09Vc=";
  };

  nativeBuildInputs = [
    cmake
    nasm
  ];

  # modify paths to allow patches to be applied directly by derivation
  prePatch = ''
    substituteInPlace ffmpeg_patches/cbs/* \
      --replace 'a/libavcodec' 'a/ffmpeg_sources/ffmpeg/libavcodec' \
      --replace 'b/libavcodec' 'b/ffmpeg_sources/ffmpeg/libavcodec' \
      --replace 'a/libavutil' 'a/ffmpeg_sources/ffmpeg/libavutil' \
      --replace 'b/libavutil' 'b/ffmpeg_sources/ffmpeg/libavutil'

    substituteInPlace cmake/ffmpeg_cbs.cmake \
      --replace '--enable-static' '--enable-shared --enable-pic' \
      --replace 'add_library(cbs' 'add_library(cbs SHARED' \
      --replace 'libcbs.a' 'libcbs.so'
  '';

  patches = [
    "ffmpeg_patches/cbs/01-explicit-intmath.patch"
    "ffmpeg_patches/cbs/02-include-cbs-config.patch"
    "ffmpeg_patches/cbs/03-remove-register.patch"
    "ffmpeg_patches/cbs/04-size-specifier.patch"
  ];

  CFLAGS = [
    "-Wno-format-security"
  ];
}