Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / tvheadend / default.nix
blob499a046663aef6fa80c70fc03f0ce2cc33546290
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchpatch
6 # buildtime
7 , makeWrapper
8 , pkg-config
9 , python3
10 , which
12 # runtime
13 , avahi
14 , bzip2
15 , dbus
16 , dtv-scan-tables
17 , ffmpeg_4
18 , gettext
19 , gnutar
20 , gzip
21 , libiconv
22 , openssl
23 , uriparser
24 , zlib
27 let
28   version = "4.2.8";
29 in stdenv.mkDerivation {
30   pname = "tvheadend";
31   inherit version;
33   src = fetchFromGitHub {
34     owner = "tvheadend";
35     repo = "tvheadend";
36     rev = "v${version}";
37     sha256 = "1xq059r2bplaa0nd0wkhw80jfwd962x0h5hgd7fz2yp6largw34m";
38   };
40   outputs = [
41     "out"
42     "man"
43   ];
45   patches = [
46     # Pull upstream fix for -fno-common toolchain
47     #   https://github.com/tvheadend/tvheadend/pull/1342
48     # TODO: can be removed with 4.3 release.
49     (fetchpatch {
50       name = "fno-common.patch";
51       url = "https://github.com/tvheadend/tvheadend/commit/bd92f1389f1aacdd08e913b0383a0ca9dc223153.patch";
52       sha256 = "17bsx6mnv4pjiayvx1d57dphva0kvlppvnmmaym06dh4524pnly1";
53     })
54   ];
56   nativeBuildInputs = [
57     makeWrapper
58     pkg-config
59     python3
60     which
61   ];
63   buildInputs = [
64     avahi
65     bzip2
66     dbus
67     ffmpeg_4 # depends on libav
68     gettext
69     gzip
70     libiconv
71     openssl
72     uriparser
73     zlib
74   ];
76   enableParallelBuilding = true;
78   env.NIX_CFLAGS_COMPILE = toString ([
79     "-Wno-error=format-truncation"
80     "-Wno-error=stringop-truncation"
81   ] ++ lib.optionals (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "12") [
82     # Needed with GCC 12 but unrecognized with GCC 9
83     "-Wno-error=use-after-free"
84   ]);
86   configureFlags = [
87     # disable dvbscan, as having it enabled causes a network download which
88     # cannot happen during build.  We now include the dtv-scan-tables ourselves
89     "--disable-dvbscan"
90     "--disable-bintray_cache"
91     "--disable-ffmpeg_static"
92     # incompatible with our libhdhomerun version
93     "--disable-hdhomerun_client"
94     "--disable-hdhomerun_static"
95     "--disable-libx264_static"
96     "--disable-libx265_static"
97     "--disable-libvpx_static"
98     "--disable-libtheora_static"
99     "--disable-libvorbis_static"
100     "--disable-libfdkaac_static"
101     "--disable-libmfx_static"
102   ];
104   preConfigure = ''
105     substituteInPlace src/config.c \
106       --replace /usr/bin/tar ${gnutar}/bin/tar
108     substituteInPlace src/input/mpegts/scanfile.c \
109       --replace /usr/share/dvb ${dtv-scan-tables}/share/dvbv5
111     # the version detection script `support/version` reads this file if it
112     # exists, so let's just use that
113     echo ${version} > rpm/version
114   '';
116   postInstall = ''
117     wrapProgram $out/bin/tvheadend \
118       --prefix PATH : ${lib.makeBinPath [ bzip2 ]}
119   '';
121   meta = with lib; {
122     description = "TV streaming server and digital video recorder";
123     longDescription = ''
124       Tvheadend is a TV streaming server for Linux supporting DVB-S,
125       DVB-S2, DVB-C, DVB-T, ATSC, IPTV,SAT>IP and other formats
126       through the unix pipe as input sources.
127     '';
128     homepage = "https://tvheadend.org";
129     license = licenses.gpl3Only;
130     platforms = platforms.unix;
131     maintainers = with maintainers; [ simonvandel ];
132     mainProgram = "tvheadend";
133   };