nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 154 lines 4.6 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 makeWrapper, 6 gawk, 7 gnused, 8 gnugrep, 9 coreutils, 10 which, 11 perlPackages, 12 withMySQL ? false, 13 zlib, 14 mariadb-connector-c, 15 withPgSQL ? false, 16 libpq, 17 withSQLite ? false, 18 sqlite, 19 withDB ? false, 20 db, 21}: 22 23let 24 drivers = lib.concatStringsSep "," ( 25 [ "hash_drv" ] 26 ++ lib.optional withMySQL "mysql_drv" 27 ++ lib.optional withPgSQL "pgsql_drv" 28 ++ lib.optional withSQLite "sqlite3_drv" 29 ++ lib.optional withDB "libdb4_drv" 30 ); 31 maintenancePath = lib.makeBinPath [ 32 gawk 33 gnused 34 gnugrep 35 coreutils 36 which 37 ]; 38 39in 40stdenv.mkDerivation rec { 41 pname = "dspam"; 42 version = "3.10.2"; 43 44 src = fetchurl { 45 url = "mirror://sourceforge/dspam/dspam/${pname}-${version}/${pname}-${version}.tar.gz"; 46 sha256 = "1acklnxn1wvc7abn31l3qdj8q6k13s51k5gv86vka7q20jb5cxmf"; 47 }; 48 patches = [ 49 # https://gist.github.com/WhiteAnthrax/613136c76882e0ead3cb3bdad6b3d551 50 ./mariadb.patch 51 ]; 52 53 buildInputs = [ 54 perlPackages.perl 55 ] 56 ++ lib.optionals withMySQL [ 57 zlib 58 mariadb-connector-c.out 59 ] 60 ++ lib.optional withPgSQL libpq 61 ++ lib.optional withSQLite sqlite 62 ++ lib.optional withDB db; 63 nativeBuildInputs = [ 64 libpq.pg_config 65 makeWrapper 66 ]; 67 # patch out libmysql >= 5 check, since mariadb-connector is at 3.x 68 postPatch = '' 69 sed -i 's/atoi(m) >= 5/1/g' configure m4/mysql_drv.m4 70 ''; 71 72 configureFlags = [ 73 "--with-storage-driver=${drivers}" 74 "--sysconfdir=/etc/dspam" 75 "--localstatedir=/var" 76 "--with-dspam-home=/var/lib/dspam" 77 "--with-logdir=/var/log/dspam" 78 "--with-logfile=/var/log/dspam/dspam.log" 79 80 "--enable-daemon" 81 "--enable-clamav" 82 "--enable-syslog" 83 "--enable-large-scale" 84 "--enable-virtual-users" 85 "--enable-split-configuration" 86 "--enable-preferences-extension" 87 "--enable-long-usernames" 88 "--enable-external-lookup" 89 ] 90 ++ lib.optionals withMySQL [ 91 "--with-mysql-includes=${mariadb-connector-c.dev}/include/mysql" 92 "--with-mysql-libraries=${mariadb-connector-c.out}/lib/mysql" 93 ]; 94 95 # Workaround build failure on -fno-common toolchains like upstream 96 # gcc-10. Otherwise build fails as: 97 # ld: .libs/hash_drv.o:/build/dspam-3.10.2/src/util.h:96: multiple definition of `verified_user'; 98 # .libs/libdspam.o:/build/dspam-3.10.2/src/util.h:96: first defined here 99 env.NIX_CFLAGS_COMPILE = "-fcommon"; 100 101 # Lots of things are hardwired to paths like sysconfdir. That's why we install with both "prefix" and "DESTDIR" 102 # and fix directory structure manually after that. 103 installFlags = [ "DESTDIR=$(out)" ]; 104 105 postInstall = '' 106 cp -r $out/$out/* $out 107 rm -rf $out/$(echo "$out" | cut -d "/" -f2) 108 rm -rf $out/var 109 110 wrapProgram $out/bin/dspam_notify \ 111 --set PERL5LIB "${perlPackages.makePerlPath [ perlPackages.libnet ]}" 112 113 # Install SQL scripts 114 mkdir -p $out/share/dspam/sql 115 # MySQL 116 cp src/tools.mysql_drv/mysql_*.sql $out/share/dspam/sql 117 for i in src/tools.mysql_drv/{purge*.sql,virtual*.sql}; do 118 cp "$i" $out/share/dspam/sql/mysql_$(basename "$i") 119 done 120 # PostgreSQL 121 cp src/tools.pgsql_drv/pgsql_*.sql $out/share/dspam/sql 122 for i in src/tools.pgsql_drv/{purge*.sql,virtual*.sql}; do 123 cp "$i" $out/share/dspam/sql/pgsql_$(basename "$i") 124 done 125 # SQLite 126 for i in src/tools.sqlite_drv/purge*.sql; do 127 cp "$i" $out/share/dspam/sql/sqlite_$(basename "$i") 128 done 129 130 # Install maintenance script 131 install -Dm755 contrib/dspam_maintenance/dspam_maintenance.sh $out/bin/dspam_maintenance 132 sed -i \ 133 -e "2iexport PATH=$out/bin:${maintenancePath}:\$PATH" \ 134 -e 's,/usr/[a-z0-9/]*,,g' \ 135 -e 's,^DSPAM_CONFIGDIR=.*,DSPAM_CONFIGDIR=/etc/dspam,' \ 136 -e "s,^DSPAM_HOMEDIR=.*,DSPAM_HOMEDIR=/var/lib/dspam," \ 137 -e "s,^DSPAM_PURGE_SCRIPT_DIR=.*,DSPAM_PURGE_SCRIPT_DIR=$out/share/dspam/sql," \ 138 -e "s,^DSPAM_BIN_DIR=.*,DSPAM_BIN_DIR=$out/bin," \ 139 -e "s,^MYSQL_BIN_DIR=.*,MYSQL_BIN_DIR=/run/current-system/sw/bin," \ 140 -e "s,^PGSQL_BIN_DIR=.*,PGSQL_BIN_DIR=/run/current-system/sw/bin," \ 141 -e "s,^SQLITE_BIN_DIR=.*,SQLITE_BIN_DIR=/run/current-system/sw/bin," \ 142 -e "s,^SQLITE3_BIN_DIR=.*,SQLITE3_BIN_DIR=/run/current-system/sw/bin," \ 143 -e 's,^DSPAM_CRON_LOCKFILE=.*,DSPAM_CRON_LOCKFILE=/run/dspam/dspam_maintenance.pid,' \ 144 $out/bin/dspam_maintenance 145 ''; 146 147 meta = { 148 homepage = "https://dspam.sourceforge.net/"; 149 description = "Community Driven Antispam Filter"; 150 license = lib.licenses.agpl3Plus; 151 platforms = lib.platforms.linux; 152 maintainers = [ ]; 153 }; 154}