fork
Configure Feed
Select the types of activity you want to include in your feed.
lol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{
2 stdenv,
3 lib,
4 fetchurl,
5 fetchsvn,
6 fetchFromGitHub,
7 jansson,
8 libedit,
9 libxml2,
10 libxslt,
11 ncurses,
12 openssl,
13 sqlite,
14 util-linux,
15 dmidecode,
16 libuuid,
17 newt,
18 lua,
19 speex,
20 libopus,
21 opusfile,
22 libogg,
23 srtp,
24 wget,
25 curl,
26 iksemel,
27 pkg-config,
28 autoconf,
29 libtool,
30 automake,
31 python3,
32 writeScript,
33 withOpus ? true,
34 ldapSupport ? false,
35 openldap,
36}:
37
38let
39 common =
40 {
41 version,
42 sha256,
43 externals,
44 pjsip_patches ? [ ],
45 }:
46 stdenv.mkDerivation {
47 inherit version;
48 pname = "asterisk" + lib.optionalString ldapSupport "-ldap";
49
50 buildInputs = [
51 jansson
52 libedit
53 libxml2
54 libxslt
55 ncurses
56 openssl
57 sqlite
58 dmidecode
59 libuuid
60 newt
61 lua
62 speex
63 srtp
64 wget
65 curl
66 iksemel
67 ]
68 ++ lib.optionals withOpus [
69 libopus
70 opusfile
71 libogg
72 ]
73 ++ lib.optionals ldapSupport [ openldap ];
74 nativeBuildInputs = [
75 util-linux
76 pkg-config
77 autoconf
78 libtool
79 automake
80 ];
81
82 patches = [
83 # We want the Makefile to install the default /var skeleton
84 # under ${out}/var but we also want to use /var at runtime.
85 # This patch changes the runtime behavior to look for state
86 # directories in /var rather than ${out}/var.
87 ./runtime-vardirs.patch
88 ]
89 ++ lib.optional withOpus "${asterisk-opus}/asterisk.patch";
90
91 postPatch = ''
92 echo "PJPROJECT_CONFIG_OPTS += --prefix=$out" >> third-party/pjproject/Makefile.rules
93 '';
94
95 src = fetchurl {
96 url = "https://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
97 inherit sha256;
98 };
99
100 # The default libdir is $PREFIX/usr/lib, which causes problems when paths
101 # compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
102
103 # Copy in externals to avoid them being downloaded;
104 # they have to be copied, because the modification date is checked.
105 # If you are getting a permission denied error on this dir,
106 # you're likely missing an automatically downloaded dependency
107 preConfigure = ''
108 mkdir externals_cache
109
110 ${lib.concatStringsSep "\n" (
111 lib.mapAttrsToList (dst: src: "cp -r --no-preserve=mode ${src} ${dst}") externals
112 )}
113
114 ${lib.optionalString (externals ? "addons/mp3") "bash contrib/scripts/get_mp3_source.sh || true"}
115
116 chmod -w externals_cache
117 ${lib.optionalString withOpus ''
118 cp ${asterisk-opus}/include/asterisk/* ./include/asterisk
119 cp ${asterisk-opus}/codecs/* ./codecs
120 cp ${asterisk-opus}/formats/* ./formats
121 ''}
122 ${lib.concatMapStringsSep "\n" (patch: ''
123 cp ${patch} ./third-party/pjproject/patches/${patch.name}
124 '') pjsip_patches}
125 ./bootstrap.sh
126 '';
127
128 configureFlags = [
129 "--libdir=\${out}/lib"
130 "--with-lua=${lua}/lib"
131 "--with-pjproject-bundled"
132 "--with-externals-cache=$(PWD)/externals_cache"
133 ];
134
135 preBuild = ''
136 cat third-party/pjproject/source/pjlib-util/src/pjlib-util/scanner.c
137 make menuselect.makeopts
138 ${lib.optionalString (externals ? "addons/mp3") ''
139 substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
140 ''}
141 ${lib.optionalString withOpus ''
142 substituteInPlace menuselect.makeopts --replace 'codec_opus_open_source ' ""
143 substituteInPlace menuselect.makeopts --replace 'format_ogg_opus_open_source ' ""
144 ''}
145 '';
146
147 postInstall = ''
148 # Install sample configuration files for this version of Asterisk
149 make samples
150 make install-headers
151 '';
152
153 meta = with lib; {
154 description = "Software implementation of a telephone private branch exchange (PBX)";
155 homepage = "https://www.asterisk.org/";
156 license = licenses.gpl2Only;
157 mainProgram = "asterisk";
158 maintainers = with maintainers; [
159 auntie
160 DerTim1
161 yorickvp
162 ];
163 };
164 };
165
166 pjproject = fetchurl {
167 url = "https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.15.1/pjproject-2.15.1.tar.bz2";
168 hash = "sha256-WLuDzsTUMfSNAG5FXYIWaEUPjPa2yV8JDe9HBi+jpgw=";
169 };
170
171 mp3-204 = fetchsvn {
172 url = "http://svn.digium.com/svn/thirdparty/mp3/trunk";
173 rev = "204";
174 hash = "sha256-Viec0LwFPfR7ewy+2hc/LIUR1LiDZfYos3RUbc+tyNk=";
175 };
176
177 asterisk-opus = fetchFromGitHub {
178 owner = "traud";
179 repo = "asterisk-opus";
180 # No releases, points to master as of 2022-04-06
181 rev = "a959f072d3f364be983dd27e6e250b038aaef747";
182 hash = "sha256-CASlTvTahOg9D5jccF/IN10LP/U8rRy9BFCSaHGQfCw=";
183 };
184
185 # auto-generated by update.py
186 versions = lib.mapAttrs (
187 _:
188 { version, sha256 }:
189 common {
190 inherit version sha256;
191 externals = {
192 "externals_cache/${pjproject.name}" = pjproject;
193 "addons/mp3" = mp3-204;
194 };
195 }
196 ) (lib.importJSON ./versions.json);
197
198 updateScript_python = python3.withPackages (
199 p: with p; [
200 packaging
201 beautifulsoup4
202 requests
203 ]
204 );
205 updateScript = writeScript "asterisk-update" ''
206 #!/usr/bin/env bash
207 exec ${updateScript_python}/bin/python ${toString ./update.py}
208 '';
209
210in
211{
212 # Supported releases (as of 2023-04-19).
213 # v16 and v19 have been dropped because they go EOL before the NixOS 23.11 release.
214 # Source: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions
215 # Exact version can be found at https://www.asterisk.org/downloads/asterisk/all-asterisk-versions/
216 #
217 # Series Type Rel. Date Sec. Fixes EOL
218 # 16.x LTS 2018-10-09 2022-10-09 2023-10-09 (dropped)
219 # 18.x LTS 2020-10-20 2024-10-20 2025-10-20
220 # 19.x Standard 2021-11-02 2022-11-02 2023-11-02 (dropped)
221 # 20.x LTS 2022-11-02 2026-10-19 2027-10-19
222 # 21.x Standard 2023-10-18 2025-10-18 2026-10-18 (unreleased)
223 asterisk-lts = versions.asterisk_18;
224 asterisk-stable = versions.asterisk_20;
225 asterisk = versions.asterisk_20.overrideAttrs (o: {
226 passthru = (o.passthru or { }) // {
227 inherit updateScript;
228 };
229 });
230
231}
232// versions