summary refs log tree commit diff
path: root/pkgs/servers/http/hiawatha/default.nix
blob: 277fa06a707910d35db75f8f2ee4cfb2d33c3590 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ stdenv, fetchurl, cmake,
  libxslt, zlib, libxml2, openssl,
  enableSSL ? true,
  enableMonitor ? false,
  enableRproxy ? true,
  enableTomahawk ? false,
  enableXSLT ? true,
  enableToolkit ? true
}:

assert enableSSL -> openssl !=null;

stdenv.mkDerivation rec {
  name = "hiawatha-${version}";
  version = "10.8.1";

  src = fetchurl {
    url = "https://github.com/hsleisink/hiawatha/archive/v${version}.tar.gz";
    sha256 = "1f2hlw2lp98b4dx87i7pz7h66vsy2g22b5adfrlij3kj0vfv61w8";
  };

  buildInputs =  [ cmake libxslt zlib libxml2 ] ++ stdenv.lib.optional enableSSL openssl ;

  prePatch = ''
    substituteInPlace CMakeLists.txt --replace SETUID ""
  '';

  cmakeFlags = [
    ( if enableSSL then "-DENABLE_TLS=on" else "-DENABLE_TLS=off" )
    ( if enableMonitor then "-DENABLE_MONITOR=on" else "-DENABLE_MONITOR=off" )
    ( if enableRproxy then "-DENABLE_RPROXY=on" else "-DENABLE_RPROXY=off" )
    ( if enableTomahawk then "-DENABLE_TOMAHAWK=on" else "-DENABLE_TOMAHAWK=off" )
    ( if enableXSLT then "-DENABLE_XSLT=on" else "-DENABLE_XSLT=off" )
    ( if enableToolkit then "-DENABLE_TOOLKIT=on" else "-DENABLE_TOOLKIT=off" )
    "-DWEBROOT_DIR=/var/www/hiawatha"
    "-DPID_DIR=/run"
    "-DWORK_DIR=/var/lib/hiawatha"
    "-DLOG_DIR=/var/log/hiawatha"
  ];

  # workaround because cmake tries installs stuff outside of nix store
  makeFlags = [ "DESTDIR=$(out)" "PREFIX=" ];
  postInstall = ''
    mv $out/$out/* $out
    rm -rf $out/{var,run}
  '';

  meta = with stdenv.lib; {
    description = "An advanced and secure webserver";
    license = licenses.gpl2;
    homepage = https://www.hiawatha-webserver.org;
    maintainers = [ maintainers.ndowens ];
  };

}