Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 208 lines 4.7 kB view raw
1{ 2 stdenv, 3 fetchurl, 4 lib, 5 ncurses, 6 openssl, 7 aspell, 8 cjson, 9 gnutls, 10 gettext, 11 zlib, 12 curl, 13 pkg-config, 14 libgcrypt, 15 cmake, 16 libresolv, 17 libiconv, 18 asciidoctor, # manpages 19 enableTests ? !stdenv.hostPlatform.isDarwin, 20 cpputest, 21 guileSupport ? true, 22 guile, 23 luaSupport ? true, 24 lua5, 25 perlSupport ? true, 26 perl, 27 pythonSupport ? true, 28 python3Packages, 29 rubySupport ? true, 30 ruby, 31 tclSupport ? true, 32 tcl, 33 phpSupport ? !stdenv.hostPlatform.isDarwin, 34 php, 35 systemd, 36 libxml2, 37 pcre2, 38 libargon2, 39 extraBuildInputs ? [ ], 40 writeScript, 41}: 42 43let 44 inherit (python3Packages) python; 45 php-embed = php.override { 46 embedSupport = true; 47 apxs2Support = false; 48 }; 49 plugins = [ 50 { 51 name = "perl"; 52 enabled = perlSupport; 53 cmakeFlag = "ENABLE_PERL"; 54 buildInputs = [ perl ]; 55 } 56 { 57 name = "tcl"; 58 enabled = tclSupport; 59 cmakeFlag = "ENABLE_TCL"; 60 buildInputs = [ tcl ]; 61 } 62 { 63 name = "ruby"; 64 enabled = rubySupport; 65 cmakeFlag = "ENABLE_RUBY"; 66 buildInputs = [ ruby ]; 67 } 68 { 69 name = "guile"; 70 enabled = guileSupport; 71 cmakeFlag = "ENABLE_GUILE"; 72 buildInputs = [ guile ]; 73 } 74 { 75 name = "lua"; 76 enabled = luaSupport; 77 cmakeFlag = "ENABLE_LUA"; 78 buildInputs = [ lua5 ]; 79 } 80 { 81 name = "python"; 82 enabled = pythonSupport; 83 cmakeFlag = "ENABLE_PYTHON3"; 84 buildInputs = [ python ]; 85 } 86 { 87 name = "php"; 88 enabled = phpSupport; 89 cmakeFlag = "ENABLE_PHP"; 90 buildInputs = [ 91 php-embed.unwrapped.dev 92 libxml2 93 pcre2 94 libargon2 95 ] 96 ++ lib.optional stdenv.hostPlatform.isLinux systemd; 97 } 98 ]; 99 enabledPlugins = builtins.filter (p: p.enabled) plugins; 100 101in 102 103assert lib.all (p: p.enabled -> !(builtins.elem null p.buildInputs)) plugins; 104 105stdenv.mkDerivation rec { 106 pname = "weechat"; 107 version = "4.7.0"; 108 109 src = fetchurl { 110 url = "https://weechat.org/files/src/weechat-${version}.tar.xz"; 111 hash = "sha256-RdwDlgYMhjFphoNJ7CgK8cb0rFJKpJJYDhoGXhQsLNg="; 112 }; 113 114 # Why is this needed? https://github.com/weechat/weechat/issues/2031 115 patches = lib.optional gettext.gettextNeedsLdflags ./gettext-intl.patch; 116 117 outputs = [ 118 "out" 119 "man" 120 ] 121 ++ map (p: p.name) enabledPlugins; 122 123 cmakeFlags = [ 124 (lib.cmakeBool "ENABLE_MAN" true) 125 (lib.cmakeBool "ENABLE_DOC" true) 126 (lib.cmakeBool "ENABLE_DOC_INCOMPLETE" true) 127 (lib.cmakeBool "ENABLE_TESTS" enableTests) 128 ] 129 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 130 (lib.cmakeFeature "ICONV_LIBRARY" "${libiconv}/lib/libiconv.dylib") 131 ] 132 ++ map (p: lib.cmakeBool p.cmakeFlag p.enabled) plugins; 133 134 nativeBuildInputs = [ 135 cmake 136 pkg-config 137 asciidoctor 138 ] 139 ++ lib.optional enableTests cpputest; 140 141 buildInputs = [ 142 ncurses 143 openssl 144 aspell 145 cjson 146 gnutls 147 gettext 148 zlib 149 curl 150 libgcrypt 151 ] 152 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 153 libresolv 154 ] 155 ++ lib.concatMap (p: p.buildInputs) enabledPlugins 156 ++ extraBuildInputs; 157 158 hardeningEnable = [ "pie" ]; 159 160 env.NIX_CFLAGS_COMPILE = 161 "-I${python}/include/${python.libPrefix}" 162 # Fix '_res_9_init: undefined symbol' error 163 + (lib.optionalString stdenv.hostPlatform.isDarwin "-DBIND_8_COMPAT=1 -lresolv"); 164 165 postInstall = '' 166 for p in ${lib.concatMapStringsSep " " (p: p.name) enabledPlugins}; do 167 from=$out/lib/weechat/plugins/$p.so 168 to=''${!p}/lib/weechat/plugins/$p.so 169 mkdir -p $(dirname $to) 170 mv $from $to 171 done 172 ''; 173 174 doInstallCheck = true; 175 176 installCheckPhase = '' 177 $out/bin/weechat --version 178 ''; 179 180 passthru.updateScript = writeScript "update-weechat" '' 181 #!/usr/bin/env nix-shell 182 #!nix-shell -i bash -p coreutils gawk git gnugrep common-updater-scripts 183 set -eu -o pipefail 184 185 version="$(git ls-remote --refs https://github.com/weechat/weechat | \ 186 awk '{ print $2 }' | \ 187 grep "refs/tags/v" | \ 188 sed -E -e 's,refs/tags/v(.*)$,\1,' | \ 189 sort --version-sort --reverse | \ 190 head -n1)" 191 update-source-version weechat-unwrapped "$version" 192 ''; 193 194 meta = { 195 homepage = "https://weechat.org/"; 196 changelog = "https://github.com/weechat/weechat/releases/tag/v${version}"; 197 description = "Fast, light and extensible chat client"; 198 longDescription = '' 199 You can find more documentation as to how to customize this package 200 (e.g. adding python modules for scripts that would require them, etc.) 201 on https://nixos.org/nixpkgs/manual/#sec-weechat . 202 ''; 203 license = lib.licenses.gpl3; 204 maintainers = with lib.maintainers; [ ncfavier ]; 205 mainProgram = "weechat"; 206 platforms = lib.platforms.unix; 207 }; 208}