summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/op/openfec/package.nix
blob: 622b4122227554bc0b94cfcc18fc6b69647697dd (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  stdenv,
  lib,
  fetchzip,
  cmake,
  gitUpdater,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "openfec";
  version = "1.4.2.12";

  src = fetchzip {
    url = "https://github.com/roc-streaming/openfec/archive/refs/tags/v${finalAttrs.version}.tar.gz";
    hash = "sha256-KOP3LqCZHdEgm+XhzBdNxnJipGC4gpvA57T7mIeSyaE=";
  };

  outputs = [
    "out"
    "dev"
  ];

  nativeBuildInputs = [
    cmake
  ];

  cmakeFlags = [
    "-DDEBUG:STRING=OFF"
    (lib.cmakeBool "BUILD_STATIC_LIBS" stdenv.hostPlatform.isStatic)
  ];

  installPhase =
    let
      so = stdenv.hostPlatform.extensions.library;
    in
    ''
      # This is pretty horrible but sadly there is not installation procedure
      # provided.
      mkdir -p $dev/include
      cp -R ../src/* $dev/include
      find $dev/include -type f -a ! -iname '*.h' -delete

      install -D -m755 -t $out/lib ../bin/Release/libopenfec${so}
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      install_name_tool -id $out/lib/libopenfec${so} $out/lib/libopenfec${so}
    ''
    + ''
      ln -s libopenfec${so} $out/lib/libopenfec${so}.1
    '';

  passthru.updateScript = gitUpdater {
    url = "https://github.com/roc-streaming/openfec.git";
    rev-prefix = "v";
  };

  meta = {
    description = "Application-level Forward Erasure Correction codes";
    homepage = "https://github.com/roc-streaming/openfec";
    license = lib.licenses.cecill-c;
    maintainers = with lib.maintainers; [ bgamari ];
    platforms = lib.platforms.unix;
  };
})