nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, buildPackages, fetchurl, pkg-config, pcre2, libxml2, zlib, bzip2, which, file
2, fetchpatch
3, openssl
4, enableDbi ? false, libdbi
5, enableMagnet ? false, lua5_1
6, enableMysql ? false, libmysqlclient
7, enableLdap ? false, openldap
8, enablePam ? false, linux-pam
9, enableSasl ? false, cyrus_sasl
10, enableWebDAV ? false, sqlite, libuuid
11, enableExtendedAttrs ? false, attr
12, perl
13, nixosTests
14}:
15
16stdenv.mkDerivation rec {
17 pname = "lighttpd";
18 version = "1.4.71";
19
20 src = fetchurl {
21 url = "https://download.lighttpd.net/lighttpd/releases-${lib.versions.majorMinor version}.x/${pname}-${version}.tar.xz";
22 sha256 = "sha256-uLaRXaIDlv3DVN8zJNXkQBabLl6nhZ46d1IThBMlr6w=";
23 };
24
25 patches = [
26 # disable tests for des/md5, which we don't support any more
27 ./disable-legacy-crypt-tests.patch
28 ];
29
30 postPatch = ''
31 patchShebangs tests
32 # Linux sandbox has an empty hostname and not /etc/hosts, which fails some tests
33 sed -ire '/[$]self->{HOSTNAME} *=/i if(length($name)==0) { $name = "127.0.0.1" }' tests/LightyTest.pm
34 # it's difficult to prevent this test from trying to use /var/tmp (which
35 # the sandbox doesn't have) so until libredirect has support for mkstemp
36 # calls it's easiest to disable it
37 sed -i '/test_mod_ssi/d' src/t/test_mod.c
38 '';
39
40 depsBuildBuild = [ buildPackages.stdenv.cc ];
41
42 nativeBuildInputs = [ pkg-config ];
43 buildInputs = [ pcre2 pcre2.dev libxml2 zlib bzip2 which file openssl ]
44 ++ lib.optional enableDbi libdbi
45 ++ lib.optional enableMagnet lua5_1
46 ++ lib.optional enableMysql libmysqlclient
47 ++ lib.optional enableLdap openldap
48 ++ lib.optional enablePam linux-pam
49 ++ lib.optional enableSasl cyrus_sasl
50 ++ lib.optional enableWebDAV sqlite
51 ++ lib.optional enableWebDAV libuuid;
52
53 configureFlags = [ "--with-openssl" ]
54 ++ lib.optional enableDbi "--with-dbi"
55 ++ lib.optional enableMagnet "--with-lua"
56 ++ lib.optional enableMysql "--with-mysql"
57 ++ lib.optional enableLdap "--with-ldap"
58 ++ lib.optional enablePam "--with-pam"
59 ++ lib.optional enableSasl "--with-sasl"
60 ++ lib.optional enableWebDAV "--with-webdav-props"
61 ++ lib.optional enableWebDAV "--with-webdav-locks"
62 ++ lib.optional enableExtendedAttrs "--with-attr";
63
64 preConfigure = ''
65 export PATH=$PATH:${pcre2.dev}/bin
66 sed -i "s:/usr/bin/file:${file}/bin/file:g" configure
67 '';
68
69 nativeCheckInputs = [ perl ];
70 doCheck = true;
71
72 postInstall = ''
73 mkdir -p "$out/share/lighttpd/doc/config"
74 cp -vr doc/config "$out/share/lighttpd/doc/"
75 # Remove files that references needless store paths (dependency bloat)
76 rm "$out/share/lighttpd/doc/config/Makefile"*
77 rm "$out/share/lighttpd/doc/config/conf.d/Makefile"*
78 rm "$out/share/lighttpd/doc/config/vhosts.d/Makefile"*
79 '';
80
81 passthru.tests = {
82 inherit (nixosTests) lighttpd;
83 };
84
85 meta = with lib; {
86 description = "Lightweight high-performance web server";
87 homepage = "http://www.lighttpd.net/";
88 license = lib.licenses.bsd3;
89 platforms = platforms.linux ++ platforms.darwin;
90 maintainers = with maintainers; [ bjornfor brecht ];
91 };
92}