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