about summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/amqp/qpid-cpp/default.nix59
-rw-r--r--pkgs/servers/amqp/rabbitmq-server/default.nix72
-rw-r--r--[-rwxr-xr-x]pkgs/servers/apache-kafka/default.nix40
-rw-r--r--pkgs/servers/apcupsd/default.nix20
-rw-r--r--pkgs/servers/asterisk/default.nix169
-rw-r--r--pkgs/servers/asterisk/disable-download.patch12
-rw-r--r--pkgs/servers/asterisk/runtime-vardirs.patch6
-rw-r--r--pkgs/servers/atlassian/confluence.nix46
-rw-r--r--pkgs/servers/atlassian/crowd.nix50
-rw-r--r--pkgs/servers/atlassian/jira.nix43
-rw-r--r--pkgs/servers/beanstalkd/default.nix2
-rw-r--r--pkgs/servers/bird/default.nix66
-rw-r--r--pkgs/servers/bird/dont-create-sysconfdir-1.patch (renamed from pkgs/servers/bird/dont-create-sysconfdir.patch)0
-rw-r--r--pkgs/servers/bird/dont-create-sysconfdir-2.patch13
-rw-r--r--pkgs/servers/brickd/default.nix7
-rw-r--r--pkgs/servers/caddy/default.nix29
-rw-r--r--pkgs/servers/cayley/default.nix30
-rw-r--r--pkgs/servers/cayley/deps.nix272
-rw-r--r--pkgs/servers/clickhouse/default.nix35
-rw-r--r--pkgs/servers/clickhouse/find-mysql.patch11
-rw-r--r--pkgs/servers/clickhouse/termcap.patch25
-rw-r--r--pkgs/servers/cloud-print-connector/default.nix35
-rw-r--r--pkgs/servers/cloud-print-connector/deps.nix57
-rw-r--r--pkgs/servers/computing/slurm-spank-x11/default.nix39
-rw-r--r--pkgs/servers/computing/slurm/default.nix60
-rw-r--r--pkgs/servers/computing/storm/default.nix72
-rw-r--r--pkgs/servers/computing/torque/default.nix9
-rw-r--r--pkgs/servers/consul/Gemfile1
-rw-r--r--pkgs/servers/consul/Gemfile.lock27
-rw-r--r--pkgs/servers/consul/default.nix31
-rw-r--r--pkgs/servers/consul/gemset.nix57
-rw-r--r--pkgs/servers/consul/ui-no-bundle-exec.patch17
-rw-r--r--pkgs/servers/consul/ui.nix20
-rw-r--r--pkgs/servers/corosync/default.nix55
-rw-r--r--pkgs/servers/coturn/default.nix27
-rw-r--r--pkgs/servers/coturn/pure-configure.patch17
-rw-r--r--pkgs/servers/couchpotato/default.nix43
-rw-r--r--pkgs/servers/dante/default.nix25
-rw-r--r--pkgs/servers/dex/default.nix32
-rw-r--r--pkgs/servers/dgraph/default.nix41
-rw-r--r--pkgs/servers/dgraph/deps.nix326
-rw-r--r--pkgs/servers/dico/default.nix10
-rw-r--r--pkgs/servers/dict/default.nix23
-rw-r--r--pkgs/servers/dict/dictd-db.nix178
-rw-r--r--pkgs/servers/dict/dictd-wiktionary.nix6
-rw-r--r--pkgs/servers/dict/dictd-wordnet.nix4
-rw-r--r--pkgs/servers/dict/libmaa.nix2
-rw-r--r--pkgs/servers/diod/default.nix4
-rw-r--r--pkgs/servers/dns/bind/darwin-openssl-linking-fix.patch26
-rw-r--r--pkgs/servers/dns/bind/default.nix72
-rw-r--r--pkgs/servers/dns/bind/dont-keep-configure-flags.patch41
-rw-r--r--pkgs/servers/dns/bind/remove-mkdir-var.patch12
-rw-r--r--pkgs/servers/dns/coredns/default.nix25
-rw-r--r--pkgs/servers/dns/coredns/deps.nix317
-rw-r--r--pkgs/servers/dns/dnsdist/default.nix35
-rw-r--r--pkgs/servers/dns/knot-dns/default.nix44
-rw-r--r--pkgs/servers/dns/knot-resolver/default.nix82
-rw-r--r--pkgs/servers/dns/nsd/default.nix21
-rw-r--r--pkgs/servers/dns/pdns-recursor/default.nix38
-rw-r--r--pkgs/servers/dns/powerdns/default.nix52
-rw-r--r--pkgs/servers/dns/powerdns/skip-sha384-test.patch14
-rw-r--r--pkgs/servers/dnschain/default.nix11
-rw-r--r--pkgs/servers/dnschain/package.json3
-rw-r--r--pkgs/servers/dnschain/package.nix2200
-rw-r--r--pkgs/servers/elasticmq/default.nix3
-rw-r--r--pkgs/servers/emby/default.nix44
-rw-r--r--pkgs/servers/etcd/default.nix36
-rw-r--r--pkgs/servers/exhibitor/default.nix54
-rw-r--r--pkgs/servers/fcgiwrap/default.nix10
-rw-r--r--pkgs/servers/felix/default.nix11
-rw-r--r--pkgs/servers/felix/remoteshell.nix11
-rw-r--r--pkgs/servers/fingerd/bsd-fingerd/default.nix4
-rw-r--r--pkgs/servers/firebird/default.nix12
-rw-r--r--pkgs/servers/fleet/default.nix33
-rw-r--r--pkgs/servers/foswiki/default.nix44
-rw-r--r--pkgs/servers/foundationdb/default.nix129
-rw-r--r--pkgs/servers/foundationdb/fix-scm-version.patch42
-rw-r--r--pkgs/servers/foundationdb/ldflags.patch90
-rw-r--r--pkgs/servers/freeradius/default.nix87
-rw-r--r--pkgs/servers/ftp/bftpd/default.nix36
-rw-r--r--pkgs/servers/ftp/pure-ftpd/default.nix22
-rw-r--r--pkgs/servers/ftp/vsftpd/default.nix4
-rw-r--r--pkgs/servers/games/ghost-one/default.nix53
-rw-r--r--pkgs/servers/gopher/gofish/default.nix20
-rw-r--r--pkgs/servers/gotty/default.nix25
-rw-r--r--pkgs/servers/gotty/deps.nix74
-rw-r--r--pkgs/servers/gpm/default.nix13
-rw-r--r--pkgs/servers/gpsd/0001-Import-LD_LIBRARY_PATH-to-allow-running-scons-check-.patch10
-rw-r--r--pkgs/servers/gpsd/0001-Use-pkgconfig-for-dbus-library.patch31
-rw-r--r--pkgs/servers/gpsd/0002-Import-XML_CATALOG_FILES-to-be-able-to-validate-the-.patch10
-rw-r--r--pkgs/servers/gpsd/default.nix45
-rw-r--r--pkgs/servers/h2/default.nix44
-rw-r--r--pkgs/servers/hbase/default.nix4
-rw-r--r--pkgs/servers/hitch/default.nix23
-rw-r--r--pkgs/servers/home-assistant/appdaemon.nix57
-rw-r--r--pkgs/servers/home-assistant/component-packages.nix1173
-rw-r--r--pkgs/servers/home-assistant/default.nix123
-rw-r--r--pkgs/servers/home-assistant/frontend.nix13
-rwxr-xr-xpkgs/servers/home-assistant/parse-requirements.py131
-rw-r--r--pkgs/servers/http/4store/4store-1.1.6-glibc-2.26.patch12
-rw-r--r--pkgs/servers/http/4store/default.nix88
-rw-r--r--pkgs/servers/http/apache-httpd/2.2.nix68
-rw-r--r--pkgs/servers/http/apache-httpd/2.4.nix59
-rw-r--r--pkgs/servers/http/apache-modules/mod_auth_mellon/default.nix39
-rw-r--r--pkgs/servers/http/apache-modules/mod_auth_mellon/fixdeps.patch30
-rw-r--r--pkgs/servers/http/apache-modules/mod_dnssd/default.nix11
-rw-r--r--pkgs/servers/http/apache-modules/mod_evasive/default.nix2
-rw-r--r--pkgs/servers/http/apache-modules/mod_fastcgi/default.nix6
-rw-r--r--pkgs/servers/http/apache-modules/mod_perl/default.nix25
-rw-r--r--pkgs/servers/http/apache-modules/mod_python/default.nix5
-rw-r--r--pkgs/servers/http/apache-modules/mod_wsgi/default.nix12
-rw-r--r--pkgs/servers/http/apache-modules/tomcat-connectors/default.nix10
-rw-r--r--pkgs/servers/http/apt-cacher-ng/default.nix34
-rw-r--r--pkgs/servers/http/couchdb/2.0.0.nix54
-rw-r--r--pkgs/servers/http/couchdb/default.nix31
-rw-r--r--pkgs/servers/http/couchdb/jsapi.patch60
-rw-r--r--pkgs/servers/http/darkhttpd/default.nix30
-rw-r--r--pkgs/servers/http/gatling/default.nix32
-rw-r--r--pkgs/servers/http/h2o/default.nix30
-rw-r--r--pkgs/servers/http/hiawatha/default.nix55
-rw-r--r--pkgs/servers/http/hyp/default.nix19
-rw-r--r--pkgs/servers/http/jboss/default.nix4
-rw-r--r--pkgs/servers/http/jboss/jdbc/mysql/default.nix4
-rw-r--r--pkgs/servers/http/jetty/6.1/bin-builder.sh7
-rw-r--r--pkgs/servers/http/jetty/6.1/default.nix13
-rw-r--r--pkgs/servers/http/jetty/9.2.nix28
-rw-r--r--pkgs/servers/http/jetty/bin-builder.sh7
-rw-r--r--pkgs/servers/http/jetty/default.nix28
-rw-r--r--pkgs/servers/http/joseki/default.nix112
-rw-r--r--pkgs/servers/http/lighttpd/default.nix31
-rw-r--r--pkgs/servers/http/lwan/default.nix35
-rw-r--r--pkgs/servers/http/micro-httpd/default.nix2
-rw-r--r--pkgs/servers/http/mini-httpd/default.nix14
-rw-r--r--pkgs/servers/http/myserver/default.nix2
-rw-r--r--pkgs/servers/http/nginx/default.nix162
-rw-r--r--pkgs/servers/http/nginx/generic.nix78
-rw-r--r--pkgs/servers/http/nginx/mainline.nix6
-rw-r--r--pkgs/servers/http/nginx/mainline.upstream (renamed from pkgs/servers/http/nginx/unstable.upstream)0
-rw-r--r--pkgs/servers/http/nginx/modules.nix199
-rw-r--r--pkgs/servers/http/nginx/stable.nix6
-rw-r--r--pkgs/servers/http/nginx/stable.upstream (renamed from pkgs/servers/http/nginx/default.upstream)0
-rw-r--r--pkgs/servers/http/nginx/unstable.nix134
-rw-r--r--pkgs/servers/http/nix-binary-cache/default.nix16
-rw-r--r--pkgs/servers/http/openresty/default.nix41
-rw-r--r--pkgs/servers/http/pshs/default.nix24
-rw-r--r--pkgs/servers/http/redstore/default.nix17
-rw-r--r--pkgs/servers/http/spawn-fcgi/default.nix1
-rw-r--r--pkgs/servers/http/thttpd/default.nix8
-rw-r--r--pkgs/servers/http/tomcat/5.0.nix17
-rw-r--r--pkgs/servers/http/tomcat/6.0.nix6
-rw-r--r--pkgs/servers/http/tomcat/7.0.nix6
-rw-r--r--pkgs/servers/http/tomcat/8.0.nix6
-rw-r--r--pkgs/servers/http/tomcat/axis2/default.nix12
-rw-r--r--pkgs/servers/http/tomcat/builder.sh20
-rw-r--r--pkgs/servers/http/tomcat/default.nix56
-rw-r--r--pkgs/servers/http/tomcat/jdbc/mysql/default.nix8
-rw-r--r--pkgs/servers/http/tomcat/recent.nix25
-rw-r--r--pkgs/servers/http/webfs/default.nix34
-rw-r--r--pkgs/servers/http/webfs/ls.c.patch13
-rw-r--r--pkgs/servers/http/yaws/default.nix6
-rw-r--r--pkgs/servers/icecast/default.nix7
-rw-r--r--pkgs/servers/identd/oidentd/default.nix9
-rw-r--r--pkgs/servers/inginious/default.nix74
-rw-r--r--pkgs/servers/interlock/default.nix37
-rw-r--r--pkgs/servers/interlock/deps.nix65
-rw-r--r--pkgs/servers/irc/charybdis/default.nix29
-rw-r--r--pkgs/servers/irc/ircd-hybrid/default.nix12
-rw-r--r--pkgs/servers/irc/ngircd/default.nix6
-rw-r--r--pkgs/servers/irker/default.nix41
-rw-r--r--pkgs/servers/isso/default.nix54
-rw-r--r--pkgs/servers/jackett/default.nix30
-rw-r--r--pkgs/servers/jetbrains/youtrack.nix30
-rw-r--r--pkgs/servers/kippo/default.nix50
-rw-r--r--pkgs/servers/kwakd/default.nix28
-rw-r--r--pkgs/servers/ldap/389/default.nix28
-rw-r--r--pkgs/servers/limesurvey/default.nix1
-rw-r--r--pkgs/servers/mail/archiveopteryx/default.nix42
-rw-r--r--pkgs/servers/mail/clamsmtp/default.nix22
-rw-r--r--pkgs/servers/mail/clamsmtp/header-order.patch25
-rw-r--r--pkgs/servers/mail/dkimproxy/default.nix36
-rw-r--r--pkgs/servers/mail/dovecot/2.2.x-module_dir.patch113
-rw-r--r--pkgs/servers/mail/dovecot/2.2.x.nix57
-rw-r--r--pkgs/servers/mail/dovecot/default.nix75
-rw-r--r--pkgs/servers/mail/dovecot/plugins/pigeonhole/default.nix (renamed from pkgs/servers/mail/dovecot-pigeonhole/default.nix)25
-rw-r--r--pkgs/servers/mail/dspam/default.nix108
-rw-r--r--pkgs/servers/mail/exim/default.nix19
-rw-r--r--pkgs/servers/mail/freepops/default.nix3
-rw-r--r--pkgs/servers/mail/mailhog/default.nix25
-rw-r--r--pkgs/servers/mail/mailhog/deps.nix191
-rw-r--r--pkgs/servers/mail/mailman/default.nix15
-rw-r--r--pkgs/servers/mail/mlmmj/default.nix12
-rw-r--r--pkgs/servers/mail/nullmailer/default.nix51
-rw-r--r--pkgs/servers/mail/opensmtpd/default.nix53
-rw-r--r--pkgs/servers/mail/opensmtpd/extras.nix14
-rw-r--r--pkgs/servers/mail/opensmtpd/proc_path.diff81
-rw-r--r--pkgs/servers/mail/petidomo/default.nix8
-rw-r--r--pkgs/servers/mail/popa3d/default.nix3
-rw-r--r--pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch54
-rw-r--r--pkgs/servers/mail/postfix/2.11.nix63
-rw-r--r--pkgs/servers/mail/postfix/db-linux3.patch39
-rw-r--r--pkgs/servers/mail/postfix/default.nix111
-rw-r--r--pkgs/servers/mail/postfix/pfixtools.nix55
-rw-r--r--pkgs/servers/mail/postfix/pflogsumm.nix35
-rw-r--r--pkgs/servers/mail/postfix/post-install-script.patch28
-rw-r--r--pkgs/servers/mail/postfix/postfix-2.11.0.patch76
-rw-r--r--pkgs/servers/mail/postfix/postfix-2.2.9-db.patch40
-rw-r--r--pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch12
-rw-r--r--pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch86
-rw-r--r--pkgs/servers/mail/postfix/postfix-script-shell.patch21
-rw-r--r--pkgs/servers/mail/postfix/relative-symlinks.patch13
-rw-r--r--pkgs/servers/mail/postgrey/default.nix34
-rw-r--r--pkgs/servers/mail/postsrsd/default.nix29
-rw-r--r--pkgs/servers/mail/pypolicyd-spf/default.nix26
-rw-r--r--pkgs/servers/mail/rmilter/default.nix33
-rw-r--r--pkgs/servers/mail/rmilter/fd-passing-libmilter.patch80
-rw-r--r--pkgs/servers/mail/rspamd/default.nix40
-rw-r--r--pkgs/servers/mail/spamassassin/default.nix25
-rw-r--r--pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch59
-rw-r--r--pkgs/servers/matrix-synapse/default.nix64
-rw-r--r--pkgs/servers/matrix-synapse/matrix-synapse.patch20
-rw-r--r--pkgs/servers/matterbridge/default.nix21
-rw-r--r--pkgs/servers/mattermost/default.nix61
-rw-r--r--pkgs/servers/mattermost/matterircd.nix23
-rw-r--r--pkgs/servers/mediatomb/default.nix7
-rw-r--r--pkgs/servers/meguca/default.nix48
-rw-r--r--pkgs/servers/meguca/server_deps.nix255
-rw-r--r--pkgs/servers/memcached/default.nix9
-rw-r--r--pkgs/servers/mesos-dns/default.nix21
-rw-r--r--pkgs/servers/mesos-dns/deps.nix101
-rw-r--r--pkgs/servers/metabase/default.nix27
-rw-r--r--pkgs/servers/meteor/default.nix18
-rw-r--r--pkgs/servers/meteor/main.patch19
-rw-r--r--pkgs/servers/minio/default.nix28
-rw-r--r--pkgs/servers/mirrorbits/default.nix48
-rw-r--r--pkgs/servers/mirrorbits/deps.nix66
-rw-r--r--pkgs/servers/misc/airsonic/default.nix24
-rw-r--r--pkgs/servers/misc/client-ip-echo/client-ip-echo.nix17
-rw-r--r--pkgs/servers/misc/client-ip-echo/default.nix2
-rw-r--r--pkgs/servers/misc/subsonic/default.nix5
-rw-r--r--pkgs/servers/misc/taskserver/default.nix24
-rw-r--r--pkgs/servers/monitoring/bosun/default.nix24
-rw-r--r--pkgs/servers/monitoring/cadvisor/default.nix10
-rw-r--r--pkgs/servers/monitoring/consul-alerts/default.nix16
-rw-r--r--pkgs/servers/monitoring/facette/default.nix30
-rw-r--r--pkgs/servers/monitoring/fusion-inventory/default.nix93
-rw-r--r--pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch67
-rw-r--r--pkgs/servers/monitoring/grafana/default.nix35
-rw-r--r--pkgs/servers/monitoring/heapster/default.nix27
-rw-r--r--pkgs/servers/monitoring/kapacitor/default.nix23
-rw-r--r--pkgs/servers/monitoring/lcdproc/default.nix49
-rw-r--r--pkgs/servers/monitoring/lcdproc/hardcode_mtab.patch17
-rw-r--r--pkgs/servers/monitoring/longview/default.nix68
-rw-r--r--pkgs/servers/monitoring/longview/log-stdout.patch38
-rw-r--r--pkgs/servers/monitoring/mtail/default.nix26
-rw-r--r--pkgs/servers/monitoring/mtail/deps.nix56
-rw-r--r--pkgs/servers/monitoring/mtail/fix-gopath.patch13
-rw-r--r--pkgs/servers/monitoring/munin/adding_sconfdir_munin-node.patch41
-rw-r--r--pkgs/servers/monitoring/munin/default.nix32
-rw-r--r--pkgs/servers/monitoring/munin/preserve_environment.patch41
-rw-r--r--pkgs/servers/monitoring/nagios/default.nix10
-rw-r--r--pkgs/servers/monitoring/nagios/plugins/check_ssl_cert.nix28
-rw-r--r--pkgs/servers/monitoring/nagios/plugins/official-2.x.nix36
-rw-r--r--pkgs/servers/monitoring/net-snmp/default.nix31
-rw-r--r--pkgs/servers/monitoring/newrelic-sysmond/default.nix20
-rw-r--r--pkgs/servers/monitoring/plugins/default.nix71
-rw-r--r--pkgs/servers/monitoring/plugins/esxi.nix37
-rw-r--r--pkgs/servers/monitoring/plugins/labs_consol_de.nix79
-rw-r--r--pkgs/servers/monitoring/plugins/uptime.nix26
-rw-r--r--pkgs/servers/monitoring/prometheus/alertmanager.nix42
-rw-r--r--pkgs/servers/monitoring/prometheus/bind-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/blackbox-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/collectd-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/consul-exporter.nix23
-rw-r--r--pkgs/servers/monitoring/prometheus/default.nix56
-rw-r--r--pkgs/servers/monitoring/prometheus/dnsmasq-exporter-deps.nix93
-rw-r--r--pkgs/servers/monitoring/prometheus/dnsmasq-exporter.nix23
-rw-r--r--pkgs/servers/monitoring/prometheus/dovecot-exporter-deps.nix93
-rw-r--r--pkgs/servers/monitoring/prometheus/dovecot-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/fritzbox-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/haproxy-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/json-exporter.nix25
-rw-r--r--pkgs/servers/monitoring/prometheus/json-exporter_deps.nix111
-rw-r--r--pkgs/servers/monitoring/prometheus/mesos-exporter.nix26
-rw-r--r--pkgs/servers/monitoring/prometheus/mesos-exporter_deps.nix83
-rw-r--r--pkgs/servers/monitoring/prometheus/minio-exporter/default.nix35
-rw-r--r--pkgs/servers/monitoring/prometheus/minio-exporter/deps.nix174
-rw-r--r--pkgs/servers/monitoring/prometheus/mysqld-exporter.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/nginx-exporter.nix25
-rw-r--r--pkgs/servers/monitoring/prometheus/nginx-exporter_deps.nix119
-rw-r--r--pkgs/servers/monitoring/prometheus/node-exporter.nix27
-rw-r--r--pkgs/servers/monitoring/prometheus/openvpn-exporter-deps.nix66
-rw-r--r--pkgs/servers/monitoring/prometheus/openvpn-exporter.nix25
-rw-r--r--pkgs/servers/monitoring/prometheus/postfix-exporter-deps.nix66
-rw-r--r--pkgs/servers/monitoring/prometheus/postfix-exporter.nix56
-rw-r--r--pkgs/servers/monitoring/prometheus/prom2json.nix26
-rw-r--r--pkgs/servers/monitoring/prometheus/prom2json_deps.nix38
-rw-r--r--pkgs/servers/monitoring/prometheus/pushgateway.nix43
-rw-r--r--pkgs/servers/monitoring/prometheus/rabbitmq-exporter.nix26
-rw-r--r--pkgs/servers/monitoring/prometheus/rabbitmq-exporter_deps.nix165
-rw-r--r--pkgs/servers/monitoring/prometheus/snmp-exporter.nix27
-rw-r--r--pkgs/servers/monitoring/prometheus/statsd-bridge.nix26
-rw-r--r--pkgs/servers/monitoring/prometheus/statsd-bridge_deps.nix74
-rw-r--r--pkgs/servers/monitoring/prometheus/surfboard-exporter.nix23
-rw-r--r--pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix24
-rw-r--r--pkgs/servers/monitoring/prometheus/varnish-exporter.nix34
-rw-r--r--pkgs/servers/monitoring/prometheus/varnish-exporter_deps.nix65
-rw-r--r--pkgs/servers/monitoring/riemann-dash/Gemfile2
-rw-r--r--pkgs/servers/monitoring/riemann-dash/Gemfile.lock17
-rw-r--r--pkgs/servers/monitoring/riemann-dash/default.nix16
-rw-r--r--pkgs/servers/monitoring/riemann-dash/gemset.nix75
-rw-r--r--pkgs/servers/monitoring/riemann/default.nix18
-rw-r--r--pkgs/servers/monitoring/sensu/Gemfile11
-rw-r--r--pkgs/servers/monitoring/sensu/Gemfile.lock181
-rw-r--r--pkgs/servers/monitoring/sensu/default.nix29
-rw-r--r--pkgs/servers/monitoring/sensu/gemset.nix484
-rw-r--r--pkgs/servers/monitoring/telegraf/default.nix31
-rw-r--r--pkgs/servers/monitoring/telegraf/deps-1.6.1.nix723
-rw-r--r--pkgs/servers/monitoring/uchiwa/bower-packages.nix25
-rw-r--r--pkgs/servers/monitoring/uchiwa/default.nix50
-rw-r--r--pkgs/servers/monitoring/uchiwa/src.nix4
-rwxr-xr-xpkgs/servers/monitoring/uchiwa/update.sh42
-rw-r--r--pkgs/servers/monitoring/zabbix/2.0.nix11
-rw-r--r--pkgs/servers/monitoring/zabbix/2.2.nix15
-rw-r--r--pkgs/servers/monitoring/zabbix/3.4.nix40
-rw-r--r--pkgs/servers/monitoring/zabbix/default.nix11
-rw-r--r--pkgs/servers/monitoring/zipkin/default.nix26
-rw-r--r--pkgs/servers/mpd/clientlib.nix24
-rw-r--r--pkgs/servers/mpd/default.nix53
-rw-r--r--pkgs/servers/mpd/x86.patch12
-rw-r--r--pkgs/servers/mqtt/mosquitto/default.nix24
-rw-r--r--pkgs/servers/nas/default.nix38
-rw-r--r--pkgs/servers/neard/default.nix15
-rw-r--r--pkgs/servers/news/leafnode/default.nix6
-rw-r--r--pkgs/servers/nextcloud/default.nix24
-rw-r--r--pkgs/servers/nextcloud/news-updater.nix22
-rw-r--r--pkgs/servers/nosql/apache-jena/binary.nix8
-rw-r--r--pkgs/servers/nosql/apache-jena/fuseki-binary.nix41
-rw-r--r--pkgs/servers/nosql/apache-jena/fuseki-binary.upstream4
-rw-r--r--pkgs/servers/nosql/arangodb/default.nix29
-rw-r--r--pkgs/servers/nosql/cassandra/1.2.nix52
-rw-r--r--pkgs/servers/nosql/cassandra/2.0.nix52
-rw-r--r--pkgs/servers/nosql/cassandra/2.1.nix56
-rw-r--r--pkgs/servers/nosql/cassandra/2.2.nix6
-rw-r--r--pkgs/servers/nosql/cassandra/3.0.nix6
-rw-r--r--pkgs/servers/nosql/cassandra/3.11.nix6
-rw-r--r--pkgs/servers/nosql/cassandra/generic.nix71
-rw-r--r--pkgs/servers/nosql/eventstore/default.nix40
-rw-r--r--pkgs/servers/nosql/hyperdex/busybee.nix28
-rw-r--r--pkgs/servers/nosql/hyperdex/default.nix57
-rw-r--r--pkgs/servers/nosql/hyperdex/hyperleveldb.nix20
-rw-r--r--pkgs/servers/nosql/hyperdex/libe.nix19
-rw-r--r--pkgs/servers/nosql/hyperdex/libmacaroons.nix20
-rw-r--r--pkgs/servers/nosql/hyperdex/libpo6.nix19
-rw-r--r--pkgs/servers/nosql/hyperdex/replicant.nix32
-rw-r--r--pkgs/servers/nosql/influxdb/default.nix47
-rw-r--r--pkgs/servers/nosql/influxdb/deps-1.4.1.nix227
-rw-r--r--pkgs/servers/nosql/mongodb/default.nix67
-rw-r--r--pkgs/servers/nosql/mongodb/forget-build-dependencies.patch17
-rw-r--r--pkgs/servers/nosql/neo4j/default.nix29
-rw-r--r--pkgs/servers/nosql/redis/default.nix7
-rw-r--r--pkgs/servers/nosql/rethinkdb/default.nix36
-rw-r--r--pkgs/servers/nosql/riak-cs/2.1.1.nix69
-rw-r--r--pkgs/servers/nosql/riak-cs/stanchion.nix65
-rw-r--r--pkgs/servers/nosql/riak/1.3.1.nix64
-rw-r--r--pkgs/servers/nosql/riak/2.2.0.nix (renamed from pkgs/servers/nosql/riak/2.1.1.nix)22
-rw-r--r--pkgs/servers/nosql/riak/riak-1.3.1.patch64
-rw-r--r--pkgs/servers/nosql/riak/riak-admin-1.3.1.patch52
-rw-r--r--pkgs/servers/nsq/default.nix18
-rw-r--r--pkgs/servers/nsq/deps.nix83
-rw-r--r--pkgs/servers/oauth2_proxy/default.nix25
-rw-r--r--pkgs/servers/oauth2_proxy/deps.nix129
-rw-r--r--pkgs/servers/openafs-client/default.nix57
-rw-r--r--pkgs/servers/openafs/default.nix89
-rw-r--r--pkgs/servers/openafs/module.nix57
-rw-r--r--pkgs/servers/openafs/srcs.nix14
-rw-r--r--pkgs/servers/openafs/tsmbac.patch62
-rw-r--r--pkgs/servers/openpts/bugs.patch12
-rw-r--r--pkgs/servers/openpts/default.nix53
-rw-r--r--pkgs/servers/openpts/ptsc.patch28
-rw-r--r--pkgs/servers/openpts/tboot.patch21
-rw-r--r--pkgs/servers/openpts/zlib.patch12
-rw-r--r--pkgs/servers/openxpki/default.nix10
-rw-r--r--pkgs/servers/osrm-backend/4.5.0-default-profile-path.template.patch13
-rw-r--r--pkgs/servers/osrm-backend/4.5.0-openmp.patch18
-rw-r--r--pkgs/servers/osrm-backend/default.nix25
-rw-r--r--pkgs/servers/owncloud/default.nix79
-rw-r--r--pkgs/servers/p910nd/default.nix10
-rw-r--r--pkgs/servers/pies/default.nix10
-rw-r--r--pkgs/servers/plex/default.nix33
-rw-r--r--pkgs/servers/plexpy/default.nix41
-rw-r--r--pkgs/servers/polipo/default.nix7
-rw-r--r--pkgs/servers/portmap/default.nix45
-rw-r--r--pkgs/servers/portmap/reuse-socket.patch38
-rw-r--r--pkgs/servers/prayer/default.nix17
-rw-r--r--pkgs/servers/ps3netsrv/default.nix29
-rw-r--r--pkgs/servers/pulseaudio/default.nix35
-rw-r--r--pkgs/servers/quagga/default.nix73
-rw-r--r--pkgs/servers/radarr/default.nix31
-rw-r--r--pkgs/servers/radicale/1.x.nix34
-rw-r--r--pkgs/servers/radicale/default.nix41
-rw-r--r--pkgs/servers/radius/default.nix35
-rw-r--r--pkgs/servers/restund/default.nix33
-rw-r--r--pkgs/servers/rippled/default.nix6
-rw-r--r--pkgs/servers/rippled/ripple-rest.nix26
-rw-r--r--pkgs/servers/rpcbind/default.nix29
-rw-r--r--pkgs/servers/rt/default.nix102
-rw-r--r--pkgs/servers/rt/override-generated.patch21
-rw-r--r--pkgs/servers/s6/default.nix44
-rw-r--r--pkgs/servers/sabnzbd/builder.sh16
-rw-r--r--pkgs/servers/sabnzbd/default.nix42
-rw-r--r--pkgs/servers/samba/3.x.nix9
-rw-r--r--pkgs/servers/samba/4.x-fix-ctdb-deps.patch13
-rw-r--r--pkgs/servers/samba/4.x-no-persistent-install-dynconfig.patch15
-rw-r--r--pkgs/servers/samba/4.x-no-persistent-install.patch53
-rw-r--r--pkgs/servers/samba/4.x.nix57
-rw-r--r--pkgs/servers/samba/master.nix29
-rw-r--r--pkgs/servers/samba/patch-source3__libads__kerberos_keytab.c.patch20
-rw-r--r--pkgs/servers/search/elasticsearch/2.x.nix40
-rw-r--r--pkgs/servers/search/elasticsearch/5.x.nix41
-rw-r--r--pkgs/servers/search/elasticsearch/6.x.nix41
-rw-r--r--pkgs/servers/search/elasticsearch/default.nix13
-rw-r--r--pkgs/servers/search/elasticsearch/es-classpath-2.x.patch38
-rw-r--r--pkgs/servers/search/elasticsearch/es-classpath-5.x.patch34
-rw-r--r--pkgs/servers/search/elasticsearch/es-home-2.x.patch31
-rw-r--r--pkgs/servers/search/elasticsearch/es-home-5.x.patch31
-rw-r--r--pkgs/servers/search/elasticsearch/es-home-6.x.patch26
-rw-r--r--pkgs/servers/search/elasticsearch/es-home.patch13
-rw-r--r--pkgs/servers/search/elasticsearch/plugins.nix12
-rw-r--r--pkgs/servers/search/groonga/default.nix42
-rw-r--r--pkgs/servers/search/solr/default.nix4
-rw-r--r--pkgs/servers/search/sphinxsearch/default.nix6
-rw-r--r--pkgs/servers/serf/default.nix24
-rw-r--r--pkgs/servers/serviio/default.nix30
-rw-r--r--pkgs/servers/shairplay/default.nix35
-rw-r--r--pkgs/servers/shairport-sync/default.nix9
-rw-r--r--pkgs/servers/shellinabox/default.nix18
-rw-r--r--pkgs/servers/shishi/default.nix26
-rw-r--r--pkgs/servers/shishi/freebsd-unistd.patch12
-rw-r--r--pkgs/servers/simplehttp2server/default.nix25
-rw-r--r--pkgs/servers/simplehttp2server/deps.nix12
-rw-r--r--pkgs/servers/sip/freeswitch/default.nix30
-rw-r--r--pkgs/servers/sip/sipwitch/default.nix7
-rw-r--r--pkgs/servers/sks/default.nix44
-rw-r--r--pkgs/servers/skydns/default.nix18
-rw-r--r--pkgs/servers/skydns/deps.nix128
-rw-r--r--pkgs/servers/slimserver/default.nix105
-rw-r--r--pkgs/servers/smcroute/default.nix29
-rw-r--r--pkgs/servers/softether/4.18.nix6
-rw-r--r--pkgs/servers/softether/4.20.nix53
-rw-r--r--pkgs/servers/softether/4.25.nix53
-rw-r--r--pkgs/servers/sonarr/default.nix33
-rw-r--r--pkgs/servers/sql/cockroachdb/default.nix44
-rw-r--r--pkgs/servers/sql/mariadb/clang-isfinite.patch17
-rw-r--r--pkgs/servers/sql/mariadb/cmake-includedir.patch11
-rw-r--r--pkgs/servers/sql/mariadb/default.nix301
-rw-r--r--pkgs/servers/sql/mariadb/include-dirs-path.patch13
-rw-r--r--pkgs/servers/sql/mariadb/my_context_asm.patch18
-rw-r--r--pkgs/servers/sql/monetdb/default.nix49
-rw-r--r--pkgs/servers/sql/mysql/5.1.x.nix42
-rw-r--r--pkgs/servers/sql/mysql/5.5.x.nix30
-rw-r--r--pkgs/servers/sql/mysql/5.7.x.nix83
-rw-r--r--pkgs/servers/sql/mysql/jdbc/default.nix12
-rw-r--r--pkgs/servers/sql/oracle-xe/default.nix7
-rw-r--r--pkgs/servers/sql/percona/5.6.x.nix62
-rw-r--r--pkgs/servers/sql/pgbouncer/default.nix20
-rw-r--r--pkgs/servers/sql/pgpool/default.nix8
-rw-r--r--pkgs/servers/sql/pgpool/pgpool-II-3.4.14-glibc-2.26.patch12
-rw-r--r--pkgs/servers/sql/postgresql/cstore_fdw/default.nix32
-rw-r--r--pkgs/servers/sql/postgresql/default.nix98
-rw-r--r--pkgs/servers/sql/postgresql/hardcode-pgxs-path-96.patch14
-rw-r--r--pkgs/servers/sql/postgresql/hardcode-pgxs-path.patch17
-rw-r--r--pkgs/servers/sql/postgresql/jdbc/default.nix28
-rw-r--r--pkgs/servers/sql/postgresql/less-is-more-96.patch12
-rw-r--r--pkgs/servers/sql/postgresql/pg_cron/default.nix31
-rw-r--r--pkgs/servers/sql/postgresql/pg_hll/default.nix31
-rw-r--r--pkgs/servers/sql/postgresql/pg_repack/default.nix35
-rw-r--r--pkgs/servers/sql/postgresql/pg_similarity/default.nix31
-rw-r--r--pkgs/servers/sql/postgresql/pgjwt/default.nix25
-rw-r--r--pkgs/servers/sql/postgresql/pgroonga/default.nix30
-rw-r--r--pkgs/servers/sql/postgresql/pgtap/default.nix32
-rw-r--r--pkgs/servers/sql/postgresql/plv8/default.nix34
-rw-r--r--pkgs/servers/sql/postgresql/psqlodbc/default.nix1
-rw-r--r--pkgs/servers/sql/postgresql/specify_pkglibdir_at_runtime.patch29
-rw-r--r--pkgs/servers/sql/postgresql/timescaledb/default.nix44
-rw-r--r--pkgs/servers/sql/postgresql/topn/default.nix32
-rw-r--r--pkgs/servers/sql/postgresql/tsearch_extras/default.nix29
-rw-r--r--pkgs/servers/sql/sqlite/jdbc/default.nix26
-rw-r--r--pkgs/servers/sql/virtuoso/6.x.nix24
-rw-r--r--pkgs/servers/sql/virtuoso/7.x.nix14
-rw-r--r--pkgs/servers/squid/4.nix39
-rw-r--r--pkgs/servers/squid/default.nix48
-rw-r--r--pkgs/servers/squid/squids.nix67
-rw-r--r--pkgs/servers/sslh/default.nix12
-rw-r--r--pkgs/servers/teleport/default.nix41
-rw-r--r--pkgs/servers/traefik/default.nix39
-rw-r--r--pkgs/servers/trezord/default.nix26
-rw-r--r--pkgs/servers/tt-rss/default.nix25
-rw-r--r--pkgs/servers/tvheadend/default.nix71
-rw-r--r--pkgs/servers/u9fs/default.nix2
-rw-r--r--pkgs/servers/udpt/default.nix52
-rw-r--r--pkgs/servers/uftp/default.nix33
-rw-r--r--pkgs/servers/uhub/default.nix24
-rw-r--r--pkgs/servers/uhub/plugin-dir.patch24
-rw-r--r--pkgs/servers/uhub/systemd.patch164
-rw-r--r--pkgs/servers/ums/default.nix33
-rw-r--r--pkgs/servers/unifi/default.nix73
-rw-r--r--pkgs/servers/uwsgi/default.nix73
-rw-r--r--pkgs/servers/uwsgi/nixos.ini1
-rw-r--r--pkgs/servers/varnish/default.nix64
-rw-r--r--pkgs/servers/varnish/digest.nix31
-rw-r--r--pkgs/servers/varnish/dynamic.nix26
-rw-r--r--pkgs/servers/varnish/geoip.nix31
-rw-r--r--pkgs/servers/varnish/modules.nix29
-rw-r--r--pkgs/servers/varnish/packages.nix22
-rw-r--r--pkgs/servers/varnish/rtstatus.nix21
-rw-r--r--pkgs/servers/web-apps/fileshelter/default.nix30
-rw-r--r--pkgs/servers/web-apps/frab/Gemfile88
-rw-r--r--pkgs/servers/web-apps/frab/Gemfile.lock329
-rw-r--r--pkgs/servers/web-apps/frab/default.nix46
-rw-r--r--pkgs/servers/web-apps/frab/gemset.nix932
-rw-r--r--pkgs/servers/web-apps/matomo/bootstrap.php6
-rw-r--r--pkgs/servers/web-apps/matomo/default.nix60
-rw-r--r--pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch13
-rw-r--r--pkgs/servers/web-apps/morty/default.nix41
-rw-r--r--pkgs/servers/web-apps/morty/deps.nix57
-rw-r--r--pkgs/servers/web-apps/pgpkeyserver-lite/default.nix25
-rw-r--r--pkgs/servers/web-apps/restya-board/default.nix50
-rw-r--r--pkgs/servers/web-apps/restya-board/fix_request-uri.patch12
-rw-r--r--pkgs/servers/web-apps/searx/default.nix47
-rw-r--r--pkgs/servers/web-apps/selfoss/default.nix28
-rw-r--r--pkgs/servers/web-apps/shaarli/default.nix61
-rw-r--r--pkgs/servers/web-apps/shaarli/material-theme.nix35
-rw-r--r--pkgs/servers/web-apps/wallabag/default.nix41
-rw-r--r--pkgs/servers/web-apps/wallabag/wallabag-data.patch26
-rw-r--r--pkgs/servers/web-apps/wordpress/default.nix13
-rw-r--r--pkgs/servers/webmetro/default.nix31
-rw-r--r--pkgs/servers/x11/quartz-wm/default.nix4
-rw-r--r--pkgs/servers/x11/xorg/builder.sh28
-rw-r--r--pkgs/servers/x11/xorg/darwin/0001-XQuartz-GLX-Use-__glXEnableExtension-to-build-extens.patch78
-rw-r--r--pkgs/servers/x11/xorg/darwin/0002-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch41
-rw-r--r--pkgs/servers/x11/xorg/darwin/0003-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch165
-rw-r--r--pkgs/servers/x11/xorg/darwin/0004-Use-old-miTrapezoids-and-miTriangles-routines.patch297
-rw-r--r--pkgs/servers/x11/xorg/darwin/0005-fb-Revert-fb-changes-that-broke-XQuartz.patch316
-rw-r--r--pkgs/servers/x11/xorg/darwin/0006-fb-Revert-fb-changes-that-broke-XQuartz.patch243
-rw-r--r--pkgs/servers/x11/xorg/darwin/bundle_main.patch118
-rw-r--r--pkgs/servers/x11/xorg/darwin/function-pointer-test.patch46
-rw-r--r--pkgs/servers/x11/xorg/darwin/private-extern.patch12
-rw-r--r--pkgs/servers/x11/xorg/darwin/stub.patch80
-rw-r--r--pkgs/servers/x11/xorg/default.nix1372
-rw-r--r--pkgs/servers/x11/xorg/extra.list9
-rw-r--r--pkgs/servers/x11/xorg/fix_segfault.patch63
-rwxr-xr-xpkgs/servers/x11/xorg/generate-expr-from-tarballs.pl22
-rw-r--r--pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch13
-rw-r--r--pkgs/servers/x11/xorg/old.list4
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix434
-rw-r--r--pkgs/servers/x11/xorg/replacements.nix21
-rw-r--r--pkgs/servers/x11/xorg/tarballs-7.7.list111
-rw-r--r--pkgs/servers/x11/xorg/unichrome/configure.patch37
-rw-r--r--pkgs/servers/x11/xorg/unichrome/default.nix32
-rw-r--r--pkgs/servers/x11/xorg/xcb-util-xrm.nix23
-rw-r--r--pkgs/servers/x11/xorg/xkeyboard-config-eo.patch69
-rw-r--r--pkgs/servers/x11/xorg/xorgserver-xkbcomp-path.patch15
-rw-r--r--pkgs/servers/x11/xorg/xwayland.nix8
-rwxr-xr-xpkgs/servers/x11/xquartz/X112
-rw-r--r--pkgs/servers/x11/xquartz/default.nix31
-rwxr-xr-xpkgs/servers/x11/xquartz/font_cache4
-rwxr-xr-xpkgs/servers/x11/xquartz/startx2
-rw-r--r--pkgs/servers/x11/xquartz/system-fonts.nix4
-rw-r--r--pkgs/servers/xinetd/default.nix10
-rw-r--r--pkgs/servers/xmpp/biboumi/catch.patch30
-rw-r--r--pkgs/servers/xmpp/biboumi/default.nix43
-rw-r--r--pkgs/servers/xmpp/ejabberd/default.nix127
-rw-r--r--pkgs/servers/xmpp/openfire/default.nix5
-rw-r--r--pkgs/servers/xmpp/prosody/default.nix47
-rw-r--r--pkgs/servers/xmpp/pyIRCt/default.nix43
-rw-r--r--pkgs/servers/xmpp/pyMAILt/default.nix37
-rw-r--r--pkgs/servers/zookeeper/default.nix82
577 files changed, 21977 insertions, 8736 deletions
diff --git a/pkgs/servers/amqp/qpid-cpp/default.nix b/pkgs/servers/amqp/qpid-cpp/default.nix
index 410bd23eb30e..8446578507d8 100644
--- a/pkgs/servers/amqp/qpid-cpp/default.nix
+++ b/pkgs/servers/amqp/qpid-cpp/default.nix
@@ -1,31 +1,54 @@
-{ stdenv, fetchurl, cmake, python, boost, libuuid, ruby }:
+{ stdenv, fetchurl, cmake, python2, boost, libuuid, ruby, buildEnv, buildPythonPackage, qpid-python }:
 
-stdenv.mkDerivation rec {
+let
   name = "qpid-cpp-${version}";
-
-  version = "0.34";
+  version = "1.37.0";
 
   src = fetchurl {
     url = "mirror://apache/qpid/cpp/${version}/${name}.tar.gz";
-    sha256 = "07ibwvw5lm7xabv32zai5x03r7l9mxm0zk7h9lbfkzmav0f41w0w";
+    sha256 = "1s4hyi867i0lqn81c1crrk6fga1gmsv61675vjv5v41skz56lrsb";
   };
 
-  buildInputs = [ cmake python boost libuuid ruby ];
-
-  # the subdir managementgen wants to install python stuff in ${python} and
-  # the installation tries to create some folders in /var
-  patchPhase = ''
-    sed -i '/managementgen/d' CMakeLists.txt
-    sed -i '/ENV/d' src/CMakeLists.txt
-  '';
-
-  meta = {
+  meta = with stdenv.lib; {
     homepage = http://qpid.apache.org;
     repositories.git = git://git.apache.org/qpid.git;
     repositories.svn = http://svn.apache.org/repos/asf/qpid;
     description = "An AMQP message broker and a C++ messaging API";
-    license = stdenv.lib.licenses.asl20;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.page ];
+    license = licenses.asl20;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ cpages ma27 ];
+  };
+
+  qpid-cpp = stdenv.mkDerivation {
+    inherit src meta name;
+
+    nativeBuildInputs = [ cmake ];
+    buildInputs = [ boost libuuid ruby python2 ];
+
+    # the subdir managementgen wants to install python stuff in ${python} and
+    # the installation tries to create some folders in /var
+    postPatch = ''
+      sed -i '/managementgen/d' CMakeLists.txt
+      sed -i '/ENV/d' src/CMakeLists.txt
+      sed -i '/management/d' CMakeLists.txt
+    '';
+
+    NIX_CFLAGS_COMPILE = [
+      "-Wno-error=deprecated-declarations"
+      "-Wno-error=int-in-bool-context"
+      "-Wno-error=maybe-uninitialized"
+      "-Wno-error=unused-function"
+    ];
+  };
+
+  python-frontend = buildPythonPackage {
+    inherit name meta src;
+
+    sourceRoot = "${name}/management/python";
+
+    propagatedBuildInputs = [ qpid-python ];
   };
+in buildEnv {
+  name = "${name}-env";
+  paths = [ qpid-cpp python-frontend ];
 }
diff --git a/pkgs/servers/amqp/rabbitmq-server/default.nix b/pkgs/servers/amqp/rabbitmq-server/default.nix
index 3e8ec09a0b05..4cc187846d0d 100644
--- a/pkgs/servers/amqp/rabbitmq-server/default.nix
+++ b/pkgs/servers/amqp/rabbitmq-server/default.nix
@@ -1,43 +1,67 @@
-{ stdenv, fetchurl, erlang, python, libxml2, libxslt, xmlto
-, docbook_xml_dtd_45, docbook_xsl, zip, unzip }:
+{ stdenv, fetchurl, runCommand
+, erlang, python, libxml2, libxslt, xmlto
+, docbook_xml_dtd_45, docbook_xsl, zip, unzip, rsync
+, AppKit, Carbon, Cocoa
+, getconf
+}:
 
 stdenv.mkDerivation rec {
   name = "rabbitmq-server-${version}";
-
-  version = "3.5.6";
+  version = "3.6.15";
 
   src = fetchurl {
-    url = "http://www.rabbitmq.com/releases/rabbitmq-server/v${version}/${name}.tar.gz";
-    sha256 = "07v7c6ippngkq269jmrf3gji389czcmz6phc3qwxn4j14cri9gi4";
+    url = "https://www.rabbitmq.com/releases/rabbitmq-server/v${version}/${name}.tar.xz";
+    sha256 = "1zdmil657mhjmd20jv47s5dfpj2liqwvyg0zv2ky3akanfpgj98y";
   };
 
   buildInputs =
-    [ erlang python libxml2 libxslt xmlto docbook_xml_dtd_45 docbook_xsl zip unzip ];
+    [ erlang python libxml2 libxslt xmlto docbook_xml_dtd_45 docbook_xsl zip unzip rsync ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ AppKit Carbon Cocoa ];
 
-  preBuild =
-    ''
-      # Fix the "/usr/bin/env" in "calculate-relative".
-      patchShebangs .
-    '';
+  outputs = [ "out" "man" "doc" ];
 
-  installFlags = "TARGET_DIR=$(out)/libexec/rabbitmq SBIN_DIR=$(out)/sbin MAN_DIR=$(out)/share/man DOC_INSTALL_DIR=$(out)/share/doc";
+  postPatch = with stdenv.lib; ''
+    # patch the path to getconf
+    substituteInPlace deps/rabbit_common/src/vm_memory_monitor.erl \
+      --replace "getconf PAGESIZE" "${getconf}/bin/getconf PAGESIZE"
+  '';
 
-  preInstall =
-    ''
-      sed -i \
-        -e 's|SYS_PREFIX=|SYS_PREFIX=''${SYS_PREFIX-''${HOME}/.rabbitmq/${version}}|' \
-        -e 's|CONF_ENV_FILE=''${SYS_PREFIX}\(.*\)|CONF_ENV_FILE=\1|' \
-        scripts/rabbitmq-defaults
-    '';
+  preBuild = ''
+    # Fix the "/usr/bin/env" in "calculate-relative".
+    patchShebangs .
+  '';
+
+  installFlags = "PREFIX=$(out) RMQ_ERLAPP_DIR=$(out)";
+  installTargets = "install install-man";
+
+  postInstall = ''
+    echo 'PATH=${erlang}/bin:''${PATH:+:}$PATH' >> $out/sbin/rabbitmq-env
 
-  postInstall =
-    ''
-      echo 'PATH=${erlang}/bin:${PATH:+:}$PATH' >> $out/sbin/rabbitmq-env
-    ''; # */
+    # we know exactly where rabbitmq is gonna be,
+    # so we patch that into the env-script
+    substituteInPlace $out/sbin/rabbitmq-env \
+      --replace 'RABBITMQ_SCRIPTS_DIR=`dirname $SCRIPT_PATH`' \
+                "RABBITMQ_SCRIPTS_DIR=$out/sbin"
+
+    # there’s a few stray files that belong into share
+    mkdir -p $doc/share/doc/rabbitmq-server
+    mv $out/LICENSE* $doc/share/doc/rabbitmq-server
+
+    # and an unecessarily copied INSTALL file
+    rm $out/INSTALL
+
+    # patched into a source file above;
+    # needs to be explicitely passed to not be stripped by fixup
+    mkdir -p $out/nix-support
+    echo "${getconf}" > $out/nix-support/dont-strip-getconf
+
+    '';
 
   meta = {
     homepage = http://www.rabbitmq.com/;
     description = "An implementation of the AMQP messaging protocol";
+    license = stdenv.lib.licenses.mpl11;
     platforms = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ Profpatsch ];
   };
 }
diff --git a/pkgs/servers/apache-kafka/default.nix b/pkgs/servers/apache-kafka/default.nix
index 06f8c5130633..fd9c48f3469e 100755..100644
--- a/pkgs/servers/apache-kafka/default.nix
+++ b/pkgs/servers/apache-kafka/default.nix
@@ -1,18 +1,45 @@
-{ stdenv, fetchurl, jre, makeWrapper, bash }:
+{ stdenv, fetchurl, jre, makeWrapper, bash,
+  majorVersion ? "1.0" }:
 
 let
-  kafkaVersion = "0.8.2.1";
-  scalaVersion = "2.10";
-
+  versionMap = {
+    "0.9" = {
+      kafkaVersion = "0.9.0.1";
+      scalaVersion = "2.11";
+      sha256 = "0ykcjv5dz9i5bws9my2d60pww1g9v2p2nqr67h0i2xrjm7az8a6v";
+    };
+    "0.10" = {
+      kafkaVersion = "0.10.2.1";
+      scalaVersion = "2.12";
+      sha256 = "0iszr6r0n9yjgq7kcp1hf00fg754m86gs4jzqc18542an94b88z5";
+    };
+    "0.11" = {
+      kafkaVersion = "0.11.0.1";
+      scalaVersion = "2.12";
+      sha256 = "1wj639h95aq5n132fq1rbyzqh5rsa4mlhbg3c5mszqglnzdz4xn7";
+    };
+    "1.0" = {
+      kafkaVersion = "1.0.1";
+      scalaVersion = "2.12";
+      sha256 = "1fxn6i0kanwksj1dhcnlni0cn542k50wdg8jkwhfmf4qq8yfl90m";
+    };
+    "1.1" = {
+      kafkaVersion = "1.1.0";
+      scalaVersion = "2.12";
+      sha256 = "04idhsr6pbkb0xkx38faxv2pn5nkjcflz6wl4s3ka82h1fbq74j9";
+    };
+  };
 in
 
+with versionMap.${majorVersion};
+
 stdenv.mkDerivation rec {
   version = "${scalaVersion}-${kafkaVersion}";
   name = "apache-kafka-${version}";
 
   src = fetchurl {
     url = "mirror://apache/kafka/${kafkaVersion}/kafka_${version}.tgz";
-    sha256 = "1klri23fjxbzv7rmi05vcqqfpy7dzi1spn2084y1dxsi1ypfkvc9";
+    inherit sha256;
   };
 
   buildInputs = [ jre makeWrapper bash ];
@@ -23,6 +50,7 @@ stdenv.mkDerivation rec {
 
     mkdir -p $out/bin
     cp bin/kafka* $out/bin
+    cp bin/connect* $out/bin
 
     # allow us the specify logging directory using env
     substituteInPlace $out/bin/kafka-run-class.sh \
@@ -38,7 +66,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = "http://kafka.apache.org";
+    homepage = http://kafka.apache.org;
     description = "A high-throughput distributed messaging system";
     license = licenses.asl20;
     maintainers = [ maintainers.ragge ];
diff --git a/pkgs/servers/apcupsd/default.nix b/pkgs/servers/apcupsd/default.nix
index e60f6173c0f7..bec61d460a7a 100644
--- a/pkgs/servers/apcupsd/default.nix
+++ b/pkgs/servers/apcupsd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils, nettools, man
+{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils, wall, hostname, man
 , enableCgiScripts ? true, gd
 }:
 
@@ -6,20 +6,26 @@ assert enableCgiScripts -> gd != null;
 
 stdenv.mkDerivation rec {
   pname = "apcupsd";
-  name = "${pname}-3.14.13";
+  name = "${pname}-3.14.14";
 
   src = fetchurl {
     url = "mirror://sourceforge/${pname}/${name}.tar.gz";
-    sha256 = "1y83bly5bgpjbfaxxwmdk2mndbi4cw0svq5z9n6byj043phbvv2p";
+    sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
   };
 
-  buildInputs = [ pkgconfig utillinux man ] ++ stdenv.lib.optional enableCgiScripts gd;
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ utillinux man ] ++ stdenv.lib.optional enableCgiScripts gd;
+
+  prePatch = ''
+    sed -e "s,\$(INSTALL_PROGRAM) \$(STRIP),\$(INSTALL_PROGRAM)," \
+        -i ./src/apcagent/Makefile ./autoconf/targets.mak
+  '';
 
   # ./configure ignores --prefix, so we must specify some paths manually
   # There is no real reason for a bin/sbin split, so just use bin.
   preConfigure = ''
     export ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown
-    export ac_cv_path_WALL=${utillinux}/bin/wall
+    export ac_cv_path_WALL=${wall}/bin/wall
     sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
     export configureFlags="\
         --bindir=$out/bin \
@@ -40,8 +46,8 @@ stdenv.mkDerivation rec {
 
   postInstall = ''
     for file in "$out"/etc/apcupsd/*; do
-        sed -i -e 's|^WALL=.*|WALL="${utillinux}/bin/wall"|g' \
-               -e 's|^HOSTNAME=.*|HOSTNAME=`${nettools}/bin/hostname`|g' \
+        sed -i -e 's|^WALL=.*|WALL="${wall}/bin/wall"|g' \
+               -e 's|^HOSTNAME=.*|HOSTNAME=`${hostname}/bin/hostname`|g' \
                "$file"
     done
   '';
diff --git a/pkgs/servers/asterisk/default.nix b/pkgs/servers/asterisk/default.nix
index c37292d385f5..10ffa918e5bd 100644
--- a/pkgs/servers/asterisk/default.nix
+++ b/pkgs/servers/asterisk/default.nix
@@ -1,61 +1,124 @@
-{ stdenv, fetchurl, fetchgit, jansson, libxml2, libxslt, ncurses, openssl, sqlite, utillinux }:
+{ stdenv, pkgs, lib, fetchurl, fetchgit, fetchsvn, fetchpatch,
+  jansson, libxml2, libxslt, ncurses, openssl, sqlite,
+  utillinux, dmidecode, libuuid, newt,
+  lua, speex,
+  srtp, wget, curl
+}:
 
-stdenv.mkDerivation rec {
-  name = "asterisk-${version}";
-  version = "13.3.2";
+let
+  common = {version, sha256, externals}: stdenv.mkDerivation rec {
+    inherit version;
+    name = "asterisk-${version}";
 
-  src = fetchurl {
-    url = "http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-${version}.tar.gz";
-    sha256 = "19dafvy6ch4v8949bjim64fff456k78156m30dy2yvhm94m5k1zz";
+    buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid newt lua speex srtp wget curl ];
+
+    patches = [
+      # We want the Makefile to install the default /var skeleton
+      # under ${out}/var but we also want to use /var at runtime.
+      # This patch changes the runtime behavior to look for state
+      # directories in /var rather than ${out}/var.
+      ./runtime-vardirs.patch
+    ];
+
+    # Disable MD5 verification for pjsip
+    postPatch = ''
+      sed -i 's|$(verify_tarball)|true|' third-party/pjproject/Makefile
+    '';
+
+    src = fetchurl {
+      url = "http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-${version}.tar.gz";
+      inherit sha256;
+    };
+
+    # The default libdir is $PREFIX/usr/lib, which causes problems when paths
+    # compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
+
+    # Copy in externals to avoid them being downloaded;
+    # they have to be copied, because the modification date is checked.
+    # If you are getting a permission denied error on this dir,
+    # you're likely missing an automatically downloaded dependency
+    preConfigure = ''
+      mkdir externals_cache
+    '' + lib.concatStringsSep "\n"
+        (lib.mapAttrsToList (dst: src: "cp -r --no-preserve=mode ${src} ${dst}") externals) + ''
+
+      chmod -w externals_cache
+    '';
+    configureFlags = [
+      "--libdir=\${out}/lib"
+      "--with-lua=${lua}/lib"
+      "--with-pjproject-bundled"
+      "--with-externals-cache=$(PWD)/externals_cache"
+    ];
+
+    preBuild = ''
+      make menuselect.makeopts
+      substituteInPlace menuselect.makeopts --replace 'format_mp3 ' ""
+    '';
+
+    postInstall = ''
+      # Install sample configuration files for this version of Asterisk
+      make samples
+    '';
+
+    meta = with stdenv.lib; {
+      description = "Software implementation of a telephone private branch exchange (PBX)";
+      homepage = http://www.asterisk.org/;
+      license = licenses.gpl2;
+      maintainers = with maintainers; [ auntie DerTim1 yorickvp ];
+    };
+  };
+
+  pjproject-27 = fetchurl {
+    url = http://www.pjsip.org/release/2.7.1/pjproject-2.7.1.tar.bz2;
+    sha256 = "09ii5hgl5s7grx4fiimcl3s77i385h7b3kwpfa2q0arbl1ibryjr";
   };
 
-  # Note that these sounds are included with the release tarball. They are
-  # provided here verbatim for the convenience of anyone wanting to build
-  # Asterisk from other sources.
-  coreSounds = fetchurl {
-    url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.4.26.tar.gz;
-    sha256 = "2300e3ed1d2ded6808a30a6ba71191e7784710613a5431afebbd0162eb4d5d73";
+  mp3-202 = fetchsvn {
+    url = http://svn.digium.com/svn/thirdparty/mp3/trunk;
+    rev = 202;
+    sha256 = "1s9idx2miwk178sa731ig9r4fzx4gy1q8xazfqyd7q4lfd70s1cy";
   };
-  mohSounds = fetchurl {
-    url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz;
-    sha256 = "449fb810d16502c3052fedf02f7e77b36206ac5a145f3dacf4177843a2fcb538";
+
+in
+{
+
+  asterisk-lts = common {
+    version = "13.20.0";
+    sha256 = "a3d6d953f844867ea11e0be22ee6225049cd4f5870df6ab23454623bcfbc94d5";
+    externals = {
+      "externals_cache/pjproject-2.7.1.tar.bz2" = pjproject-27;
+      "addons/mp3" = mp3-202;
+    };
   };
-  # TODO: Sounds for other languages could be added here
-
-  buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux ];
-
-  patches = [
-    # Disable downloading of sound files (we will fetch them
-    # ourselves if needed).
-    ./disable-download.patch
-
-    # We want the Makefile to install the default /var skeleton
-    # under ${out}/var but we also want to use /var at runtime.
-    # This patch changes the runtime behavior to look for state
-    # directories in /var rather than ${out}/var.
-    ./runtime-vardirs.patch
-  ];
-
-  # Use the following preConfigure section when building Asterisk from sources
-  # other than the release tarball.
-#   preConfigure = ''
-#     ln -s ${coreSounds} sounds/asterisk-core-sounds-en-gsm-1.4.26.tar.gz
-#     ln -s ${mohSounds} sounds/asterisk-moh-opsound-wav-2.03.tar.gz
-#   '';
-
-  # The default libdir is $PREFIX/usr/lib, which causes problems when paths
-  # compiled into Asterisk expect ${out}/usr/lib rather than ${out}/lib.
-  configureFlags = "--libdir=\${out}/lib";
-
-  postInstall = ''
-    # Install sample configuration files for this version of Asterisk
-    make samples
-  '';
-
-  meta = with stdenv.lib; {
-    description = "Software implementation of a telephone private branch exchange (PBX)";
-    homepage = http://www.asterisk.org/;
-    license = licenses.gpl2;
-    maintainers = with maintainers; [ auntie ];
+
+  asterisk-stable = common {
+    version = "15.3.0";
+    sha256 = "f424f89f23b72f267ff9baab82d449bebbbf00c54e54fcd06b8fca13788b012c";
+    externals = {
+      "externals_cache/pjproject-2.7.1.tar.bz2" = pjproject-27;
+      "addons/mp3" = mp3-202;
+    };
   };
+
+  # asterisk-git = common {
+  #   version = "15-pre";
+  #   sha256 = "...";
+  #   externals = {
+  #    "externals_cache/pjproject-2.5.5.tar.bz2" = pjproject-255;
+      # Note that these sounds are included with the release tarball. They are
+      # provided here verbatim for the convenience of anyone wanting to build
+      # Asterisk from other sources. Include in externals.
+      # "sounds/asterisk-core-sounds-en-gsm-1.5.tar.gz" = fetchurl {
+      #   url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-gsm-1.5.tar.gz;
+      #   sha256 = "01xzbg7xy0c5zg7sixjw5025pvr4z64kfzi9zvx19im0w331h4cd";
+      # };
+      # "sounds/asterisk-moh-opsound-wav-2.03.tar.gz" = fetchurl {
+      #   url = http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-wav-2.03.tar.gz;
+      #   sha256 = "449fb810d16502c3052fedf02f7e77b36206ac5a145f3dacf4177843a2fcb538";
+      # };
+      # TODO: Sounds for other languages could be added here
+    # }
+  # }.overrideDerivation (_: {src = fetchgit {...}})
+
 }
diff --git a/pkgs/servers/asterisk/disable-download.patch b/pkgs/servers/asterisk/disable-download.patch
deleted file mode 100644
index 8b15ecdfaaa3..000000000000
--- a/pkgs/servers/asterisk/disable-download.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ruN asterisk-13.2.0/sounds/Makefile asterisk-13.2.0-patched/sounds/Makefile
---- asterisk-13.2.0/sounds/Makefile	2014-09-09 14:01:11.000000000 -0600
-+++ asterisk-13.2.0-patched/sounds/Makefile	2015-03-31 16:12:00.549133670 -0600
-@@ -89,7 +89,7 @@
- 	  ) && touch "$(1)$(if $(3),/$(3),)/$$@"; \
- 	fi
- 
--asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz: have_download
-+asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz:
- ifneq ($(SOUNDS_CACHE_DIR),)
- 	$(CMD_PREFIX) \
- 	if test ! -f "$(1)$(if $(3),/$(3),)/.$$(subst .tar.gz,,$$@)"; then \
diff --git a/pkgs/servers/asterisk/runtime-vardirs.patch b/pkgs/servers/asterisk/runtime-vardirs.patch
index dfc00186d136..17959bac9a07 100644
--- a/pkgs/servers/asterisk/runtime-vardirs.patch
+++ b/pkgs/servers/asterisk/runtime-vardirs.patch
@@ -1,6 +1,6 @@
-diff -rupN asterisk-13.3.2/build_tools/make_defaults_h asterisk-13.3.2-patched/build_tools/make_defaults_h
---- asterisk-13.3.2/build_tools/make_defaults_h	2012-01-30 14:21:16.000000000 -0700
-+++ asterisk-13.3.2-patched/build_tools/make_defaults_h	2015-04-15 19:07:46.760351155 -0600
+diff -rupN asterisk-14.1.2/build_tools/make_defaults_h asterisk-14.1.2-patched/build_tools/make_defaults_h
+--- asterisk-14.1.2/build_tools/make_defaults_h	2016-11-10 20:43:02.000000000 +0100
++++ asterisk-14.1.2-patched/build_tools/make_defaults_h	2016-11-16 10:09:04.189625495 +0100
 @@ -1,4 +1,13 @@
  #!/bin/sh
 +
diff --git a/pkgs/servers/atlassian/confluence.nix b/pkgs/servers/atlassian/confluence.nix
new file mode 100644
index 000000000000..c3427b8029e5
--- /dev/null
+++ b/pkgs/servers/atlassian/confluence.nix
@@ -0,0 +1,46 @@
+{ stdenv, lib, fetchurl
+, enableSSO ? false
+, crowdProperties ? null
+}:
+
+stdenv.mkDerivation rec {
+  name = "atlassian-confluence-${version}";
+  version = "6.8.0";
+
+  src = fetchurl {
+    url = "https://www.atlassian.com/software/confluence/downloads/binary/${name}.tar.gz";
+    sha256 = "07awdbkjxkk4rbnpbb5xfjp4125c33bwxncmydlgzgk5fzy6dg2w";
+  };
+
+  phases = [ "unpackPhase" "buildPhase" "installPhase" ];
+
+  buildPhase = ''
+    echo "confluence.home=/run/confluence/home" > confluence/WEB-INF/classes/confluence-init.properties
+    mv conf/server.xml conf/server.xml.dist
+    ln -sf /run/confluence/home/deploy conf/Standalone
+    ln -sf /run/confluence/server.xml conf/server.xml
+    rm -r logs; ln -sf /run/confluence/logs/ .
+    rm -r work; ln -sf /run/confluence/work/ .
+    rm -r temp; ln -sf /run/confluence/temp/ .
+  '' + lib.optionalString enableSSO ''
+    substituteInPlace confluence/WEB-INF/classes/seraph-config.xml \
+      --replace com.atlassian.confluence.user.ConfluenceAuthenticator\
+                com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator
+  '' + lib.optionalString (crowdProperties != null) ''
+    cat <<EOF > confluence/WEB-INF/classes/crowd.properties
+    ${crowdProperties}
+    EOF
+  '';
+
+  installPhase = ''
+    cp -rva . $out
+    patchShebangs $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Team collaboration software written in Java and mainly used in corporate environments";
+    homepage = https://www.atlassian.com/software/confluence;
+    license = licenses.unfree;
+    maintainers = with maintainers; [ fpletz globin ];
+  };
+}
diff --git a/pkgs/servers/atlassian/crowd.nix b/pkgs/servers/atlassian/crowd.nix
new file mode 100644
index 000000000000..4989c3a417a2
--- /dev/null
+++ b/pkgs/servers/atlassian/crowd.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchurl, home ? "/var/lib/crowd"
+, port ? 8092, proxyUrl ? null, openidPassword ? "WILL_NEVER_BE_SET" }:
+
+stdenv.mkDerivation rec {
+  name = "atlassian-crowd-${version}";
+  version = "3.1.2";
+
+  src = fetchurl {
+    url = "https://www.atlassian.com/software/crowd/downloads/binary/${name}.tar.gz";
+    sha256 = "0pnl0zl38827ckgxh4y1mnq3lr7bvd7v3ysdxxv3nfr5zya4xgki";
+  };
+
+  phases = [ "unpackPhase" "buildPhase" "installPhase" "fixupPhase" ];
+
+  buildPhase = ''
+    mv apache-tomcat/conf/server.xml apache-tomcat/conf/server.xml.dist
+    ln -s /run/atlassian-crowd/server.xml apache-tomcat/conf/server.xml
+
+    rm -rf apache-tomcat/work
+    ln -s /run/atlassian-crowd/work apache-tomcat/work
+
+    ln -s /run/atlassian-crowd/database database
+
+    substituteInPlace apache-tomcat/bin/startup.sh --replace start run
+
+    echo "crowd.home=${home}" > crowd-webapp/WEB-INF/classes/crowd-init.properties
+    substituteInPlace build.properties \
+      --replace "openidserver.url=http://localhost:8095/openidserver" \
+                "openidserver.url=http://localhost:${toString port}/openidserver"
+    substituteInPlace crowd-openidserver-webapp/WEB-INF/classes/crowd.properties \
+      --replace "http://localhost:8095/" \
+                "http://localhost:${toString port}/"
+    sed -r -i crowd-openidserver-webapp/WEB-INF/classes/crowd.properties \
+      -e 's,application.password\s+password,application.password ${openidPassword},'
+  '' + stdenv.lib.optionalString (proxyUrl != null) ''
+    sed -i crowd-openidserver-webapp/WEB-INF/classes/crowd.properties \
+      -e 's,http://localhost:${toString port}/openidserver,${proxyUrl}/openidserver,'
+  '';
+
+  installPhase = ''
+    cp -rva . $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Single sign-on and identity management tool";
+    homepage = https://www.atlassian.com/software/crowd;
+    license = licenses.unfree;
+    maintainers = with maintainers; [ fpletz globin ];
+  };
+}
diff --git a/pkgs/servers/atlassian/jira.nix b/pkgs/servers/atlassian/jira.nix
new file mode 100644
index 000000000000..01eb808c1082
--- /dev/null
+++ b/pkgs/servers/atlassian/jira.nix
@@ -0,0 +1,43 @@
+{ stdenv, lib, fetchurl
+, enableSSO ? false
+, crowdProperties ? null
+}:
+
+stdenv.mkDerivation rec {
+  name = "atlassian-jira-${version}";
+  version = "7.9.2";
+
+  src = fetchurl {
+    url = "https://downloads.atlassian.com/software/jira/downloads/atlassian-jira-software-${version}.tar.gz";
+    sha256 = "05976h6033v2w7d05qnigxmsrm33bg7gmgyzpvis8910fkxrhvhh";
+  };
+
+  phases = [ "unpackPhase" "buildPhase" "installPhase" "fixupPhase" ];
+
+  buildPhase = ''
+    mv conf/server.xml conf/server.xml.dist
+    ln -sf /run/atlassian-jira/server.xml conf/server.xml
+    rm -r logs; ln -sf /run/atlassian-jira/logs/ .
+    rm -r work; ln -sf /run/atlassian-jira/work/ .
+    rm -r temp; ln -sf /run/atlassian-jira/temp/ .
+  '' + lib.optionalString enableSSO ''
+    substituteInPlace atlassian-jira/WEB-INF/classes/seraph-config.xml \
+      --replace com.atlassian.jira.security.login.JiraSeraphAuthenticator \
+                com.atlassian.jira.security.login.SSOSeraphAuthenticator
+  '' + lib.optionalString (crowdProperties != null) ''
+    cat <<EOF > atlassian-jira/WEB-INF/classes/crowd.properties
+    ${crowdProperties}
+    EOF
+  '';
+
+  installPhase = ''
+    cp -rva . $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Proprietary issue tracking product, also providing project management functions";
+    homepage = https://www.atlassian.com/software/jira;
+    license = licenses.unfree;
+    maintainers = with maintainers; [ fpletz globin ];
+  };
+}
diff --git a/pkgs/servers/beanstalkd/default.nix b/pkgs/servers/beanstalkd/default.nix
index cea7ca0b337f..ef4621fb9a65 100644
--- a/pkgs/servers/beanstalkd/default.nix
+++ b/pkgs/servers/beanstalkd/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
     sha256 = "0n9dlmiddcfl7i0f1lwfhqiwyvf26493fxfcmn8jm30nbqciwfwj";
   };
 
+  hardeningDisable = [ "fortify" ];
+
   meta = with stdenv.lib; {
     homepage = http://kr.github.io/beanstalkd/;
     description = "A simple, fast work queue";
diff --git a/pkgs/servers/bird/default.nix b/pkgs/servers/bird/default.nix
index c13ad64fca3f..94bd92abb4f8 100644
--- a/pkgs/servers/bird/default.nix
+++ b/pkgs/servers/bird/default.nix
@@ -1,28 +1,54 @@
-{ stdenv, fetchurl, flex, bison, readline }:
+{ lib, stdenv, fetchurl, flex, bison, readline }:
 
-stdenv.mkDerivation rec {
-  name = "bird-1.4.5";
+with lib;
 
-  src = fetchurl {
-    url = "ftp://bird.network.cz/pub/bird/${name}.tar.gz";
-    sha256 = "1z4z7zmx3054zxi4q6a7095s267mw8ky628gir2n5xy5ch65yj7z";
-  };
+let
+
+  generic = { version, sha256, enableIPv6 ? false }:
+    stdenv.mkDerivation rec {
+      name = "bird-${version}";
+
+      src = fetchurl {
+        inherit sha256;
+        url = "ftp://bird.network.cz/pub/bird/${name}.tar.gz";
+      };
+
+      nativeBuildInputs = [ flex bison ];
+      buildInputs = [ readline ];
+
+      patches = [
+        (./. + (builtins.toPath "/dont-create-sysconfdir-${builtins.substring 0 1 version}.patch"))
+      ];
 
-  buildInputs = [ flex bison readline ];
+      configureFlags = [
+        "--localstatedir=/var"
+      ] ++ optional enableIPv6 "--enable-ipv6";
 
-  patches = [
-    ./dont-create-sysconfdir.patch
-  ];
+      meta = {
+        description = "BIRD Internet Routing Daemon";
+        homepage = http://bird.network.cz;
+        license = licenses.gpl2Plus;
+        maintainers = with maintainers; [ viric fpletz ];
+        platforms = platforms.linux;
+      };
+    };
 
-  configureFlags = [
-    "--localstatedir /var"
-  ];
+in
+
+{
+  bird = generic {
+    version = "1.6.3";
+    sha256 = "0z3yrxqb0p7f8b7r2gk4mvrwfzk45zx7yr9aifbvba1vgksiri9r";
+  };
+
+  bird6 = generic {
+    version = "1.6.3";
+    sha256 = "0z3yrxqb0p7f8b7r2gk4mvrwfzk45zx7yr9aifbvba1vgksiri9r";
+    enableIPv6 = true;
+  };
 
-  meta = {
-    description = "BIRD Internet Routing Daemon";
-    homepage = http://bird.network.cz;
-    license = stdenv.lib.licenses.gpl2Plus;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms  = stdenv.lib.platforms.linux;
+  bird2 = generic {
+    version = "2.0.2";
+    sha256 = "03s8hcl761y3489j1krarm3r3iy5qid26508i91yvy38ypb92pq3";
   };
 }
diff --git a/pkgs/servers/bird/dont-create-sysconfdir.patch b/pkgs/servers/bird/dont-create-sysconfdir-1.patch
index 0a11c8a2a8d8..0a11c8a2a8d8 100644
--- a/pkgs/servers/bird/dont-create-sysconfdir.patch
+++ b/pkgs/servers/bird/dont-create-sysconfdir-1.patch
diff --git a/pkgs/servers/bird/dont-create-sysconfdir-2.patch b/pkgs/servers/bird/dont-create-sysconfdir-2.patch
new file mode 100644
index 000000000000..fd86da8a1298
--- /dev/null
+++ b/pkgs/servers/bird/dont-create-sysconfdir-2.patch
@@ -0,0 +1,13 @@
+diff --git a/Makefile.in b/Makefile.in
+index fdd5e6c..45f81a1 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -165,7 +165,7 @@ tags:
+ # Install
+ 
+ install: all
+-	$(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@
++	$(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir)
+ 	$(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird
+ 	$(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl
+ 	if test -n "@CLIENT@" ; then								\
diff --git a/pkgs/servers/brickd/default.nix b/pkgs/servers/brickd/default.nix
index a99c8c5a6f95..4b71aaeca3ad 100644
--- a/pkgs/servers/brickd/default.nix
+++ b/pkgs/servers/brickd/default.nix
@@ -17,10 +17,11 @@ stdenv.mkDerivation rec {
   src = fetchgit {
     url = "git://github.com/Tinkerforge/brickd.git";
     rev = "refs/tags/v${version}";
-    sha256 = "08g587bgx628g5vykh482wxiw0z98fmq4lf5ka6aw0v8l9gim9yf";
+    sha256 = "0m2q01sbgf8z4559jpr6k3jivb8x98vxv1fhgx8nfcjbwz1q83gb";
   };
 
-  buildInputs = [ libusb pkgconfig pmutils udev ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libusb pmutils udev ];
 
   # shell thing didn't work so i replaced it using nix
   prePatch = ''
@@ -51,7 +52,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    homepage = http://www.tinkerforge.com/;
+    homepage = https://www.tinkerforge.com/;
     description = "A daemon (or service on Windows) that acts as a bridge between the Bricks/Bricklets and the API bindings for the different programming languages";
     maintainers = [ stdenv.lib.maintainers.qknight ];
     license = stdenv.lib.licenses.gpl2;
diff --git a/pkgs/servers/caddy/default.nix b/pkgs/servers/caddy/default.nix
new file mode 100644
index 000000000000..d89e59d662e7
--- /dev/null
+++ b/pkgs/servers/caddy/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, buildGoPackage, fetchFromGitHub, fetchpatch }:
+
+buildGoPackage rec {
+  name = "caddy-${version}";
+  version = "0.10.12";
+
+  goPackagePath = "github.com/mholt/caddy";
+
+  subPackages = [ "caddy" ];
+
+  src = fetchFromGitHub {
+    owner = "mholt";
+    repo = "caddy";
+    rev = "v${version}";
+    sha256 = "0vmgswln72qqay73z39qn135sl5k71zlybr2jdrcjlmp4i7hrf88";
+  };
+
+  buildFlagsArray = ''
+    -ldflags=
+      -X github.com/mholt/caddy/caddy/caddymain.gitTag=v${version}
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://caddyserver.com;
+    description = "Fast, cross-platform HTTP/2 web server with automatic HTTPS";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ rushmorem fpletz zimbatm ];
+  };
+}
diff --git a/pkgs/servers/cayley/default.nix b/pkgs/servers/cayley/default.nix
new file mode 100644
index 000000000000..befa36edd9e2
--- /dev/null
+++ b/pkgs/servers/cayley/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "cayley-${version}";
+  version = "0.6.1";
+
+  goPackagePath = "github.com/cayleygraph/cayley";
+
+  src = fetchFromGitHub {
+    owner = "cayleygraph";
+    repo = "cayley";
+    rev = "v${version}";
+    sha256 = "1r0kw3y32bqm7g37svzrch2qj9n45p93xmsrf7dj1cg4wwkb65ry";
+  };
+
+  goDeps = ./deps.nix;
+
+  buildFlagsArray = ''
+    -ldflags=
+      -X=main.Version=${version}
+  '';
+  
+  meta = {
+    homepage = https://cayley.io/;
+    description = "A graph database inspired by Freebase and Knowledge Graph";
+    maintainers = with stdenv.lib.maintainers; [ sigma ];
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/servers/cayley/deps.nix b/pkgs/servers/cayley/deps.nix
new file mode 100644
index 000000000000..1e6fadf9f4d8
--- /dev/null
+++ b/pkgs/servers/cayley/deps.nix
@@ -0,0 +1,272 @@
+[
+  {
+    goPackagePath = "github.com/badgerodon/peg";
+    fetch = {
+      type = "git";
+      url = "https://github.com/badgerodon/peg";
+      rev = "9e5f7f4d07ca576562618c23e8abadda278b684f";
+      sha256 = "12vd7hzdgknn8byz77lmvcrz9m5lvmffdnz2wwk83304przkra11";
+    };
+  }
+  {
+    goPackagePath = "github.com/boltdb/bolt";
+    fetch = {
+      type = "git";
+      url = "https://github.com/boltdb/bolt";
+      rev = "a705895fdad108f053eae7ee011ed94a0541ee13";
+      sha256 = "0ql67l2hmjhplkl80j9a49qlra4qx671il5rgn58afkvk20cgq2r";
+    };
+  }
+  {
+    goPackagePath = "github.com/cznic/mathutil";
+    fetch = {
+      type = "git";
+      url = "https://github.com/cznic/mathutil";
+      rev = "f9551431b78e71ee24939a1e9d8f49f43898b5cd";
+      sha256 = "1158mlwzryyna1qslr9v88i0k8x6m8vs4rljnnwh04rmd63ksj75";
+    };
+  }
+  {
+    goPackagePath = "github.com/davecgh/go-spew";
+    fetch = {
+      type = "git";
+      url = "https://github.com/davecgh/go-spew";
+      rev = "2df174808ee097f90d259e432cc04442cf60be21";
+      sha256 = "0jghd5dmwqpcjbxij9yjj8sjzll9s65i2qnxd8rdzwh77xdsfm9g";
+    };
+  }
+  {
+    goPackagePath = "github.com/dlclark/regexp2";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dlclark/regexp2";
+      rev = "4009c9dc49dd8906bfd4d479c255470d6a477ce5";
+      sha256 = "1r6f0q1jvn1lkwqlrmmg5d90p6zss8s64jyp91hp6i97vpahq8xz";
+    };
+  }
+  {
+    goPackagePath = "github.com/dop251/goja";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dop251/goja";
+      rev = "64f863c4eb0329df18ecd1dab1e03609556bfaca";
+      sha256 = "0smipfs7fja286nvlr7q4b8f815br0nia0k4xp8y5fvprrzrm64h";
+    };
+  }
+  {
+    goPackagePath = "github.com/gogo/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gogo/protobuf";
+      rev = "50d1bd39ce4e7a96b75e3e040be9caf79dbb4c61";
+      sha256 = "09cad9j98pdqh1sp191j92ng6lvw9la3k3v6m5mv38nwirpwzra1";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/glog";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/glog";
+      rev = "23def4e6c14b4da8ac2ed8007337bc5eb5007998";
+      sha256 = "0jb2834rw5sykfr937fxi8hxi2zy80sj2bdn9b3jb4b26ksqng30";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "888eb0692c857ec880338addf316bd662d5e630e";
+      sha256 = "1vhx2dwr71hma9z3dfb3l1yrkjlry0glwxknxzyp9ds51i6pjiq0";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/go-cleanhttp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/go-cleanhttp";
+      rev = "ad28ea4487f05916463e2423a55166280e8254b5";
+      sha256 = "0xw0qas3ixg8p2xh09hhc81km0mfn9lbnfgrdb309hzcwhmiyqjm";
+    };
+  }
+  {
+    goPackagePath = "github.com/julienschmidt/httprouter";
+    fetch = {
+      type = "git";
+      url = "https://github.com/julienschmidt/httprouter";
+      rev = "b59a38004596b696aca7aa2adccfa68760864d86";
+      sha256 = "0j1w2fkcghyw3lcsc13lwf2zqar9xyni2g7fqp4aq8g08ii7paac";
+    };
+  }
+  {
+    goPackagePath = "github.com/lib/pq";
+    fetch = {
+      type = "git";
+      url = "https://github.com/lib/pq";
+      rev = "0dad96c0b94f8dee039aa40467f767467392a0af";
+      sha256 = "06c38iy37251mh8jy9s8n97b01pjnqpq8ii77nnmqh1dsph37jz4";
+    };
+  }
+  {
+    goPackagePath = "github.com/linkeddata/gojsonld";
+    fetch = {
+      type = "git";
+      url = "https://github.com/linkeddata/gojsonld";
+      rev = "a223ef39bb925d36d4c410d3e35b0e34e370cc31";
+      sha256 = "1i3vl7gbkq2xl2wyv0kszj0x32vp8jw1cf0ngpdqdhdvnbfi1w7i";
+    };
+  }
+  {
+    goPackagePath = "github.com/pborman/uuid";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pborman/uuid";
+      rev = "ca53cad383cad2479bbba7f7a1a05797ec1386e4";
+      sha256 = "0rcx669bbjkkwdlw81spnra4ffgzd4rbpywnrj3w41m9vq6mk1gn";
+    };
+  }
+  {
+    goPackagePath = "github.com/peterh/liner";
+    fetch = {
+      type = "git";
+      url = "https://github.com/peterh/liner";
+      rev = "1bb0d1c1a25ed393d8feb09bab039b2b1b1fbced";
+      sha256 = "05ihxpmp6x3hw71xzvjdgxnyvyx2s4lf23xqnfjj16s4j4qidc48";
+    };
+  }
+  {
+    goPackagePath = "github.com/pmezard/go-difflib";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pmezard/go-difflib";
+      rev = "d8ed2627bdf02c080bf22230dbb337003b7aba2d";
+      sha256 = "0w1jp4k4zbnrxh3jvh8fgbjgqpf2hg31pbj8fb32kh26px9ldpbs";
+    };
+  }
+  {
+    goPackagePath = "github.com/robertkrimen/otto";
+    fetch = {
+      type = "git";
+      url = "https://github.com/robertkrimen/otto";
+      rev = "d1b4d8ef0e0e4b088c8328c95ca63ab9ebd8fc9d";
+      sha256 = "0i31p3paz3n7qi2v1g77lm3cx2hssgwgcfpar4qc2vj7m4766884";
+    };
+  }
+  {
+    goPackagePath = "github.com/russross/blackfriday";
+    fetch = {
+      type = "git";
+      url = "https://github.com/russross/blackfriday";
+      rev = "17bb7999de6cfb791d4f8986cc00b3309b370cdb";
+      sha256 = "1md0sjw69mj359cb4c8ghzllcbn2lnkvby1203wl0pf5wbyfvm5s";
+    };
+  }
+  {
+    goPackagePath = "github.com/shurcooL/sanitized_anchor_name";
+    fetch = {
+      type = "git";
+      url = "https://github.com/shurcooL/sanitized_anchor_name";
+      rev = "8e87604bec3c645a4eeaee97dfec9f25811ff20d";
+      sha256 = "05b6yj23c3xx446kanhaj1l83av8676z7si8n1f4sqy2pp7s966v";
+    };
+  }
+  {
+    goPackagePath = "github.com/sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/sirupsen/logrus";
+      rev = "08a8a7c27e3d058a8989316a850daad1c10bf4ab";
+      sha256 = "1fbh1b42alvpbw87v0v2hanliaqp6fm4h9n7byk921mcv6dai8fl";
+    };
+  }
+  {
+    goPackagePath = "github.com/stretchr/testify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stretchr/testify";
+      rev = "f390dcf405f7b83c997eac1b06768bb9f44dec18";
+      sha256 = "1l3z0ggdcjspfmm6k9glmh52a9x50806k6yldxql73p4bpynsd9g";
+    };
+  }
+  {
+    goPackagePath = "github.com/syndtr/goleveldb";
+    fetch = {
+      type = "git";
+      url = "https://github.com/syndtr/goleveldb";
+      rev = "4875955338b0a434238a31165cb87255ab6e9e4a";
+      sha256 = "0786j6kizrlskqz196ng4d13363d44whl849jcv1q07yab2nq40i";
+    };
+  }
+  {
+    goPackagePath = "github.com/syndtr/gosnappy";
+    fetch = {
+      type = "git";
+      url = "https://github.com/syndtr/gosnappy";
+      rev = "156a073208e131d7d2e212cb749feae7c339e846";
+      sha256 = "08lf8smnp4imj5fkph9sbqzb4a5n191q9m6b2c5kamp19i9h2y6z";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "6a513affb38dc9788b449d59ffed099b8de18fa0";
+      sha256 = "1g07c05s3ccq0086f0f200k9cfjjzxd4r9nrdilkmy44lbhhrval";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "a646d33e2ee3172a661fc09bca23bb4889a41bc8";
+      sha256 = "1jniqg2nv5zhdzfm9gwfx0s9q8mwxrgcxdbkd6cddk9w0qgji9dc";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "5a42fa2464759cbb7ee0af9de00b54d69f09a29c";
+      sha256 = "0far6mb2ikwzr7icn0yqi9ygl8kv2wsaasyprbqb9qapr0dqjw0s";
+    };
+  }
+  {
+    goPackagePath = "google.golang.org/appengine";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/appengine";
+      rev = "4f7eeb5305a4ba1966344836ba4af9996b7b4e05";
+      sha256 = "09pgvlk5ay3f0avi1bawpy8khi3rmkfl36l2yr3ryp8z12i9k2qj";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/mgo.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/mgo.v2";
+      rev = "c6a7dce14133ccac2dcac3793f1d6e2ef048503a";
+      sha256 = "0rg232q1bkq3y3kd5816hgk1jpf7i38aha5q5ia7j6p9xashz7vj";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-sql-driver/mysql";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-sql-driver/mysql";
+      rev = "2e00b5cd70399450106cec6431c2e2ce3cae5034";
+      sha256 = "085g48jq9hzmlcxg122n0c4pi41sc1nn2qpx1vrl2jfa8crsppa5";
+    };
+  }
+  {
+    goPackagePath = "github.com/dennwc/graphql";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dennwc/graphql";
+      rev = "fd5c4aa13f2119414084f229600de0d73f174436";
+      sha256 = "11f9jwfc2j646732gkcjb332ih9fxh04j31zmhvqswx75gvk9wzs";
+    };
+  }
+]
diff --git a/pkgs/servers/clickhouse/default.nix b/pkgs/servers/clickhouse/default.nix
new file mode 100644
index 000000000000..58a178a8b2ea
--- /dev/null
+++ b/pkgs/servers/clickhouse/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, cmake, libtool, boost, cctz, double-conversion, gperftools
+, icu, lz4, mysql, openssl, poco, re2, rdkafka, readline, sparsehash, unixODBC, zstd
+}:
+
+stdenv.mkDerivation rec {
+  name = "clickhouse-${version}";
+
+  version = "1.1.54385";
+
+  src = fetchFromGitHub {
+    owner = "yandex";
+    repo = "ClickHouse";
+    rev = "v${version}-stable";
+    sha256 = "0s290xnx9dil2lbxdir5p5zmakvq5h523gdwax2cb37606wg8yj7";
+  };
+
+  patches = [ ./find-mysql.patch ./termcap.patch ];
+
+  nativeBuildInputs = [ cmake libtool ];
+
+  buildInputs = [
+    boost cctz double-conversion gperftools icu lz4 mysql.connector-c openssl poco
+    re2 rdkafka readline sparsehash unixODBC zstd
+  ];
+
+  cmakeFlags = [ "-DENABLE_TESTS=OFF" "-DUNBUNDLED=ON" "-DUSE_STATIC_LIBRARIES=OFF" ];
+
+  meta = with stdenv.lib; {
+    homepage = https://clickhouse.yandex/;
+    description = "Column-oriented database management system";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ orivej ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/clickhouse/find-mysql.patch b/pkgs/servers/clickhouse/find-mysql.patch
new file mode 100644
index 000000000000..3a5ec5181d1a
--- /dev/null
+++ b/pkgs/servers/clickhouse/find-mysql.patch
@@ -0,0 +1,11 @@
+--- a/libs/libmysqlxx/cmake/find_mysqlclient.cmake
++++ b/libs/libmysqlxx/cmake/find_mysqlclient.cmake
+@@ -24,7 +24,7 @@ if (ENABLE_MYSQL)
+     if (USE_STATIC_LIBRARIES)
+         find_library (STATIC_MYSQLCLIENT_LIB mariadbclient mysqlclient PATHS ${MYSQL_LIB_PATHS})
+     else ()
+-        find_library (MYSQLCLIENT_LIBRARIES mariadbclient mysqlclient PATHS ${MYSQL_LIB_PATHS})
++        find_library (MYSQLCLIENT_LIBRARIES mariadbclient mysqlclient PATH_SUFFIXES mysql PATHS ${MYSQL_LIB_PATHS})
+     endif ()
+ 
+     if (MYSQL_INCLUDE_DIR AND (STATIC_MYSQLCLIENT_LIB OR MYSQLCLIENT_LIBRARIES))
diff --git a/pkgs/servers/clickhouse/termcap.patch b/pkgs/servers/clickhouse/termcap.patch
new file mode 100644
index 000000000000..e030d0956900
--- /dev/null
+++ b/pkgs/servers/clickhouse/termcap.patch
@@ -0,0 +1,25 @@
+From c2105ecdf6a6cc1fbb4c1ae01475db6a65fee32f Mon Sep 17 00:00:00 2001
+From: Orivej Desh <orivej@gmx.fr>
+Date: Mon, 27 Mar 2017 01:39:11 +0000
+Subject: [PATCH] Search for termcap in ncurses
+
+---
+ cmake/find_readline_edit.cmake | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cmake/find_readline_edit.cmake b/cmake/find_readline_edit.cmake
+index 26f2768..f520ece 100644
+--- a/cmake/find_readline_edit.cmake
++++ b/cmake/find_readline_edit.cmake
+@@ -7,7 +7,7 @@ endif ()
+ 
+ list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.2)
+ 
+-find_library (TERMCAP_LIB NAMES termcap)
++find_library (TERMCAP_LIB NAMES ncurses)
+ find_library (EDIT_LIB NAMES edit)
+ 
+ set(READLINE_INCLUDE_PATHS "/var/empty/local/var/empty/readline/include")
+-- 
+2.12.0
+
diff --git a/pkgs/servers/cloud-print-connector/default.nix b/pkgs/servers/cloud-print-connector/default.nix
new file mode 100644
index 000000000000..3db3d9327031
--- /dev/null
+++ b/pkgs/servers/cloud-print-connector/default.nix
@@ -0,0 +1,35 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.0
+{ stdenv, buildGoPackage, fetchFromGitHub, avahi, cups }:
+
+# TODO: Add a service for gcp-cups-connector and perhaps some other
+# kind of configuration for the same thing that gcp-connector-util
+# provides.
+
+buildGoPackage rec {
+  name = "cloud-print-connector-unstable-${version}";
+  version = "1.11";
+  rev = "481ad139cc023a3ba65e769f08f277368fa8a5de";
+
+  goPackagePath = "github.com/google/cloud-print-connector";
+
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "cloud-print-connector";
+    sha256 = "1vryhhv92bsncy1bsx9j4graz3sz9ddmizakv2fdrns09mmcgchm";
+    rev = "v${version}";
+  };
+
+  goDeps = ./deps.nix;
+
+  buildInputs = [ avahi cups ];
+
+  meta = with stdenv.lib; {
+    description = "Share printers from your Windows, Linux, FreeBSD or macOS computer with ChromeOS and Android devices, using the Cloud Print Connector";
+    homepage = https://github.com/google/cloud-print-connector;
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ hodapp ];
+    # TODO: Fix broken build on macOS.  The GitHub presently lists the
+    # FreeBSD build as broken too, but this may change in the future.
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/cloud-print-connector/deps.nix b/pkgs/servers/cloud-print-connector/deps.nix
new file mode 100644
index 000000000000..67901bdffeef
--- /dev/null
+++ b/pkgs/servers/cloud-print-connector/deps.nix
@@ -0,0 +1,57 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.0
+[
+  {
+    goPackagePath = "github.com/coreos/go-systemd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/go-systemd";
+      rev = "1f9909e51b2dab2487c26d64c8f2e7e580e4c9f5";
+      sha256 = "1cc76wcmnyhhhi03dsc11lmxjwkzy09k3zx3h78bg05z8lhry4vn";
+    };
+  }
+  {
+    goPackagePath = "github.com/urfave/cli";
+    fetch = {
+      type = "git";
+      url = "https://github.com/urfave/cli";
+      rev = "d70f47eeca3afd795160003bc6e28b001d60c67c";
+      sha256 = "1xm203qp4sdlvffcbag7v6mc2d6q61i25iiz3y9yqpy25jpcpgif";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "513929065c19401a1c7b76ecd942f9f86a0c061b";
+      sha256 = "19ziin0k3n45nccjbk094f61hr198wzqnas93cmcxdja8f8fz27q";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/oauth2";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/oauth2";
+      rev = "f047394b6d14284165300fd82dad67edb3a4d7f6";
+      sha256 = "1l1a2iz1nmfmzzbjj1h8066prag4jvjqh13iv1jdlh05fgv6769i";
+    };
+  }
+  {
+    goPackagePath = "launchpad.net/go-xdg/v0";
+    fetch = {
+      type = "bzr";
+      url = "http://bazaar.launchpad.net/~chipaca/go-xdg/v0/";
+      rev = "10";
+      sha256 = "0fd68kkxzxjanpgannpys962bxzqdf8c1qvzk687hv504a3dp76f";
+    };
+  }
+  {
+    goPackagePath = "github.com/satori/go.uuid";
+    fetch = {
+      type = "git";
+      url = "https://github.com/satori/go.uuid";
+      rev = "879c5887cd475cd7864858769793b2ceb0d44feb";
+      sha256 = "1nbydsmjr60904kz5d46nib0zid5kcv4gk9wayi44gn5wlzz80zp";
+    };
+  }
+ ]
diff --git a/pkgs/servers/computing/slurm-spank-x11/default.nix b/pkgs/servers/computing/slurm-spank-x11/default.nix
new file mode 100644
index 000000000000..13fad7059afe
--- /dev/null
+++ b/pkgs/servers/computing/slurm-spank-x11/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchFromGitHub, slurm } :
+let
+  version = "0.2.5";
+in
+stdenv.mkDerivation {
+  name = "slurm-spank-x11-${version}";
+  version = version;
+
+  src = fetchFromGitHub {
+    owner = "hautreux";
+    repo = "slurm-spank-x11";
+    rev = version;
+    sha256 = "1dmsr7whxcxwnlvl1x4s3bqr5cr6q5ssb28vqi67w5hj4sshisry";
+  };
+
+  buildPhase = ''
+      gcc -DX11_LIBEXEC_PROG="\"$out/bin/slurm-spank-x11\"" \
+          -g -o slurm-spank-x11 slurm-spank-x11.c
+      gcc -I${slurm.dev}/include -DX11_LIBEXEC_PROG="\"$out/bin/slurm-spank-x11\"" -shared -fPIC \
+          -g -o x11.so slurm-spank-x11-plug.c
+    '';
+
+  installPhase = ''
+      mkdir -p $out/bin $out/lib
+      install -m 755 slurm-spank-x11 $out/bin
+      install -m 755 x11.so $out/lib
+    '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/hautreux/slurm-spank-x11;
+    description = "Plugin for SLURM to allow for interactive X11 sessions";
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ markuskowa ];
+  };
+}
+
+
+
diff --git a/pkgs/servers/computing/slurm/default.nix b/pkgs/servers/computing/slurm/default.nix
index a1a1a2ea1f2d..7a03bf75802b 100644
--- a/pkgs/servers/computing/slurm/default.nix
+++ b/pkgs/servers/computing/slurm/default.nix
@@ -1,33 +1,65 @@
-{ stdenv, fetchurl, python, munge, perl, pam, openssl, mysql }:
-
-#TODO: add sview support based on gtk2
+{ stdenv, fetchurl, pkgconfig, libtool, curl
+, python, munge, perl, pam, openssl
+, ncurses, mysql, gtk2, lua, hwloc, numactl
+, readline, freeipmi, libssh2, xorg
+# enable internal X11 support via libssh2
+, enableX11 ? true
+}:
 
 stdenv.mkDerivation rec {
-  name = "slurm-llnl-${version}";
-  version = "14.11.5";
+  name = "slurm-${version}";
+  version = "17.11.5";
 
   src = fetchurl {
-    url = "http://www.schedmd.com/download/latest/slurm-${version}.tar.bz2";
-    sha256 = "0xx1q9ximsyyipl0xbj8r7ajsz4xrxik8xmhcb1z9nv0aza1rff2";
+    url = "https://download.schedmd.com/slurm/${name}.tar.bz2";
+    sha256 = "07ghyyz12k4rksm06xf7dshwp1ndm13zphdbqja99401q4xwbx9r";
   };
 
-  buildInputs = [ python munge perl pam openssl mysql.lib ];
+  outputs = [ "out" "dev" ];
 
-  configureFlags = ''
-    --with-munge=${munge}
-    --with-ssl=${openssl}
+  prePatch = stdenv.lib.optional enableX11 ''
+    substituteInPlace src/common/x11_util.c \
+        --replace '"/usr/bin/xauth"' '"${xorg.xauth}/bin/xauth"'
   '';
 
+  # nixos test fails to start slurmd with 'undefined symbol: slurm_job_preempt_mode'
+  # https://groups.google.com/forum/#!topic/slurm-devel/QHOajQ84_Es
+  # this doesn't fix tests completely at least makes slurmd to launch
+  hardeningDisable = [ "bindnow" ];
+
+  nativeBuildInputs = [ pkgconfig libtool ];
+  buildInputs = [
+    curl python munge perl pam openssl
+      mysql.connector-c ncurses gtk2
+      lua hwloc numactl readline freeipmi
+  ] ++ stdenv.lib.optionals enableX11 [ libssh2 xorg.xauth ];
+
+  configureFlags = with stdenv.lib;
+    [ "--with-munge=${munge}"
+      "--with-ssl=${openssl.dev}"
+      "--with-hwloc=${hwloc.dev}"
+      "--with-freeipmi=${freeipmi}"
+      "--sysconfdir=/etc/slurm"
+    ] ++ (optional (gtk2 == null)  "--disable-gtktest")
+      ++ (optional enableX11 "--with-libssh2=${libssh2.dev}");
+
+
   preConfigure = ''
-    substituteInPlace ./doc/html/shtml2html.py --replace "/usr/bin/env python" "${python.interpreter}"
-    substituteInPlace ./doc/man/man2html.py --replace "/usr/bin/env python" "${python.interpreter}"
+    patchShebangs ./doc/html/shtml2html.py
+    patchShebangs ./doc/man/man2html.py
+  '';
+
+  postInstall = ''
+    rm -f $out/lib/*.la $out/lib/slurm/*.la
   '';
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     homepage = http://www.schedmd.com/;
     description = "Simple Linux Utility for Resource Management";
     platforms = platforms.linux;
     license = licenses.gpl2;
-    maintainers = [ maintainers.jagajaga ];
+    maintainers = with maintainers; [ jagajaga markuskowa ];
   };
 }
diff --git a/pkgs/servers/computing/storm/default.nix b/pkgs/servers/computing/storm/default.nix
index cab91409654d..90c87f8019d0 100644
--- a/pkgs/servers/computing/storm/default.nix
+++ b/pkgs/servers/computing/storm/default.nix
@@ -1,49 +1,65 @@
-{ stdenv, fetchurl, zip, unzip, jzmq, jdk, lib, python, logsDir ? "", confFile ? "", extraLibraryPaths ? [], extraJars ? [] }:
+{ stdenv, lib, fetchurl, zip, unzip, makeWrapper
+, jzmq, jdk, python
+, logsDir ? "", confFile ? "", extraLibraryPaths ? [], extraJars ? [] }:
 
-stdenv.mkDerivation {
-  name = "storm-0.8.2";
+stdenv.mkDerivation rec {
+  name = "apache-storm-" + version;
+  version = "1.2.1";
   src = fetchurl {
-    url = https://dl.dropbox.com/u/133901206/storm-0.8.2.zip;
-    sha256 = "8761aea0b54e5bab4a68b259bbe6b5b2f8226204488b5559eba57a0c458b2bbc";
+    url =
+    "mirror://apache/storm/${name}/${name}.tar.gz";
+    sha256 = "177dqgbviagrpvalg8h67mwiwwgmiqsg0hh97hcqqcjg71ypnjkv";
   };
 
   buildInputs = [ zip unzip jzmq ];
 
   installPhase = ''
-    # Remove junk
-    rm -f lib/jzmq*
-    mkdir -p $out/bin
-    mv bin/storm $out/bin/
-    rm -R bin conf logs
+    mkdir -p $out/share/${name}
+    mv public $out/docs
+    mv examples $out/share/${name}/.
 
-    # Fix shebang header for python scripts
-    sed -i -e "s|#!/usr/bin/.*python|#!${python}/bin/python|" $out/bin/storm;
-
-    mkdir -p $out/conf
-    cp -av * $out
-
-    cd $out;
-    ${if logsDir  != "" then ''ln -s ${logsDir} logs'' else ""}
+    rm -f lib/jzmq* || exit 1
+    mv external extlib* lib $out/.
+    mv conf bin $out/.
+    mv log4j2 $out/conf/.
+  '';
 
-    # Extract, delete from zip; and optionally append to defaults.yaml
-    unzip  storm-*.jar defaults.yaml;
-    zip -d storm-*.jar defaults.yaml;
-    echo 'java.library.path: "${jzmq}/lib:${lib.concatStringsSep ":" extraLibraryPaths}"' >> defaults.yaml;
+  fixupPhase = ''
+    # Fix python reference
+    sed -i \
+      -e '19iPYTHON=${python}/bin/python' \
+      -e 's|#!/usr/bin/.*python|#!${python}/bin/python|' \
+      $out/bin/storm
+    sed -i \
+      -e 's|#!/usr/bin/.*python|#!${python}/bin/python|' \
+      -e "s|STORM_CONF_DIR = .*|STORM_CONF_DIR = os.getenv('STORM_CONF_DIR','$out/conf')|" \
+      -e 's|STORM_LOG4J2_CONF_DIR =.*|STORM_LOG4J2_CONF_DIR = os.path.join(STORM_CONF_DIR, "log4j2")|' \
+        $out/bin/storm.py
+    # Default jdk location
+    sed -i -e 's|#.*export JAVA_HOME=.*|export JAVA_HOME="${jdk.home}"|' \
+           $out/conf/storm-env.sh
+    unzip  $out/lib/storm-core-${version}.jar defaults.yaml;
+    zip -d $out/lib/storm-core-${version}.jar defaults.yaml;
+    sed -i \
+       -e 's|java.library.path: .*|java.library.path: "${jzmq}/lib:${lib.concatStringsSep ":" extraLibraryPaths}"|' \
+       -e 's|storm.log4j2.conf.dir: .*|storm.log4j2.conf.dir: "conf/log4j2"|' \
+      defaults.yaml
     ${if confFile != "" then ''cat ${confFile} >> defaults.yaml'' else ""}
-    mv defaults.yaml conf;
+    mv defaults.yaml $out/conf;
 
     # Link to jzmq jar and extra jars
-    cd lib;
+    cd $out/lib;
     ln -s ${jzmq}/share/java/*.jar;
     ${lib.concatMapStrings (jar: "ln -s ${jar};\n") extraJars}
   '';
 
   dontStrip = true;
 
-  meta = {
-    homepage = "http://storm-project.net";
+  meta = with stdenv.lib; {
+    homepage = http://storm.apache.org;
     description = "Distributed realtime computation system";
-    license = stdenv.lib.licenses.epl10;
-    maintainers = [ lib.maintainers.vizanto ];
+    license = licenses.asl20;
+    maintainers = with maintainers; [ edwtjo vizanto ];
+    platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/servers/computing/torque/default.nix b/pkgs/servers/computing/torque/default.nix
index 6d0037f74bdb..35c830dff8a5 100644
--- a/pkgs/servers/computing/torque/default.nix
+++ b/pkgs/servers/computing/torque/default.nix
@@ -10,11 +10,15 @@ stdenv.mkDerivation rec {
     sha256 = "1qpsk3bla6b6m7m0i1xpr183yj79liy3p34xhnz1grgq0776wg5l";
   };
 
-  buildInputs = [ openssl flex bison pkgconfig groff libxml2 utillinux libtool
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ openssl flex bison groff libxml2 utillinux libtool
                   which ];
 
   enableParallelBuilding = true;
 
+  # added to fix build with gcc7
+  NIX_CFLAGS_COMPILE = [ "-fpermissive" ];
+
   preConfigure = ''
    substituteInPlace ./configure \
      --replace '/usr/bin/file' '${file}/bin/file'
@@ -29,8 +33,9 @@ stdenv.mkDerivation rec {
 
    for f in $(find ./ -name Makefile.in); do
      echo patching $f...
-     sed -i $f -e '/PBS_MKDIRS/d'
+     sed -i $f -e '/PBS_MKDIRS/d' -e '/chmod u+s/d'
    done
+
   '';
 
   postInstall = ''
diff --git a/pkgs/servers/consul/Gemfile b/pkgs/servers/consul/Gemfile
index 77b884c352dc..0e782af6b000 100644
--- a/pkgs/servers/consul/Gemfile
+++ b/pkgs/servers/consul/Gemfile
@@ -3,4 +3,3 @@ source "https://rubygems.org"
 
 gem "uglifier"
 gem "sass"
-gem "therubyracer"
diff --git a/pkgs/servers/consul/Gemfile.lock b/pkgs/servers/consul/Gemfile.lock
index cc4df6b24309..60a565f66951 100644
--- a/pkgs/servers/consul/Gemfile.lock
+++ b/pkgs/servers/consul/Gemfile.lock
@@ -1,22 +1,25 @@
 GEM
   remote: https://rubygems.org/
   specs:
-    execjs (2.3.0)
-    json (1.8.2)
-    libv8 (3.16.14.11)
-    ref (1.0.5)
-    sass (3.4.11)
-    therubyracer (0.12.1)
-      libv8 (~> 3.16.14.0)
-      ref
-    uglifier (2.7.0)
-      execjs (>= 0.3.0)
-      json (>= 1.8.0)
+    execjs (2.7.0)
+    ffi (1.9.23)
+    rb-fsevent (0.10.3)
+    rb-inotify (0.9.10)
+      ffi (>= 0.5.0, < 2)
+    sass (3.5.6)
+      sass-listen (~> 4.0.0)
+    sass-listen (4.0.0)
+      rb-fsevent (~> 0.9, >= 0.9.4)
+      rb-inotify (~> 0.9, >= 0.9.7)
+    uglifier (4.1.10)
+      execjs (>= 0.3.0, < 3)
 
 PLATFORMS
   ruby
 
 DEPENDENCIES
   sass
-  therubyracer
   uglifier
+
+BUNDLED WITH
+   1.14.6
diff --git a/pkgs/servers/consul/default.nix b/pkgs/servers/consul/default.nix
new file mode 100644
index 000000000000..d2ad5d0bd8e8
--- /dev/null
+++ b/pkgs/servers/consul/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, lib, buildGoPackage, consul-ui, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "consul-${version}";
+  version = "0.9.3";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/hashicorp/consul";
+
+  src = fetchFromGitHub {
+    owner = "hashicorp";
+    repo = "consul";
+    inherit rev;
+    sha256 = "1176frp7kimpycsmz9wrbizf46jgxr8jq7hz5w4q1x90lswvrxv3";
+  };
+
+  # Keep consul.ui for backward compatability
+  passthru.ui = consul-ui;
+
+  preBuild = ''
+    buildFlagsArray+=("-ldflags" "-X github.com/hashicorp/consul/version.GitDescribe=v${version} -X github.com/hashicorp/consul/version.Version=${version} -X github.com/hashicorp/consul/version.VersionPrerelease=")
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Tool for service discovery, monitoring and configuration";
+    homepage = https://www.consul.io/;
+    platforms = platforms.linux ++ platforms.darwin;
+    license = licenses.mpl20;
+    maintainers = with maintainers; [ pradeepchhetri ];
+  };
+}
diff --git a/pkgs/servers/consul/gemset.nix b/pkgs/servers/consul/gemset.nix
index f87038775be7..2a5425ccf5f5 100644
--- a/pkgs/servers/consul/gemset.nix
+++ b/pkgs/servers/consul/gemset.nix
@@ -1,59 +1,62 @@
 {
   execjs = {
-    version = "2.3.0";
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1yz55sf2nd3l666ms6xr18sm2aggcvmb8qr3v53lr4rir32y1yp1";
       type = "gem";
-      sha256 = "097v02bhmzc70j7n0yyf8j0z5wms88zcmgpmggby4hnvqxf41y1h";
     };
+    version = "2.7.0";
   };
-  json = {
-    version = "1.8.2";
+  ffi = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0zw6pbyvmj8wafdc7l5h7w20zkp1vbr2805ql5d941g2b20pk4zr";
       type = "gem";
-      sha256 = "0zzvv25vjikavd3b1bp6lvbgj23vv9jvmnl4vpim8pv30z8p6vr5";
     };
+    version = "1.9.23";
   };
-  libv8 = {
-    version = "3.16.14.11";
+  rb-fsevent = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1lm1k7wpz69jx7jrc92w3ggczkjyjbfziq5mg62vjnxmzs383xx8";
       type = "gem";
-      sha256 = "000vbiy78wk5r1f6p7qncab8ldg7qw5pjz7bchn3lw700gpaacxp";
     };
+    version = "0.10.3";
   };
-  ref = {
-    version = "1.0.5";
+  rb-inotify = {
+    dependencies = ["ffi"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0yfsgw5n7pkpyky6a9wkf1g9jafxb0ja7gz0qw0y14fd2jnzfh71";
       type = "gem";
-      sha256 = "19qgpsfszwc2sfh6wixgky5agn831qq8ap854i1jqqhy1zsci3la";
     };
+    version = "0.9.10";
   };
   sass = {
-    version = "3.4.11";
+    dependencies = ["sass-listen"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "19wyzp9qsg8hdkkxlsv713w0qmy66qrdp0shj42587ssx4qhrlag";
       type = "gem";
-      sha256 = "10dncnv7g5v8d1xpw2aaarxjjlm68f7nm02ns2kl8nf3yxi6wzdf";
     };
+    version = "3.5.6";
   };
-  therubyracer = {
-    version = "0.12.1";
+  sass-listen = {
+    dependencies = ["rb-fsevent" "rb-inotify"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0xw3q46cmahkgyldid5hwyiwacp590zj2vmswlll68ryvmvcp7df";
       type = "gem";
-      sha256 = "106fqimqyaalh7p6czbl5m2j69z8gv7cm10mjb8bbb2p2vlmqmi6";
     };
-    dependencies = [
-      "libv8"
-      "ref"
-    ];
+    version = "4.0.0";
   };
   uglifier = {
-    version = "2.7.0";
+    dependencies = ["execjs"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0dycp9c5xiricla6sgvg0vf22i3axs5k1v1607dvl7nv1xkkaczi";
       type = "gem";
-      sha256 = "1x1mnakx086l83a3alj690c6n8kfmb4bk243a6m6yz99s15gbxfq";
     };
-    dependencies = [
-      "execjs"
-      "json"
-    ];
+    version = "4.1.10";
   };
-}
+}
\ No newline at end of file
diff --git a/pkgs/servers/consul/ui-no-bundle-exec.patch b/pkgs/servers/consul/ui-no-bundle-exec.patch
new file mode 100644
index 000000000000..5707b871049b
--- /dev/null
+++ b/pkgs/servers/consul/ui-no-bundle-exec.patch
@@ -0,0 +1,17 @@
+diff --git a/ui/scripts/dist.sh b/ui/scripts/dist.sh
+index 0ad6e28e..db340da0 100755
+--- a/ui/scripts/dist.sh
++++ b/ui/scripts/dist.sh
+@@ -15,10 +15,9 @@ DEPLOY="../pkg/web_ui"
+ rm -rf $DEPLOY
+ mkdir -p $DEPLOY
+ 
+-bundle check >/dev/null 2>&1 || bundle install
+-bundle exec sass styles/base.scss static/base.css
++sass styles/base.scss static/base.css
+ 
+-bundle exec ruby scripts/compile.rb
++ruby scripts/compile.rb
+ 
+ # Copy into deploy
+ shopt -s dotglob
diff --git a/pkgs/servers/consul/ui.nix b/pkgs/servers/consul/ui.nix
index 2aaa7b4a1319..da9b518bad73 100644
--- a/pkgs/servers/consul/ui.nix
+++ b/pkgs/servers/consul/ui.nix
@@ -1,21 +1,23 @@
-{ stdenv, goPackages, ruby, bundlerEnv }:
+{ stdenv, consul, ruby, bundlerEnv, zip, nodejs }:
 
 let
   # `sass` et al
   gems = bundlerEnv {
     name = "consul-ui-deps";
-    gemfile = ./Gemfile;
-    lockfile = ./Gemfile.lock;
-    gemset = ./gemset.nix;
+    gemdir = ./.;
   };
 in
 
 stdenv.mkDerivation {
-  name = "consul-ui-${goPackages.consul.rev}";
+  name = "consul-ui-${consul.version}";
 
-  src = goPackages.consul.src;
+  src = consul.src;
 
-  buildInputs = [ ruby gems ];
+  buildInputs = [ ruby gems zip nodejs ];
+
+  patches = [ ./ui-no-bundle-exec.patch ];
+
+  postPatch = "patchShebangs ./ui/scripts/dist.sh";
 
   buildPhase = ''
     # Build ui static files
@@ -26,11 +28,11 @@ stdenv.mkDerivation {
   installPhase = ''
     # Install ui static files
     mkdir -p $out
-    mv dist/* $out
+    mv ../pkg/web_ui/* $out
   '';
 
   meta = with stdenv.lib; {
-    homepage    = http://www.consul.io/;
+    homepage    = https://www.consul.io/;
     description = "A tool for service discovery, monitoring and configuration";
     maintainers = with maintainers; [ cstrahan wkennington ];
     license     = licenses.mpl20 ;
diff --git a/pkgs/servers/corosync/default.nix b/pkgs/servers/corosync/default.nix
index 5e8f2fd0caae..145052ff8c3a 100644
--- a/pkgs/servers/corosync/default.nix
+++ b/pkgs/servers/corosync/default.nix
@@ -1,50 +1,61 @@
 { stdenv, fetchurl, makeWrapper, pkgconfig, nss, nspr, libqb
-, dbus ? null
-, librdmacm ? null, libibverbs ? null
-, libstatgrab ? null
-, net_snmp ? null
+, dbus, librdmacm, libibverbs, libstatgrab, net_snmp
+, enableDbus ? false
+, enableInfiniBandRdma ? false
+, enableMonitoring ? false
+, enableSnmp ? false
 }:
 
 with stdenv.lib;
+
 stdenv.mkDerivation rec {
-  name = "corosync-2.3.4";
+  name = "corosync-2.4.3";
 
   src = fetchurl {
     url = "http://build.clusterlabs.org/corosync/releases/${name}.tar.gz";
-    sha256 = "1m276b060fjghr93hdzfag81whi5ph65dc2ka8ln1igm3kxr7bix";
+    sha256 = "15y5la04qn2lh1gabyifygzpa4dx3ndk5yhmaf7azxyjx0if9rxi";
   };
 
-  buildInputs = [
-    makeWrapper pkgconfig nss nspr libqb
-    dbus librdmacm libibverbs libstatgrab net_snmp
-  ];
+  nativeBuildInputs = [ makeWrapper pkgconfig ];
 
-  # Remove when rdma libraries gain pkgconfig support
-  ibverbs_CFLAGS = optionalString (libibverbs != null)
-    "-I${libibverbs}/include/infiniband";
-  ibverbs_LIBS = optionalString (libibverbs != null) "-libverbs";
-  rdmacm_CFLAGS = optionalString (librdmacm != null)
-    "-I${librdmacm}/include/rdma";
-  rdmacm_LIBS = optionalString (librdmacm != null) "-lrdmacm";
+  buildInputs = [
+    nss nspr libqb
+  ] ++ optional enableDbus dbus
+    ++ optional enableInfiniBandRdma [ librdmacm libibverbs ]
+    ++ optional enableMonitoring libstatgrab
+    ++ optional enableSnmp net_snmp;
 
   configureFlags = [
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+    "--with-logdir=/var/log/corosync"
     "--enable-watchdog"
     "--enable-qdevices"
-  ] ++ optional (dbus != null) "--enable-dbus"
-    ++ optional (librdmacm != null && libibverbs != null) "--enable-rdma"
-    ++ optional (libstatgrab != null) "--enable-monitoring"
-    ++ optional (net_snmp != null) "--enable-snmp";
+  ] ++ optional enableDbus "--enable-dbus"
+    ++ optional enableInfiniBandRdma "--enable-rdma"
+    ++ optional enableMonitoring "--enable-monitoring"
+    ++ optional enableSnmp "--enable-snmp";
+
+  installFlags = [
+    "sysconfdir=$(out)/etc"
+    "localstatedir=$(out)/var"
+    "COROSYSCONFDIR=$(out)/etc/corosync"
+    "INITDDIR=$(out)/etc/init.d"
+    "LOGROTATEDIR=$(out)/etc/logrotate.d"
+  ];
 
   postInstall = ''
     wrapProgram $out/bin/corosync-blackbox \
       --prefix PATH ":" "$out/sbin:${libqb}/sbin"
   '';
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://corosync.org/;
     description = "A Group Communication System with features for implementing high availability within applications";
     license = licenses.bsd3;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ wkennington ];
+    maintainers = with maintainers; [ wkennington montag451 ];
   };
 }
diff --git a/pkgs/servers/coturn/default.nix b/pkgs/servers/coturn/default.nix
new file mode 100644
index 000000000000..f83ef4cef388
--- /dev/null
+++ b/pkgs/servers/coturn/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, openssl, libevent }:
+
+let inherit (stdenv.lib) optional; in
+
+stdenv.mkDerivation rec {
+  name = "coturn-${version}";
+  version = "4.5.0.7";
+
+  src = fetchFromGitHub {
+    owner = "coturn";
+    repo = "coturn";
+    rev = "${version}";
+    sha256 = "1781fx8lqgc54j973xzgq9d7k3g2j03va82jb4217gd3a93pa65l";
+  };
+
+  buildInputs = [ openssl libevent ];
+
+  patches = [ ./pure-configure.patch ];
+
+  meta = with stdenv.lib; {
+    homepage = http://coturn.net/;
+    license = with licenses; [ bsd3 ];
+    description = "A TURN server";
+    platforms = platforms.all;
+    maintainers = [ maintainers.ralith ];
+  };
+}
diff --git a/pkgs/servers/coturn/pure-configure.patch b/pkgs/servers/coturn/pure-configure.patch
new file mode 100644
index 000000000000..0315a71b1844
--- /dev/null
+++ b/pkgs/servers/coturn/pure-configure.patch
@@ -0,0 +1,17 @@
+diff --git a/configure b/configure
+index 28a0625..ea25488 100755
+--- a/configure
++++ b/configure
+@@ -624,12 +624,6 @@ fi
+ 
+ TMPDIR="."
+ 
+-if [ -d /var/tmp ] ; then
+-  TMPDIR="/var/tmp"
+-elif [ -d /tmp ] ; then
+-  TMPDIR=/tmp
+-fi
+-
+ ${ECHO_CMD} Use TMP dir ${TMPDIR}
+ 
+ #########################
diff --git a/pkgs/servers/couchpotato/default.nix b/pkgs/servers/couchpotato/default.nix
new file mode 100644
index 000000000000..a996cec0d5b5
--- /dev/null
+++ b/pkgs/servers/couchpotato/default.nix
@@ -0,0 +1,43 @@
+{ fetchurl, pythonPackages, lib }:
+
+with pythonPackages;
+
+buildPythonApplication rec {
+  name = "couchpotato-${version}";
+  version = "3.0.1";
+  disabled = isPy3k;
+
+  src = fetchurl {
+    url = "https://github.com/CouchPotato/CouchPotatoServer/archive/build/${version}.tar.gz";
+    sha256 = "1xwjis3ijh1rff32mpdsphmsclf0lkpd3phpgxkccrigq1m9r3zh";
+  };
+
+  format = "other";
+
+  postPatch = ''
+    substituteInPlace CouchPotato.py --replace "dirname(os.path.abspath(__file__))" "os.path.join(dirname(os.path.abspath(__file__)), '../${python.sitePackages}')"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin/
+    mkdir -p $out/${python.sitePackages}/
+
+    cp -r libs/* $out/${python.sitePackages}/
+    cp -r couchpotato $out/${python.sitePackages}/
+
+    cp CouchPotato.py $out/bin/couchpotato
+    chmod +x $out/bin/*
+  '';
+
+  fixupPhase = ''
+    wrapProgram "$out/bin/couchpotato" --set PYTHONPATH "$PYTHONPATH:$out/${python.sitePackages}" \
+                                       --set PATH ${python}/bin
+  '';
+
+  meta = {
+    description = "Automatic movie downloading via NZBs and torrents";
+    license     = lib.licenses.gpl3;
+    homepage    = https://couchpota.to/;
+    maintainers = with lib.maintainers; [ fadenb ];
+  };
+}
diff --git a/pkgs/servers/dante/default.nix b/pkgs/servers/dante/default.nix
new file mode 100644
index 000000000000..1c093facde5c
--- /dev/null
+++ b/pkgs/servers/dante/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, pam, libkrb5, cyrus_sasl, miniupnpc }:
+
+stdenv.mkDerivation rec {
+  name = "dante-${version}";
+  version = "1.4.2";
+
+  src = fetchurl {
+    url = "https://www.inet.no/dante/files/${name}.tar.gz";
+    sha256 = "1bfafnm445afrmyxvvcl8ckq0p59yzykmr3y8qvryzrscd85g8ms";
+  };
+
+  buildInputs = [ pam libkrb5 cyrus_sasl miniupnpc ];
+
+  configureFlags = [
+    "--with-libc=libc.so.6"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A circuit-level SOCKS client/server that can be used to provide convenient and secure network connectivity.";
+    homepage    = "https://www.inet.no/dante/";
+    maintainers = [ maintainers.arobyn ];
+    license     = licenses.bsdOriginal;
+    platforms   = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/dex/default.nix b/pkgs/servers/dex/default.nix
new file mode 100644
index 000000000000..119d5f03f626
--- /dev/null
+++ b/pkgs/servers/dex/default.nix
@@ -0,0 +1,32 @@
+{ lib, buildGoPackage, fetchFromGitHub }:
+
+let version = "2.4.1"; in
+
+buildGoPackage rec {
+  name = "dex-${version}";
+
+  goPackagePath = "github.com/coreos/dex";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner = "coreos";
+    repo = "dex";
+    sha256 = "11qpn3wh74mq16xgl9l50n2v02ffqcd14xccf77j5il04xr764nx";
+  };
+
+  subPackages = [
+    "cmd/dex"
+  ];
+
+  buildFlagsArray = [
+    "-ldflags=-w -X ${goPackagePath}/version.Version=${src.rev}"
+  ];
+
+  meta = {
+    description = "OpenID Connect and OAuth2 identity provider with pluggable connectors";
+    license = lib.licenses.asl20;
+    homepage = https://github.com/coreos/dex;
+    maintainers = with lib.maintainers; [benley];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/pkgs/servers/dgraph/default.nix b/pkgs/servers/dgraph/default.nix
new file mode 100644
index 000000000000..5056df06e598
--- /dev/null
+++ b/pkgs/servers/dgraph/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "dgraph-${version}";
+  version = "0.8.2";
+
+  goPackagePath = "github.com/dgraph-io/dgraph";
+
+  src = fetchFromGitHub {
+    owner = "dgraph-io";
+    repo = "dgraph";
+    rev = "v${version}";
+    sha256 = "0zc5bda8m2srjbk0gy1nnm0bya8if0kmk1szqr1qv3xifdzmi4nf";
+  };
+
+  extraOutputsToInstall = [ "dashboard" ];
+
+  goDeps = ./deps.nix;
+  subPackages = [ "cmd/dgraph" "cmd/dgraphloader" "cmd/bulkloader"];
+
+  # let's move the dashboard to a different output, to prevent $bin from
+  # depending on $out
+  # TODO: provide a proper npm application for the dashboard.
+  postPatch = ''
+    mv dashboard/* $dashboard
+  '';
+
+  preBuild = ''
+    export buildFlagsArray="-ldflags=\
+      -X github.com/dgraph-io/dgraph/x.dgraphVersion=${version} \
+      -X github.com/dgraph-io/dgraph/cmd/dgraph/main.uiDir=$dashboard/src/assets/"
+  '';
+
+  meta = {
+    homepage = "https://dgraph.io/";
+    description = "Fast, Distributed Graph DB";
+    maintainers = with stdenv.lib.maintainers; [ sigma ];
+    license = stdenv.lib.licenses.agpl3;
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/servers/dgraph/deps.nix b/pkgs/servers/dgraph/deps.nix
new file mode 100644
index 000000000000..89e00e0d8cb3
--- /dev/null
+++ b/pkgs/servers/dgraph/deps.nix
@@ -0,0 +1,326 @@
+[
+  {
+    goPackagePath = "github.com/AndreasBriese/bbloom";
+    fetch = {
+      type = "git";
+      url = "https://github.com/AndreasBriese/bbloom";
+      rev = "28f7e881ca57bc00e028f9ede9f0d9104cfeef5e";
+      sha256 = "03cqhqvdz8c9by5w5ls4kwnnwlm6b2kkslc6m120fanw1lgamfzp";
+    };
+  }
+  {
+    goPackagePath = "github.com/MakeNowJust/heredoc";
+    fetch = {
+      type = "git";
+      url = "https://github.com/MakeNowJust/heredoc";
+      rev = "1d91351acdc1cb2f2c995864674b754134b86ca7";
+      sha256 = "0ia1r8ibqmx6zv3wmsvgkpqlhwk79z9l38nzp4gd4f1kcb46856x";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/bkaradzic/go-lz4";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bkaradzic/go-lz4";
+      rev = "7224d8d8f27ef618c0a95f1ae69dbb0488abc33a";
+      sha256 = "10lmya17vdqg2pvqni0p73iahni48s1v11ya9a0hcz4jh5vw4dkb";
+    };
+  }
+  {
+    goPackagePath = "github.com/blevesearch/bleve";
+    fetch = {
+      type = "git";
+      url = "https://github.com/blevesearch/bleve";
+      rev = "a7ebb8480579777c6cd1c4750d2e6b5ff2b49bdd";
+      sha256 = "121jhd158slf4050kmghz25jrvv7gbsan31wr0nxyw9z32lyf6yx";
+    };
+  }
+  {
+    goPackagePath = "github.com/blevesearch/blevex";
+    fetch = {
+      type = "git";
+      url = "https://github.com/blevesearch/blevex";
+      rev = "507dcd576550f9f3260f11495ba2de4e96773a3e";
+      sha256 = "0i9azysvia99fjpx525qnc5rcgv45hfvl3zcs58gvgqyxpzpc78z";
+    };
+  }
+  {
+    goPackagePath = "github.com/blevesearch/go-porterstemmer";
+    fetch = {
+      type = "git";
+      url = "https://github.com/blevesearch/go-porterstemmer";
+      rev = "23a2c8e5cf1f380f27722c6d2ae8896431dc7d0e";
+      sha256 = "0rcfbrad79xd114h3dhy5d3zs3b5bcgqwm3h5ih1lk69zr9wi91d";
+    };
+  }
+  {
+    goPackagePath = "github.com/blevesearch/segment";
+    fetch = {
+      type = "git";
+      url = "https://github.com/blevesearch/segment";
+      rev = "762005e7a34fd909a84586299f1dd457371d36ee";
+      sha256 = "1nrm145sm0xlhqy3d12yipnb16ikjz9ykjcskmkgm7vjm47xkmfl";
+    };
+  }
+  {
+    goPackagePath = "github.com/cockroachdb/cmux";
+    fetch = {
+      type = "git";
+      url = "https://github.com/cockroachdb/cmux";
+      rev = "30d10be492927e2dcae0089c374c455d42414fcb";
+      sha256 = "0ixif6hwcm2dpi1si5ah49dmdyy5chillz1048jpvjzwzxyfv1nx";
+    };
+  }
+  {
+    goPackagePath = "github.com/codahale/hdrhistogram";
+    fetch = {
+      type = "git";
+      url = "https://github.com/codahale/hdrhistogram";
+      rev = "3a0bb77429bd3a61596f5e8a3172445844342120";
+      sha256 = "1zampgfjbxy192cbwdi7g86l1idxaam96d834wncnpfdwgh5kl57";
+    };
+  }
+  {
+    goPackagePath = "github.com/coreos/etcd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/etcd";
+      rev = "9d43462d174c664f5edf313dec0de31e1ef4ed47";
+      sha256 = "0qxqjxhhciaacag1jz2rlncmlgw861ig2yx993ylvfm30jvyj2cj";
+    };
+  }
+  {
+    goPackagePath = "github.com/davecgh/go-spew";
+    fetch = {
+      type = "git";
+      url = "https://github.com/davecgh/go-spew";
+      rev = "6d212800a42e8ab5c146b8ace3490ee17e5225f9";
+      sha256 = "01i0n1s4j7khb7n6mz2wymniz37q0vbzkgfv7rbi6p9hpg227q93";
+    };
+  }
+  {
+    goPackagePath = "github.com/dgraph-io/badger";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dgraph-io/badger";
+      rev = "64df7f57d9ee20d7b28de4a3eea90bf8d7310a77";
+      sha256 = "1ikgzn2l62kb238n0wm6s95py5ypv71p09w7zyvzkjf34x675mzz";
+    };
+  }
+  {
+    goPackagePath = "github.com/dgryski/go-farm";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dgryski/go-farm";
+      rev = "d1e51a4af19092715f4ce7d8257fe5bc8f8be727";
+      sha256 = "00iijjzdg8g6jbzhdbfw8s2rf0k25gxw4x7h7r6mkxcq18n69182";
+    };
+  }
+  {
+    goPackagePath = "github.com/gogo/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gogo/protobuf";
+      rev = "e57a569e1882958f6b188cb42231d6db87701f2a";
+      sha256 = "0r3jpmp6wp4xyrh1ikr8iqld3rg4r1yhv99zxw5zd7d2zprw9yfc";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/geo";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/geo";
+      rev = "31fb0106dc4a947e5aaee1fe186e56447f839510";
+      sha256 = "00w4kwm98hrgr3ggfdk1h7qa5gp00z4s0j0iwgwd9rgadb59kb2c";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "2bba0603135d7d7f5cb73b2125beeda19c09f4ef";
+      sha256 = "1xy0bj66qks2xlzxzlfma16w7m8g6rrwawmlhlv68bcw2k5hvvib";
+    };
+  }
+  {
+    goPackagePath = "github.com/google/codesearch";
+    fetch = {
+      type = "git";
+      url = "https://github.com/google/codesearch";
+      rev = "a45d81b686e85d01f2838439deaf72126ccd5a96";
+      sha256 = "12bv3yz0l3bmsxbasfgv7scm9j719ch6pmlspv4bd4ix7wjpyhny";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/errors";
+      rev = "17b591df37844cde689f4d5813e5cea0927d8dd2";
+      sha256 = "1f400f1682h1wdjknlh1ad95rbss09g0ia36a8w102bf2f1qfq8l";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/profile";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/profile";
+      rev = "5b67d428864e92711fcbd2f8629456121a56d91f";
+      sha256 = "0blqmvgqvdbqmh3fp9pfdxc9w1qfshrr0zy9whj0sn372bw64qnr";
+    };
+  }
+  {
+    goPackagePath = "github.com/pmezard/go-difflib";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pmezard/go-difflib";
+      rev = "792786c7400a136282c1664665ae0a8db921c6c2";
+      sha256 = "0c1cn55m4rypmscgf0rrb88pn58j3ysvc2d0432dp3c6fqg6cnzw";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "310ce84375bb84c5cbbf0d05069c92daa5673740";
+      sha256 = "11awb5bjkwqj7va3v7fgniwqkjqhmhjkp01rdvnv4xfp1laxwn7v";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "6f3806018612930941127f2a7c6c453ba2c527d2";
+      sha256 = "1413ibprinxhni51p0755dp57r9wvbw7xgj9nmdaxmhzlqhc86j4";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "0866df4b85a18d652b6965be022d007cdf076822";
+      sha256 = "0zw4rxs6zh9vgxz5wwhjnwa6mgac8jh7mb63viircgh08r889chp";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "e645f4e5aaa8506fc71d6edbc5c4ff02c04c46f2";
+      sha256 = "18hwygbawbqilz7h8fl25xpbciwalkslb4igqn4cr9d8sqp7d3np";
+    };
+  }
+  {
+    goPackagePath = "github.com/stretchr/testify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stretchr/testify";
+      rev = "976c720a22c8eb4eb6a0b4348ad85ad12491a506";
+      sha256 = "0a2gxvqzacrj9k8h022zhr8fchhn9afc6a511m07j71dzw9g4y3m";
+    };
+  }
+  {
+    goPackagePath = "github.com/tebeka/snowball";
+    fetch = {
+      type = "git";
+      url = "https://github.com/tebeka/snowball";
+      rev = "6b06bd306c4e4442a63e546752278920ae487934";
+      sha256 = "110akijkb55k5h7m6mra8fircvi4sxd5xq7lcjgyiqj96srq8v2k";
+    };
+  }
+  {
+    goPackagePath = "github.com/twpayne/go-geom";
+    fetch = {
+      type = "git";
+      url = "https://github.com/twpayne/go-geom";
+      rev = "6753ad11e46b04e21b3f286b342e73a8c4be8216";
+      sha256 = "0qyrdnp7j7lmj0qb0p7k45m757zvbwn78s1apiy46zfnb5415df1";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "22ddb68eccda408bbf17759ac18d3120ce0d4f3f";
+      sha256 = "07ks6qal02iz24vv54qyb90wmsg9vwqc14abf68rakprpy26qwsg";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "d1e1b351919c6738fdeb9893d5c998b161464f0c";
+      sha256 = "0qzbfah03z992zyygfp7imjjas5np2gcar5aanx5y3av5g68ggjp";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "abf9c25f54453410d0c6668e519582a9e1115027";
+      sha256 = "0dmpqjfif2zg6776d366js60k21g81jvsr3jm9dc7fv7w3282al4";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "1cbadb444a806fd9430d14ad08967ed91da4fa0a";
+      sha256 = "0ih9ysagh4ylj08393497sscf3yziybc6acg4mrh0wa7mld75j56";
+    };
+  }
+  {
+    goPackagePath = "google.golang.org/genproto";
+    fetch = {
+      type = "git";
+      url = "https://github.com/google/go-genproto";
+      rev = "1e559d0a00eef8a9a43151db4665280bd8dd5886";
+      sha256 = "1dfm8zd9mif1aswks79wgyi7n818s5brbdnnrrlg79whfhaf20hd";
+    };
+  }
+  {
+    goPackagePath = "google.golang.org/grpc";
+    fetch = {
+      type = "git";
+      url = "https://github.com/grpc/grpc-go";
+      rev = "f92cdcd7dcdc69e81b2d7b338479a19a8723cfa3";
+      sha256 = "1li8rn2s4f8qc77npamlm2ijin44scb8vvd8c4cr0l7za2m89jfn";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/yaml.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/yaml.v2";
+      rev = "a5b47d31c556af34a302ce5d659e6fea44d90de0";
+      sha256 = "0v6l48fshdjrqzyq1kwn22gy7vy434xdr1i0lm3prsf6jbln9fam";
+    };
+  }
+]
diff --git a/pkgs/servers/dico/default.nix b/pkgs/servers/dico/default.nix
index f898034719f3..8958daa1a70a 100644
--- a/pkgs/servers/dico/default.nix
+++ b/pkgs/servers/dico/default.nix
@@ -1,17 +1,19 @@
 { fetchurl, stdenv, libtool, gettext, zlib, readline, gsasl
-, guile, python, pcre, libffi }:
+, guile, python, pcre, libffi, groff }:
 
 stdenv.mkDerivation rec {
-  name = "dico-2.2";
+  name = "dico-2.5";
 
   src = fetchurl {
     url = "mirror://gnu/dico/${name}.tar.xz";
-    sha256 = "04pjks075x20d19l623mj50bw64g8i41s63z4kzzqcbg9qg96x64";
+    sha256 = "0szm3z4xvq0pjj8kxl4paq63byamf281kzn1la0cdm5ngavypxxq";
   };
 
+  hardeningDisable = [ "format" ];
+
   # XXX: Add support for GNU SASL.
   buildInputs =
-    [ libtool gettext zlib readline gsasl guile python pcre libffi ];
+    [ libtool gettext zlib readline gsasl guile python pcre libffi groff ];
 
   # dicod fails to load modules, so the tests fail
   doCheck = false;
diff --git a/pkgs/servers/dict/default.nix b/pkgs/servers/dict/default.nix
index ee0477734c2f..6868c0f81664 100644
--- a/pkgs/servers/dict/default.nix
+++ b/pkgs/servers/dict/default.nix
@@ -1,22 +1,35 @@
 { stdenv, fetchurl, which, bison, flex, libmaa, zlib, libtool }:
 
 stdenv.mkDerivation rec {
-  version = "1.12.1";
   name = "dictd-${version}";
+  version = "1.12.1";
 
   src = fetchurl {
     url = "mirror://sourceforge/dict/dictd-${version}.tar.gz";
     sha256 = "0min6v60b6z5mrymyjfwzx8nv6rdm8pd8phlwl6v2jl5vkngcdx2";
   };
 
-  buildInputs = [ flex bison which libmaa zlib libtool ];
+  buildInputs = [ libmaa zlib ];
+
+  nativeBuildInputs = [ bison flex libtool which ];
+
+  # Makefile(.in) contains "clientparse.c clientparse.h: clientparse.y" which
+  # causes bison to run twice, and break the build when this happens in
+  # parallel.  Test with "make -j clientparse.c clientparse.h".  The error
+  # message may be "mv: cannot move 'y.tab.c' to 'clientparse.c'".
+  enableParallelBuilding = false;
 
   patchPhase = "patch -p0 < ${./buildfix.diff}";
-  configureFlags = "--datadir=/var/run/current-system/share/dictd";
+  configureFlags = [
+    "--enable-dictorg"
+    "--datadir=/run/current-system/share/dictd"
+  ];
 
   meta = with stdenv.lib; {
     description = "Dict protocol server and client";
-    maintainers = [ maintainers.mornfall ];
-    platforms = platforms.linux;
+    homepage    = http://www.dict.org;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ ];
+    platforms   = platforms.linux;
   };
 }
diff --git a/pkgs/servers/dict/dictd-db.nix b/pkgs/servers/dict/dictd-db.nix
index 5f109c58e6e4..70cd362c5ea3 100644
--- a/pkgs/servers/dict/dictd-db.nix
+++ b/pkgs/servers/dict/dictd-db.nix
@@ -1,91 +1,95 @@
-{ builderDefs }:
+{ stdenv, fetchurl, callPackage }:
 
-let makeDictdDB = _src: _name: _subdir: _locale:
-with builderDefs;
-	let localDefs = builderDefs.passthru.function (rec {
-		src=_src;
-		doInstall = fullDepEntry (''
-			mkdir -p $out/share/dictd
-			tar xf  ${src}
-			cp $(ls ./${_subdir}/*.{dict*,index} || true) $out/share/dictd 
-			echo "${_locale}" >$out/share/dictd/locale
-		'') ["minInit" "addInputs" "defEnsureDir"];
+let
+ # Probably a bug in some FreeDict release files, but easier to trivially
+ # work around than report. Not that it can cause any other problems..
+ makeDictdDBFreedict = src: name: locale:
+   makeDictdDB src name "{.,bin}" locale;
 
-		buildInputs = [];
-		configureFlags = [];
-	});
-	in with localDefs;
-stdenv.mkDerivation rec {
-	name = "dictd-db-${_name}";
-	locale = _locale;
-	dbName = _name;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs 
-			[doInstall doForceShare doPropagate]);
-	meta = {
-		description = "${name} dictionary for dictd";
-	};
-};
-# Probably a bug in some FreeDict release files, but easier to trivially
-# work around than report. Not that it can cause any other problems..
-makeDictdDBFreedict = _src: _name: _locale: makeDictdDB _src _name "{.,bin}" _locale;
-fetchurl = builderDefs.fetchurl;
+ makeDictdDB = src: _name: _subdir: _locale:
+   stdenv.mkDerivation rec {
+     name = "dictd-db-${_name}";
+     inherit src;
+     locale = _locale;
+     dbName = _name;
+     buildPhase = ":";
+     unpackPhase = ''
+       tar xf  ${src}
+     '';
+     installPhase = ''
+       mkdir -p $out/share/dictd
+       cp $(ls ./${_subdir}/*.{dict*,index} || true) $out/share/dictd
+       echo "${_locale}" >$out/share/dictd/locale
+     '';
 
-in 
-
-rec {
-	nld2eng = makeDictdDBFreedict (fetchurl {
-		url = http://prdownloads.sourceforge.net/freedict/nld-eng.tar.gz;
-		sha256 = "1vhw81pphb64fzsjvpzsnnyr34ka2fxizfwilnxyjcmpn9360h07";
-	}) "nld-eng" "nl_NL";
-	eng2nld =  makeDictdDBFreedict (fetchurl {
-		url = http://downloads.sourceforge.net/freedict/eng-nld.tar.gz;
-		sha256 = "0rcg28ldykv0w2mpxc6g4rqmfs33q7pbvf68ssy1q9gpf6mz7vcl";
-	}) "eng-nld" "en_UK";
-	eng2rus = makeDictdDBFreedict (fetchurl {
-		url = http://downloads.sourceforge.net/freedict/eng-rus.tar.gz;
-		sha256 = "15409ivhww1wsfjr05083pv6mg10bak8v5pg1wkiqybk7ck61rry";
-	}) "eng-rus" "en_UK";
-	fra2eng = makeDictdDBFreedict (fetchurl {
-		url = http://downloads.sourceforge.net/freedict/fra-eng.tar.gz;
-		sha256 = "0sdd88s2zs5whiwdf3hd0s4pzzv75sdsccsrm1wxc87l3hjm85z3";
-	}) "fra-eng" "fr_FR";
-	eng2fra = makeDictdDBFreedict (fetchurl {
-		url = http://downloads.sourceforge.net/freedict/eng-fra.tar.gz;
-		sha256 = "0fi6rrnbqnhc6lq8d0nmn30zdqkibrah0mxfg27hsn9z7alwbj3m";
-	}) "eng-fra" "en_UK";
-	mueller_eng2rus_pkg = makeDictdDB (fetchurl {
-		url = http://downloads.sourceforge.net/mueller-dict/mueller-dict-3.1.tar.gz;
-		sha256 = "04r5xxznvmcb8hkxqbjgfh2gxvbdd87jnhqn5gmgvxxw53zpwfmq";
-	}) "mueller-eng-rus" "mueller-dict-*/dict" "en_UK";
-	mueller_enru_abbr = {
-		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-abbrev";
-		name = "mueller-abbr";
-		dbName = "mueller-abbr";
-		locale = "en_UK";
-	};
-	mueller_enru_base = {
-		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-base";
-		name = "mueller-base";
-		dbName = "mueller-base";
-		locale = "en_UK";
-	};
-	mueller_enru_dict = {
-		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-dict";
-		name = "mueller-dict";
-		dbName = "mueller-dict";
-		locale = "en_UK";
-	};
-	mueller_enru_geo = {
-		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-geo";
-		name = "mueller-geo";
-		dbName = "mueller-geo";
-		locale = "en_UK";
-	};
-	mueller_enru_names = {
-		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-names";
-		name = "mueller-names";
-		dbName = "mueller-names";
-		locale = "en_UK";
-	};
+     meta = {
+       description = "dictd-db dictionary for dictd";
+       platforms = stdenv.lib.platforms.linux;
+     };
+   };
+in rec {
+  deu2eng = makeDictdDBFreedict (fetchurl {
+    url = http://prdownloads.sourceforge.net/freedict/deu-eng.tar.gz;
+    sha256 = "0dqrhv04g4f5s84nbgisgcfwk5x0rpincif0yfhfh4sc1bsvzsrb";
+  }) "deu-eng" "de_DE";
+  eng2deu = makeDictdDBFreedict (fetchurl {
+    url = http://prdownloads.sourceforge.net/freedict/eng-deu.tar.gz;
+    sha256 = "01x12p72sa3071iff3jhzga8588440f07zr56r3x98bspvdlz73r";
+  }) "eng-deu" "en_EN";
+  nld2eng = makeDictdDBFreedict (fetchurl {
+    url = http://prdownloads.sourceforge.net/freedict/nld-eng.tar.gz;
+    sha256 = "1vhw81pphb64fzsjvpzsnnyr34ka2fxizfwilnxyjcmpn9360h07";
+  }) "nld-eng" "nl_NL";
+  eng2nld =  makeDictdDBFreedict (fetchurl {
+    url = mirror://sourceforge/freedict/eng-nld.tar.gz;
+    sha256 = "0rcg28ldykv0w2mpxc6g4rqmfs33q7pbvf68ssy1q9gpf6mz7vcl";
+  }) "eng-nld" "en_UK";
+  eng2rus = makeDictdDBFreedict (fetchurl {
+    url = mirror://sourceforge/freedict/eng-rus.tar.gz;
+    sha256 = "15409ivhww1wsfjr05083pv6mg10bak8v5pg1wkiqybk7ck61rry";
+  }) "eng-rus" "en_UK";
+  fra2eng = makeDictdDBFreedict (fetchurl {
+    url = mirror://sourceforge/freedict/fra-eng.tar.gz;
+    sha256 = "0sdd88s2zs5whiwdf3hd0s4pzzv75sdsccsrm1wxc87l3hjm85z3";
+  }) "fra-eng" "fr_FR";
+  eng2fra = makeDictdDBFreedict (fetchurl {
+    url = mirror://sourceforge/freedict/eng-fra.tar.gz;
+    sha256 = "0fi6rrnbqnhc6lq8d0nmn30zdqkibrah0mxfg27hsn9z7alwbj3m";
+  }) "eng-fra" "en_UK";
+  mueller_eng2rus_pkg = makeDictdDB (fetchurl {
+    url = mirror://sourceforge/mueller-dict/mueller-dict-3.1.tar.gz;
+    sha256 = "04r5xxznvmcb8hkxqbjgfh2gxvbdd87jnhqn5gmgvxxw53zpwfmq";
+  }) "mueller-eng-rus" "mueller-dict-*/dict" "en_UK";
+  mueller_enru_abbr = {
+    outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-abbrev";
+    name = "mueller-abbr";
+    dbName = "mueller-abbr";
+    locale = "en_UK";
+  };
+  mueller_enru_base = {
+    outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-base";
+    name = "mueller-base";
+    dbName = "mueller-base";
+    locale = "en_UK";
+  };
+  mueller_enru_dict = {
+    outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-dict";
+    name = "mueller-dict";
+    dbName = "mueller-dict";
+    locale = "en_UK";
+  };
+  mueller_enru_geo = {
+    outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-geo";
+    name = "mueller-geo";
+    dbName = "mueller-geo";
+    locale = "en_UK";
+  };
+  mueller_enru_names = {
+    outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-names";
+    name = "mueller-names";
+    dbName = "mueller-names";
+    locale = "en_UK";
+  };
+  wordnet = callPackage ./dictd-wordnet.nix {};
+  wiktionary = callPackage ./dictd-wiktionary.nix {};
 }
diff --git a/pkgs/servers/dict/dictd-wiktionary.nix b/pkgs/servers/dict/dictd-wiktionary.nix
index 42eb3c0757e3..13e4757fe89e 100644
--- a/pkgs/servers/dict/dictd-wiktionary.nix
+++ b/pkgs/servers/dict/dictd-wiktionary.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, python, dict, glibcLocales, writeScript}:
 
 stdenv.mkDerivation rec {
-  version = "20140118";
+  version = "20161001";
   name = "dict-db-wiktionary-${version}";
   data = fetchurl {
     url = "http://dumps.wikimedia.org/enwiktionary/${version}/enwiktionary-${version}-pages-articles.xml.bz2";
-    sha256 = "892c9fc16b248a31e2d3e42590267161c1b899b31fe923eb1ede1deb6d24cfa8";
+    sha256 = "0g3k7kxp2nzg0v56i4cz253af3aqvhn1lwkys2fnam51cn3yqm7m";
   };
 
   convert = ./wiktionary2dict.py;
@@ -25,7 +25,7 @@ stdenv.mkDerivation rec {
   meta = {
     description = "DICT version of English Wiktionary";
     homepage = http://en.wiktionary.org/;
-    maintainers = [ stdenv.lib.maintainers.mornfall ];
+    maintainers = [ ];
     platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/servers/dict/dictd-wordnet.nix b/pkgs/servers/dict/dictd-wordnet.nix
index b6680e8b21c4..13a78d61098b 100644
--- a/pkgs/servers/dict/dictd-wordnet.nix
+++ b/pkgs/servers/dict/dictd-wordnet.nix
@@ -28,9 +28,9 @@ stdenv.mkDerivation rec {
          the wordnet data available to dictd and by extension for lookup with
          the dict command. '';
 
-    homepage = http://wordnet.princeton.edu/;
+    homepage = https://wordnet.princeton.edu/;
 
-    maintainers = [ stdenv.lib.maintainers.mornfall ];
+    maintainers = [ ];
     platforms = stdenv.lib.platforms.all;
   };
 }
diff --git a/pkgs/servers/dict/libmaa.nix b/pkgs/servers/dict/libmaa.nix
index 833aaa95b0ca..d35a9a683031 100644
--- a/pkgs/servers/dict/libmaa.nix
+++ b/pkgs/servers/dict/libmaa.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Dict protocol server and client";
-    maintainers = [ maintainers.mornfall ];
+    maintainers = [ ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/servers/diod/default.nix b/pkgs/servers/diod/default.nix
index dcda4e8c0bb4..a233b6ba4cf8 100644
--- a/pkgs/servers/diod/default.nix
+++ b/pkgs/servers/diod/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "diod-${version}";
-  version = "1.0.23";
+  version = "1.0.24";
 
   src = fetchurl {
     url = "https://github.com/chaos/diod/releases/download/${version}/${name}.tar.gz";
-    sha256 = "002vxc9fwdwshda4jydxagr63xd6nnhbc6fh73974gi2pvp6gid3";
+    sha256 = "17wckwfsqj61yixz53nwkc35z66arb1x3napahpi64m7q68jn7gl";
   };
 
   buildInputs = [ munge lua libcap perl ncurses ];
diff --git a/pkgs/servers/dns/bind/darwin-openssl-linking-fix.patch b/pkgs/servers/dns/bind/darwin-openssl-linking-fix.patch
new file mode 100644
index 000000000000..8276c28c3f4b
--- /dev/null
+++ b/pkgs/servers/dns/bind/darwin-openssl-linking-fix.patch
@@ -0,0 +1,26 @@
+diff --git a/configure b/configure
+index b9ad66b..a2a7382 100755
+--- a/configure
++++ b/configure
+@@ -16033,21 +16033,6 @@ $as_echo "not found" >&6; }
+ 			*-hp-hpux*)
+ 				DST_OPENSSL_LIBS="-L$use_openssl/lib -Wl,+b: -lcrypto"
+ 				;;
+-			*-apple-darwin*)
+-				#
+-				# Apple's ld seaches for serially for dynamic
+-				# then static libraries.  This means you can't
+-				# use -L to override dynamic system libraries
+-				# with static ones when linking.  Instead
+-				# we specify a absolute path.
+-				#
+-				if test -f "$use_openssl/lib/libcrypto.dylib"
+-				then
+-					DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
+-				else
+-					DST_OPENSSL_LIBS="$use_openssl/lib/libcrypto.a"
+-				fi
+-				;;
+ 			*)
+ 				DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
+ 				;;
diff --git a/pkgs/servers/dns/bind/default.nix b/pkgs/servers/dns/bind/default.nix
index c44f507f2ead..b0fb29677f9a 100644
--- a/pkgs/servers/dns/bind/default.nix
+++ b/pkgs/servers/dns/bind/default.nix
@@ -1,43 +1,87 @@
-{ stdenv, fetchurl, openssl, libtool, perl, libxml2 }:
+{ stdenv, lib, fetchurl
+, perl
+, libcap, libtool, libxml2, openssl
+, enablePython ? false, python3 ? null
+, enableSeccomp ? false, libseccomp ? null, buildPackages
+}:
 
-let version = "9.10.3"; in
+assert enableSeccomp -> libseccomp != null;
+assert enablePython -> python3 != null;
+
+let version = "9.12.1-P2"; in
 
 stdenv.mkDerivation rec {
   name = "bind-${version}";
 
   src = fetchurl {
     url = "http://ftp.isc.org/isc/bind9/${version}/${name}.tar.gz";
-    sha256 = "1w4gp4hdkb452nmz91l413d1rx89isl2l6wv8kpbdd2afpc3phws";
+    sha256 = "0a9dvyg1dk7vpqn9gz7p5jas3bz7z22bjd66b98g1qk16i2w7rqd";
   };
 
-  patchPhase = ''
-    sed -i 's/^\t.*run/\t/' Makefile.in
-  '';
+  outputs = [ "out" "lib" "dev" "man" "dnsutils" "host" ];
+
+  patches = [ ./dont-keep-configure-flags.patch ./remove-mkdir-var.patch ] ++
+    stdenv.lib.optional stdenv.isDarwin ./darwin-openssl-linking-fix.patch;
 
-  buildInputs = [ openssl libtool perl libxml2 ];
+  nativeBuildInputs = [ perl ];
+  buildInputs = [ libtool libxml2 openssl ]
+    ++ lib.optional stdenv.isLinux libcap
+    ++ lib.optional enableSeccomp libseccomp
+    ++ lib.optional enablePython python3;
+
+  STD_CDEFINES = [ "-DDIG_SIGCHASE=1" ]; # support +sigchase
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   configureFlags = [
     "--localstatedir=/var"
     "--with-libtool"
-    "--with-libxml2=${libxml2}"
-    "--with-openssl=${openssl}"
+    "--with-libxml2=${libxml2.dev}"
+    "--with-openssl=${openssl.dev}"
+    (if enablePython then "--with-python" else "--without-python")
     "--without-atf"
     "--without-dlopen"
     "--without-docbook-xsl"
     "--without-gssapi"
     "--without-idn"
     "--without-idnlib"
+    "--without-lmdb"
+    "--without-libjson"
     "--without-pkcs11"
     "--without-purify"
-    "--without-python"
-  ];
+    "--with-randomdev=/dev/random"
+    "--with-ecdsa"
+    "--with-gost"
+    "--without-eddsa"
+    "--with-aes"
+  ] ++ lib.optional stdenv.isLinux "--with-libcap=${libcap.dev}"
+    ++ lib.optional enableSeccomp "--enable-seccomp";
+
+  postInstall = ''
+    moveToOutput bin/bind9-config $dev
+    moveToOutput bin/isc-config.sh $dev
+
+    moveToOutput bin/host $host
+
+    moveToOutput bin/dig $dnsutils
+    moveToOutput bin/nslookup $dnsutils
+    moveToOutput bin/nsupdate $dnsutils
+
+    for f in "$lib/lib/"*.la "$dev/bin/"{isc-config.sh,bind*-config}; do
+      sed -i "$f" -e 's|-L${openssl.dev}|-L${openssl.out}|g'
+    done
+  '';
+
+  doCheck = false; # requires root and the net
 
   meta = {
-    homepage = "http://www.isc.org/software/bind";
+    homepage = http://www.isc.org/software/bind;
     description = "Domain name server";
-    license = stdenv.lib.licenses.isc;
+    license = stdenv.lib.licenses.mpl20;
 
-    maintainers = with stdenv.lib.maintainers; [viric simons];
+    maintainers = with stdenv.lib.maintainers; [viric peti];
     platforms = with stdenv.lib.platforms; unix;
+
+    outputsToInstall = [ "out" "dnsutils" "host" ];
   };
 }
diff --git a/pkgs/servers/dns/bind/dont-keep-configure-flags.patch b/pkgs/servers/dns/bind/dont-keep-configure-flags.patch
new file mode 100644
index 000000000000..5a934056d13d
--- /dev/null
+++ b/pkgs/servers/dns/bind/dont-keep-configure-flags.patch
@@ -0,0 +1,41 @@
+diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h
+index 388dc97..3c6135c 100644
+--- a/bin/named/include/named/globals.h
++++ b/bin/named/include/named/globals.h
+@@ -65,7 +65,9 @@ EXTERN const char *		named_g_version		INIT(VERSION);
+ EXTERN const char *		named_g_product		INIT(PRODUCT);
+ EXTERN const char *		named_g_description	INIT(DESCRIPTION);
+ EXTERN const char *		named_g_srcid		INIT(SRCID);
++#if 0
+ EXTERN const char *		named_g_configargs	INIT(CONFIGARGS);
++#endif
+ EXTERN const char *		named_g_builder		INIT(BUILDER);
+ EXTERN in_port_t		named_g_port		INIT(0);
+ EXTERN isc_dscp_t		named_g_dscp		INIT(-1);
+diff --git a/bin/named/main.c b/bin/named/main.c
+index 4fb0566..60d56cd 100644
+--- a/bin/named/main.c
++++ b/bin/named/main.c
+@@ -672,8 +672,10 @@ parse_command_line(int argc, char *argv[]) {
+ 			       (*named_g_description != '\0') ? " " : "",
+ 			       named_g_description, named_g_srcid);
+ 			printf("running on %s\n", named_os_uname());
++			#if 0
+ 			printf("built by %s with %s\n",
+ 			       named_g_builder, named_g_configargs);
++			#endif
+ #ifdef __clang__
+ 			printf("compiled by CLANG %s\n", __VERSION__);
+ #else
+@@ -1075,9 +1077,11 @@ setup(void) {
+ 		      NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
+ 		      "running on %s", named_os_uname());
+ 
++#if 0
+ 	isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+ 		      NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
+ 		      "built with %s", named_g_configargs);
++#endif
+ 
+ 	isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+ 		      NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
diff --git a/pkgs/servers/dns/bind/remove-mkdir-var.patch b/pkgs/servers/dns/bind/remove-mkdir-var.patch
new file mode 100644
index 000000000000..d0dcd580c20a
--- /dev/null
+++ b/pkgs/servers/dns/bind/remove-mkdir-var.patch
@@ -0,0 +1,12 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -53,8 +53,7 @@ docclean manclean maintainer-clean::
+ doc man:: ${MANOBJS}
+ 
+ installdirs:
+-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir} \
+-	${DESTDIR}${localstatedir}/run ${DESTDIR}${sysconfdir}
++	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir} ${DESTDIR}${sysconfdir}
+	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man1
+ 
+ install:: isc-config.sh installdirs
diff --git a/pkgs/servers/dns/coredns/default.nix b/pkgs/servers/dns/coredns/default.nix
new file mode 100644
index 000000000000..6dcb8fbbd772
--- /dev/null
+++ b/pkgs/servers/dns/coredns/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "coredns-${version}";
+  version = "005";
+
+  goPackagePath = "github.com/miekg/coredns";
+  subPackages = [ "." ];
+
+  src = fetchFromGitHub {
+    owner = "miekg";
+    repo = "coredns";
+    rev = "v${version}";
+    sha256 = "11wvy3xp9in5ny6h7hp24dq6asc013vrwc6bqiky83dlzasjwkf6";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    homepage = https://coredns.io;
+    description = "A DNS server that runs middleware";
+    license = licenses.asl20;
+    maintainers = [ maintainers.rushmorem maintainers.rtreffer ];
+  };
+}
diff --git a/pkgs/servers/dns/coredns/deps.nix b/pkgs/servers/dns/coredns/deps.nix
new file mode 100644
index 000000000000..18bd2b1f85d8
--- /dev/null
+++ b/pkgs/servers/dns/coredns/deps.nix
@@ -0,0 +1,317 @@
+[
+  {
+    goPackagePath = "github.com/cockroachdb/cmux";
+    fetch = {
+      type = "git";
+      url = "https://github.com/cockroachdb/cmux";
+      rev = "30d10be492927e2dcae0089c374c455d42414fcb";
+      sha256 = "0ixif6hwcm2dpi1si5ah49dmdyy5chillz1048jpvjzwzxyfv1nx";
+    };
+  }
+  {
+    goPackagePath = "github.com/coreos/go-semver";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/go-semver";
+      rev = "5e3acbb5668c4c3deb4842615c4098eb61fb6b1e";
+      sha256 = "0kbfr8q7s10z2r01xvbv6i31n4wq6z1qvgfj7njgbcgb65bkjjrh";
+    };
+  }
+  {
+    goPackagePath = "github.com/eapache/go-xerial-snappy";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eapache/go-xerial-snappy";
+      rev = "bb955e01b9346ac19dc29eb16586c90ded99a98c";
+      sha256 = "1zhxcil8hn88hvxr2d6rmj4cls5zgss1scj0ikwiqq89f8vcgwn4";
+    };
+  }
+  {
+    goPackagePath = "github.com/eapache/queue";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eapache/queue";
+      rev = "44cc805cf13205b55f69e14bcb69867d1ae92f98";
+      sha256 = "07dp54n94gn3gsvdcki56yqh7py7wqqigxbamhxwgbr05n61fqyg";
+    };
+  }
+  {
+    goPackagePath = "github.com/flynn/go-shlex";
+    fetch = {
+      type = "git";
+      url = "https://github.com/flynn/go-shlex";
+      rev = "3f9db97f856818214da2e1057f8ad84803971cff";
+      sha256 = "1j743lysygkpa2s2gii2xr32j7bxgc15zv4113b0q9jhn676ysia";
+    };
+  }
+  {
+    goPackagePath = "github.com/fsnotify/fsnotify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/fsnotify/fsnotify";
+      rev = "a904159b9206978bb6d53fcc7a769e5cd726c737";
+      sha256 = "0qq758fcnhlqa1913jki79a1ic7p2iczdx1l2mn8s886nxydn0fi";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/snappy";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/snappy";
+      rev = "553a641470496b2327abcac10b36396bd98e45c9";
+      sha256 = "0kssxnih1l722hx9219c7javganjqkqhvl3i0hp0hif6xm6chvqk";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-logfmt/logfmt";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-logfmt/logfmt";
+      rev = "390ab7935ee28ec6b286364bba9b4dd6410cb3d5";
+      sha256 = "1gkgh3k5w1xwb2qbjq52p6azq3h1c1rr6pfwjlwj1zrijpzn2xb9";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/golang-lru";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/golang-lru";
+      rev = "0a025b7e63adc15a622f29b0b2c4c3848243bbf6";
+      sha256 = "1iq7lbpsz7ks052mpznmkf8s4k43p51z4dik2n9ivrxk666q2wxi";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/go-syslog";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/go-syslog";
+      rev = "b609c7d9de4658cded34a7336b90886c56f9dbdb";
+      sha256 = "1k0dqkizj4vwgdsb7x7fzmcgz9079sczhpn9whd0r3xcnqs7pkkb";
+    };
+  }
+  {
+    goPackagePath = "github.com/klauspost/crc32";
+    fetch = {
+      type = "git";
+      url = "https://github.com/klauspost/crc32";
+      rev = "1bab8b35b6bb565f92cbc97939610af9369f942a";
+      sha256 = "0n71bf2xkrk3b6svzsph3brwvam0cbz21pcwyymdw8scdn7mmyak";
+    };
+  }
+  {
+    goPackagePath = "github.com/mholt/caddy";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mholt/caddy";
+      rev = "60838710883baa70cf6aae08e73820b21134ee72";
+      sha256 = "15dx12sap8ziwyn2wkgiy7fj1s320444zh0pn32mwjvn065c2k3z";
+    };
+  }
+  {
+    goPackagePath = "github.com/miekg/coredns";
+    fetch = {
+      type = "git";
+      url = "https://github.com/miekg/coredns";
+      rev = "a7c9fd5d6b5157958a3df8dba0cdc1f24407957b";
+      sha256 = "11zbwx74hhgrd3qlwm91gqw6zcj4yf7af54cn3183ca8v66f3xyf";
+    };
+  }
+  {
+    goPackagePath = "github.com/miekg/dns";
+    fetch = {
+      type = "git";
+      url = "https://github.com/miekg/dns";
+      rev = "75229eecb7af00b2736e93b779a78429dcb19472";
+      sha256 = "1vsjy07kkyx11iz4qsihhykac3ddq3ywdgv6bwrv407504f7x6wl";
+    };
+  }
+  {
+    goPackagePath = "github.com/opentracing/opentracing-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/opentracing/opentracing-go";
+      rev = "6edb48674bd9467b8e91fda004f2bd7202d60ce4";
+      sha256 = "0kwighhdm187b1yzcccm4hpy7m5sv1dij5ckg31n2614xvpippby";
+    };
+  }
+  {
+    goPackagePath = "github.com/openzipkin/zipkin-go-opentracing";
+    fetch = {
+      type = "git";
+      url = "https://github.com/openzipkin/zipkin-go-opentracing";
+      rev = "6022d4d3ed39632fad842942bda1813a9b4f63c8";
+      sha256 = "0gg9g2nxjf9almgzhx5sgqvbcx4zwvs873nl1d62jb6kqhsr8sjd";
+    };
+  }
+  {
+    goPackagePath = "github.com/pierrec/lz4";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pierrec/lz4";
+      rev = "5c9560bfa9ace2bf86080bf40d46b34ae44604df";
+      sha256 = "0j74a3xc48ispj8sb9c2sd1h53q99ws0f2x827b5p86xlpam8xyj";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "a1dba9ce8baed984a2495b658c82687f8157b98f";
+      sha256 = "1k2460bjzsm238sqx7wi42bym5bk7ybdr4qadk9szdbv65hh8vf6";
+    };
+  }
+  {
+    goPackagePath = "github.com/rcrowley/go-metrics";
+    fetch = {
+      type = "git";
+      url = "https://github.com/rcrowley/go-metrics";
+      rev = "1f30fe9094a513ce4c700b9a54458bbb0c96996c";
+      sha256 = "1hvbiaq4b6dqgjz6jkkxglfh9gf71zin6qsg508sh0r0ixfavrzj";
+    };
+  }
+  {
+    goPackagePath = "github.com/Shopify/sarama";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Shopify/sarama";
+      rev = "1416bd78f804d523005322194994f08c2a0ad797";
+      sha256 = "1skfkb1yhwf8w2n31dawr1kk145h3nwdf7xmm6yrwn69vbv8jqns";
+    };
+  }
+  {
+    goPackagePath = "github.com/apache/thrift";
+    fetch = {
+      type = "git";
+      url = "https://github.com/apache/thrift";
+      rev = "655b9b6ef86c45b423a194abee2a9cd057a16a74";
+      sha256 = "1kagirgxy2a9iabm8i32i5hdr36v5p0h651bsbyr0l99970myqfp";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/coreos/etcd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/etcd";
+      rev = "2533c2a50c4b6114ad6fd4c0000175fac3b6ee06";
+      sha256 = "0z8byms8hfn7ncq8sqcw9avn9nfal5hw75ckbladd6gzjc8jay02";
+    };
+  }
+  {
+    goPackagePath = "github.com/davecgh/go-spew";
+    fetch = {
+      type = "git";
+      url = "https://github.com/davecgh/go-spew";
+      rev = "346938d642f2ec3594ed81d874461961cd0faa76";
+      sha256 = "0d4jfmak5p6lb7n2r6yvf5p1zcw0l8j74kn55ghvr7zr7b7axm6c";
+    };
+  }
+  {
+    goPackagePath = "github.com/eapache/go-resiliency";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eapache/go-resiliency";
+      rev = "b86b1ec0dd4209a588dc1285cdd471e73525c0b3";
+      sha256 = "1kzv95bh3nidm2cr7iv9lk3s2qiw1i17n8gyl2x6xk6qv8b0bc21";
+    };
+  }
+  {
+    goPackagePath = "github.com/gogo/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gogo/protobuf";
+      rev = "d2e1ade2d719b78fe5b061b4c18a9f7111b5bdc8";
+      sha256 = "1fh4jyxv1drh9jmadidrlszcnjp4zfazysbq5075lqd1mhq99lz0";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "69b215d01a5606c843240eab4937eab3acee6530";
+      sha256 = "1cy9jxqi6ba5qnjmvznlq49n2zzr5vqgky6pa9mckrbli8ssvzw7";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/pierrec/xxHash";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pierrec/xxHash";
+      rev = "5a004441f897722c627870a981d02b29924215fa";
+      sha256 = "146ibrgvgh61jhbbv9wks0mabkci3s0m68sg6shmlv1yixkw6gja";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "6ab3432d241cbe3cb7543da7e7e9a934c7e9fe76";
+      sha256 = "19phcsvq1gn53af3nnh1lvvyzg8kpwribka9mszk18jv7l6nq9mf";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "6f3806018612930941127f2a7c6c453ba2c527d2";
+      sha256 = "1413ibprinxhni51p0755dp57r9wvbw7xgj9nmdaxmhzlqhc86j4";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "3007b6072c17c8d985734e6e19b1dea9174e13d3";
+      sha256 = "0jpvnmzqbzy2krwzan7pp3bc8pj9f1qic98lqq4hanccr0g5cmk3";
+    };
+  }
+  {
+    goPackagePath = "github.com/ugorji/go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ugorji/go";
+      rev = "c88ee250d0221a57af388746f5cf03768c21d6e2";
+      sha256 = "0ylb5p5i9hln8chq8whk5iy8qypjpzyrp07zpwjd1zbf5nsm1nmv";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "6b27048ae5e6ad1ef927e72e437531493de612fe";
+      sha256 = "08zk0vavl7g6jzklhxhwrgcjh42mn2flbx2d2rxsblyxkbqri07j";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "075e574b89e4c2d22f2286a7e2b919519c6f3547";
+      sha256 = "1p38siwqcbd592lphaqpigl7scshkfy67k6jcwscbcsl6akw51km";
+    };
+  }
+]
diff --git a/pkgs/servers/dns/dnsdist/default.nix b/pkgs/servers/dns/dnsdist/default.nix
new file mode 100644
index 000000000000..772292b0a57e
--- /dev/null
+++ b/pkgs/servers/dns/dnsdist/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, pkgconfig, systemd
+, boost, libsodium, libedit, re2
+, net_snmp, lua, protobuf, openssl }: stdenv.mkDerivation rec {
+  name = "dnsdist-${version}";
+  version = "1.3.0";
+
+  src = fetchurl {
+    url = "https://downloads.powerdns.com/releases/dnsdist-${version}.tar.bz2";
+    sha256 = "025sgvpi3ps0n4mzfwkk6a5ang90a3c7s2fi9vni6jj0p16wsrxa";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ systemd boost libsodium libedit re2 net_snmp lua protobuf openssl ];
+
+  configureFlags = [
+    "--enable-libsodium"
+    "--enable-re2"
+    "--enable-dnscrypt"
+    "--enable-dns-over-tls"
+    "--with-protobuf=yes"
+    "--with-net-snmp"
+    "--disable-dependency-tracking"
+    "--enable-unit-tests"
+    "--enable-systemd"
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "DNS Loadbalancer";
+    homepage = "https://dnsdist.org";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ das_j ];
+  };
+}
diff --git a/pkgs/servers/dns/knot-dns/default.nix b/pkgs/servers/dns/knot-dns/default.nix
new file mode 100644
index 000000000000..5fe7a8608c59
--- /dev/null
+++ b/pkgs/servers/dns/knot-dns/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, pkgconfig, gnutls, liburcu, lmdb, libcap_ng, libidn
+, systemd, nettle, libedit, zlib, libiconv, libintl
+}:
+
+let inherit (stdenv.lib) optional optionals; in
+
+# Note: ATM only the libraries have been tested in nixpkgs.
+stdenv.mkDerivation rec {
+  name = "knot-dns-${version}";
+  version = "2.6.7";
+
+  src = fetchurl {
+    url = "http://secure.nic.cz/files/knot-dns/knot-${version}.tar.xz";
+    sha256 = "1c2a004b05c161f7b36d5eeccebd9d4cdf60aa09930a7cc766514e468ca92243";
+  };
+
+  outputs = [ "bin" "out" "dev" ];
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    gnutls liburcu libidn
+    nettle libedit
+    libiconv lmdb libintl
+    # without sphinx &al. for developer documentation
+  ]
+    ++ optionals stdenv.isLinux [ libcap_ng systemd ]
+    ++ optional stdenv.isDarwin zlib; # perhaps due to gnutls
+
+  enableParallelBuilding = true;
+
+  CFLAGS = [ "-O2" "-DNDEBUG" ];
+
+  #doCheck = true; problems in combination with dynamic linking
+
+  postInstall = ''rm -r "$out"/var "$out"/lib/*.la'';
+
+  meta = with stdenv.lib; {
+    description = "Authoritative-only DNS server from .cz domain registry";
+    homepage = https://knot-dns.cz;
+    license = licenses.gpl3Plus;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.vcunat ];
+  };
+}
diff --git a/pkgs/servers/dns/knot-resolver/default.nix b/pkgs/servers/dns/knot-resolver/default.nix
new file mode 100644
index 000000000000..1a5577e81655
--- /dev/null
+++ b/pkgs/servers/dns/knot-resolver/default.nix
@@ -0,0 +1,82 @@
+{ stdenv, fetchurl, runCommand, pkgconfig, hexdump, which
+, knot-dns, luajit, libuv, lmdb, gnutls, nettle
+, cmocka, systemd, dns-root-data, makeWrapper
+, extraFeatures ? false /* catch-all if defaults aren't enough */
+, hiredis, libmemcached, luajitPackages
+}:
+let # un-indented, over the whole file
+
+result = if extraFeatures then wrapped-full else unwrapped;
+
+inherit (stdenv.lib) optional optionals optionalString concatStringsSep;
+
+unwrapped = stdenv.mkDerivation rec {
+  name = "knot-resolver-${version}";
+  version = "2.3.0";
+
+  src = fetchurl {
+    url = "http://secure.nic.cz/files/knot-resolver/${name}.tar.xz";
+    sha256 = "2d19c5daf8440bd3d2acd1886b9ede65f04f7753c6fd4618a92a1a4ba3b27a9b";
+  };
+
+  outputs = [ "out" "dev" ];
+
+  configurePhase = "patchShebangs scripts/";
+
+  nativeBuildInputs = [ pkgconfig which hexdump ];
+
+  # http://knot-resolver.readthedocs.io/en/latest/build.html#requirements
+  buildInputs = [ knot-dns luajit libuv gnutls nettle lmdb ]
+    ++ optional doCheck cmocka
+    ++ optional stdenv.isLinux systemd # sd_notify
+    ## optional dependencies; TODO: libedit, dnstap
+    ;
+
+  makeFlags = [
+    "PREFIX=$(out)"
+    "ROOTHINTS=${dns-root-data}/root.hints"
+    "KEYFILE_DEFAULT=${dns-root-data}/root.ds"
+  ];
+  CFLAGS = [ "-O2" "-DNDEBUG" ];
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+  doInstallCheck = false; # FIXME
+  preInstallCheck = ''
+    patchShebangs tests/config/runtest.sh
+  '';
+
+  postInstall = ''
+    rm "$out"/etc/knot-resolver/root.hints # using system-wide instead
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Caching validating DNS resolver, from .cz domain registry";
+    homepage = https://knot-resolver.cz;
+    license = licenses.gpl3Plus;
+    # Platforms using negative pointers for stack won't work ATM due to LuaJIT impl.
+    platforms = filter (p: p != "aarch64-linux") platforms.unix;
+    maintainers = [ maintainers.vcunat /* upstream developer */ ];
+  };
+};
+
+wrapped-full = with luajitPackages; let
+    luaPkgs =  [ luasec luasocket ]; # TODO: cqueues and others for http2 module
+  in runCommand unwrapped.name
+  {
+    nativeBuildInputs = [ makeWrapper ];
+    preferLocalBuild = true;
+    allowSubstitutes = false;
+  }
+  ''
+    mkdir -p "$out/sbin" "$out/share"
+    makeWrapper '${unwrapped}/sbin/kresd' "$out"/sbin/kresd \
+      --set LUA_PATH  '${concatStringsSep ";" (map getLuaPath  luaPkgs)}' \
+      --set LUA_CPATH '${concatStringsSep ";" (map getLuaCPath luaPkgs)}'
+    ln -sr '${unwrapped}/share/man' "$out"/share/
+    ln -sr "$out"/{sbin,bin}
+  '';
+
+in result
+
diff --git a/pkgs/servers/dns/nsd/default.nix b/pkgs/servers/dns/nsd/default.nix
index 218c7dc73f18..63e4f3baa8f4 100644
--- a/pkgs/servers/dns/nsd/default.nix
+++ b/pkgs/servers/dns/nsd/default.nix
@@ -10,16 +10,22 @@
 , rootServer       ? false
 , rrtypes          ? false
 , zoneStats        ? false
+
+, configFile ? "etc/nsd/nsd.conf"
 }:
 
 stdenv.mkDerivation rec {
-  name = "nsd-4.1.3";
+  name = "nsd-4.1.22";
 
   src = fetchurl {
     url = "http://www.nlnetlabs.nl/downloads/nsd/${name}.tar.gz";
-    sha256 = "1r8p5lqj7i6xi4k04jr1n9r1p8gwy3547hzsi8xags6krnav4z09";
+    sha256 = "1704masmx77qcj7b7shzrmgp9hpf9vpd265cnvn3b2kn0mkyi1pi";
   };
 
+  prePatch = ''
+    substituteInPlace nsd-control-setup.sh.in --replace openssl ${openssl}/bin/openssl
+  '';
+
   buildInputs = [ libevent openssl ];
 
   configureFlags =
@@ -35,13 +41,20 @@ stdenv.mkDerivation rec {
      ++ edf rootServer       "root-server"
      ++ edf rrtypes          "draft-rrtypes"
      ++ edf zoneStats        "zone-stats"
-     ++ [ "--with-ssl=${openssl}" "--with-libevent=${libevent}" ];
+     ++ [ "--with-ssl=${openssl.dev}"
+          "--with-libevent=${libevent.dev}"
+          "--with-nsd_conf_file=${configFile}"
+          "--with-configdir=etc/nsd"
+        ];
+
+  patchPhase = ''
+    sed 's@$(INSTALL_DATA) nsd.conf.sample $(DESTDIR)$(nsdconfigfile).sample@@g' -i Makefile.in
+  '';
 
   meta = with stdenv.lib; {
     homepage = http://www.nlnetlabs.nl;
     description = "Authoritative only, high performance, simple and open source name server";
     license = licenses.bsd3;
-
     platforms = platforms.unix;
     maintainers = [ maintainers.hrdinka ];
   };
diff --git a/pkgs/servers/dns/pdns-recursor/default.nix b/pkgs/servers/dns/pdns-recursor/default.nix
new file mode 100644
index 000000000000..286447352fc0
--- /dev/null
+++ b/pkgs/servers/dns/pdns-recursor/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchurl, pkgconfig, boost
+, openssl, systemd, lua, luajit, protobuf
+, enableProtoBuf ? false
+}:
+assert enableProtoBuf -> protobuf != null;
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "pdns-recursor-${version}";
+  version = "4.1.3";
+
+  src = fetchurl {
+    url = "https://downloads.powerdns.com/releases/pdns-recursor-${version}.tar.bz2";
+    sha256 = "12x8gm6771wh2xaqad3p5y08p5pimp6k9h830s0487mwg9glacy1";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    boost openssl systemd
+    lua luajit
+  ] ++ optional enableProtoBuf protobuf;
+
+  configureFlags = [
+    "--enable-reproducible"
+    "--with-systemd"
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "A recursive DNS server";
+    homepage = https://www.powerdns.com/;
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ rnhmjoj ];
+  };
+}
diff --git a/pkgs/servers/dns/powerdns/default.nix b/pkgs/servers/dns/powerdns/default.nix
new file mode 100644
index 000000000000..c34edfb5d6f8
--- /dev/null
+++ b/pkgs/servers/dns/powerdns/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, pkgconfig
+, boost, libyamlcpp, libsodium, sqlite, protobuf, botan2
+, mysql57, postgresql, lua, openldap, geoip, curl, opendbx, unixODBC
+}:
+
+stdenv.mkDerivation rec {
+  name = "powerdns-${version}";
+  version = "4.1.3";
+
+  src = fetchurl {
+    url = "http://downloads.powerdns.com/releases/pdns-${version}.tar.bz2";
+    sha256 = "1bh1qdgw415ax542123b6isri1jh4mbf2i9i1yffkfk0xmyv79cs";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    boost mysql57.connector-c postgresql lua openldap sqlite protobuf geoip
+    libyamlcpp libsodium curl opendbx unixODBC botan2
+  ];
+
+  patches = [
+    # checksum type not found, maybe a dependency is to old?
+    ./skip-sha384-test.patch
+  ];
+
+  # nix destroy with-modules arguments, when using configureFlags
+  preConfigure = ''
+    configureFlagsArray=(
+      "--with-modules=bind gmysql geoip godbc gpgsql gsqlite3 ldap lua mydns opendbx pipe random remote"
+      --with-sqlite3
+      --with-socketdir=/var/lib/powerdns
+      --enable-libsodium
+      --enable-botan
+      --enable-tools
+      --disable-dependency-tracking
+      --disable-silent-rules
+      --enable-reproducible
+      --enable-unit-tests
+    )
+  '';
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Authoritative DNS server";
+    homepage = https://www.powerdns.com;
+    platforms = platforms.linux;
+    # cannot find postgresql libs on macos x
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ mic92 disassembler ];
+  };
+}
diff --git a/pkgs/servers/dns/powerdns/skip-sha384-test.patch b/pkgs/servers/dns/powerdns/skip-sha384-test.patch
new file mode 100644
index 000000000000..3fafb38c48fb
--- /dev/null
+++ b/pkgs/servers/dns/powerdns/skip-sha384-test.patch
@@ -0,0 +1,14 @@
+--- pdns-4.1.1.org/pdns/test-signers.cc	2018-02-17 11:43:15.953228279 +0000
++++ pdns-4.1.1/pdns/test-signers.cc	2018-02-17 11:44:21.089516393 +0000
+@@ -212,11 +212,6 @@
+       BOOST_CHECK_EQUAL(ds2.getZoneRepresentation(), signer.dsSHA256);
+     }
+ 
+-    auto ds4 = makeDSFromDNSKey(name, drc, DNSSECKeeper::SHA384);
+-    if (!signer.dsSHA384.empty()) {
+-      BOOST_CHECK_EQUAL(ds4.getZoneRepresentation(), signer.dsSHA384);
+-    }
+-
+     auto signature = dcke->sign(message);
+     BOOST_CHECK(dcke->verify(message, signature));
+ 
diff --git a/pkgs/servers/dnschain/default.nix b/pkgs/servers/dnschain/default.nix
deleted file mode 100644
index b1714101856a..000000000000
--- a/pkgs/servers/dnschain/default.nix
+++ /dev/null
@@ -1,11 +0,0 @@
-{ stdenv, nodePackages }:
-
-# to update dnschain, run npm2nix package.json package.nix, and
-# then add "coffee-script" manually as a dependecy for "dnschain"
-# in package.nix.
-
-let
-  np = nodePackages.override { generated = ./package.nix; self = np; };
-in
-
-np.dnschain
diff --git a/pkgs/servers/dnschain/package.json b/pkgs/servers/dnschain/package.json
deleted file mode 100644
index fda40c8a90a6..000000000000
--- a/pkgs/servers/dnschain/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-[ "dnschain"
-, "coffee-script"
-]
diff --git a/pkgs/servers/dnschain/package.nix b/pkgs/servers/dnschain/package.nix
deleted file mode 100644
index 8077cb0f01f4..000000000000
--- a/pkgs/servers/dnschain/package.nix
+++ /dev/null
@@ -1,2200 +0,0 @@
-{ self, fetchurl, fetchgit ? null, lib }:
-
-{
-  by-spec."accepts"."~1.2.3" =
-    self.by-version."accepts"."1.2.13";
-  by-version."accepts"."1.2.13" = self.buildNodePackage {
-    name = "accepts-1.2.13";
-    version = "1.2.13";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/accepts/-/accepts-1.2.13.tgz";
-      name = "accepts-1.2.13.tgz";
-      sha1 = "e5f1f3928c6d95fd96558c36ec3d9d0de4a6ecea";
-    };
-    deps = {
-      "mime-types-2.1.6" = self.by-version."mime-types"."2.1.6";
-      "negotiator-0.5.3" = self.by-version."negotiator"."0.5.3";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."async"."0.2.x" =
-    self.by-version."async"."0.2.10";
-  by-version."async"."0.2.10" = self.buildNodePackage {
-    name = "async-0.2.10";
-    version = "0.2.10";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/async/-/async-0.2.10.tgz";
-      name = "async-0.2.10.tgz";
-      sha1 = "b6bbe0b0674b9d719708ca38de8c237cb526c3d1";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."async"."~0.9.0" =
-    self.by-version."async"."0.9.2";
-  by-version."async"."0.9.2" = self.buildNodePackage {
-    name = "async-0.9.2";
-    version = "0.9.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/async/-/async-0.9.2.tgz";
-      name = "async-0.9.2.tgz";
-      sha1 = "aea74d5e61c1f899613bf64bda66d4c78f2fd17d";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."better-curry"."1.x.x" =
-    self.by-version."better-curry"."1.6.0";
-  by-version."better-curry"."1.6.0" = self.buildNodePackage {
-    name = "better-curry-1.6.0";
-    version = "1.6.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/better-curry/-/better-curry-1.6.0.tgz";
-      name = "better-curry-1.6.0.tgz";
-      sha1 = "38f716b24c8cee07a262abc41c22c314e20e3869";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."binaryheap".">= 0.0.3" =
-    self.by-version."binaryheap"."0.0.3";
-  by-version."binaryheap"."0.0.3" = self.buildNodePackage {
-    name = "binaryheap-0.0.3";
-    version = "0.0.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/binaryheap/-/binaryheap-0.0.3.tgz";
-      name = "binaryheap-0.0.3.tgz";
-      sha1 = "0d6136c84e9f1a5a90c0b97178c3e00df59820d6";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."bindings"."*" =
-    self.by-version."bindings"."1.2.1";
-  by-version."bindings"."1.2.1" = self.buildNodePackage {
-    name = "bindings-1.2.1";
-    version = "1.2.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz";
-      name = "bindings-1.2.1.tgz";
-      sha1 = "14ad6113812d2d37d72e67b4cacb4bb726505f11";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."bluebird"."2.9.9" =
-    self.by-version."bluebird"."2.9.9";
-  by-version."bluebird"."2.9.9" = self.buildNodePackage {
-    name = "bluebird-2.9.9";
-    version = "2.9.9";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/bluebird/-/bluebird-2.9.9.tgz";
-      name = "bluebird-2.9.9.tgz";
-      sha1 = "61a26904d43d7f6b19dff7ed917dbc92452ad6d3";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."bottleneck"."1.5.x" =
-    self.by-version."bottleneck"."1.5.3";
-  by-version."bottleneck"."1.5.3" = self.buildNodePackage {
-    name = "bottleneck-1.5.3";
-    version = "1.5.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/bottleneck/-/bottleneck-1.5.3.tgz";
-      name = "bottleneck-1.5.3.tgz";
-      sha1 = "55fa64920d9670087d44150404525d59f9511c20";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."buffercursor".">= 0.0.12" =
-    self.by-version."buffercursor"."0.0.12";
-  by-version."buffercursor"."0.0.12" = self.buildNodePackage {
-    name = "buffercursor-0.0.12";
-    version = "0.0.12";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/buffercursor/-/buffercursor-0.0.12.tgz";
-      name = "buffercursor-0.0.12.tgz";
-      sha1 = "78a9a7f4343ae7d820a8999acc80de591e25a779";
-    };
-    deps = {
-      "verror-1.6.0" = self.by-version."verror"."1.6.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."buffercursor".">= 0.0.5" =
-    self.by-version."buffercursor"."0.0.12";
-  by-spec."coffee-script"."*" =
-    self.by-version."coffee-script"."1.10.0";
-  by-version."coffee-script"."1.10.0" = self.buildNodePackage {
-    name = "coffee-script-1.10.0";
-    version = "1.10.0";
-    bin = true;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/coffee-script/-/coffee-script-1.10.0.tgz";
-      name = "coffee-script-1.10.0.tgz";
-      sha1 = "12938bcf9be1948fa006f92e0c4c9e81705108c0";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  "coffee-script" = self.by-version."coffee-script"."1.10.0";
-  by-spec."colors"."0.6.x" =
-    self.by-version."colors"."0.6.2";
-  by-version."colors"."0.6.2" = self.buildNodePackage {
-    name = "colors-0.6.2";
-    version = "0.6.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/colors/-/colors-0.6.2.tgz";
-      name = "colors-0.6.2.tgz";
-      sha1 = "2423fe6678ac0c5dae8852e5d0e5be08c997abcc";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."combined-stream"."~0.0.4" =
-    self.by-version."combined-stream"."0.0.7";
-  by-version."combined-stream"."0.0.7" = self.buildNodePackage {
-    name = "combined-stream-0.0.7";
-    version = "0.0.7";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz";
-      name = "combined-stream-0.0.7.tgz";
-      sha1 = "0137e657baa5a7541c57ac37ac5fc07d73b4dc1f";
-    };
-    deps = {
-      "delayed-stream-0.0.5" = self.by-version."delayed-stream"."0.0.5";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."component-emitter"."1.1.2" =
-    self.by-version."component-emitter"."1.1.2";
-  by-version."component-emitter"."1.1.2" = self.buildNodePackage {
-    name = "component-emitter-1.1.2";
-    version = "1.1.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz";
-      name = "component-emitter-1.1.2.tgz";
-      sha1 = "296594f2753daa63996d2af08d15a95116c9aec3";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."content-disposition"."0.5.0" =
-    self.by-version."content-disposition"."0.5.0";
-  by-version."content-disposition"."0.5.0" = self.buildNodePackage {
-    name = "content-disposition-0.5.0";
-    version = "0.5.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz";
-      name = "content-disposition-0.5.0.tgz";
-      sha1 = "4284fe6ae0630874639e44e80a418c2934135e9e";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."cookie"."0.1.2" =
-    self.by-version."cookie"."0.1.2";
-  by-version."cookie"."0.1.2" = self.buildNodePackage {
-    name = "cookie-0.1.2";
-    version = "0.1.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/cookie/-/cookie-0.1.2.tgz";
-      name = "cookie-0.1.2.tgz";
-      sha1 = "72fec3d24e48a3432073d90c12642005061004b1";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."cookie-signature"."1.0.5" =
-    self.by-version."cookie-signature"."1.0.5";
-  by-version."cookie-signature"."1.0.5" = self.buildNodePackage {
-    name = "cookie-signature-1.0.5";
-    version = "1.0.5";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.5.tgz";
-      name = "cookie-signature-1.0.5.tgz";
-      sha1 = "a122e3f1503eca0f5355795b0711bb2368d450f9";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."cookiejar"."2.0.1" =
-    self.by-version."cookiejar"."2.0.1";
-  by-version."cookiejar"."2.0.1" = self.buildNodePackage {
-    name = "cookiejar-2.0.1";
-    version = "2.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/cookiejar/-/cookiejar-2.0.1.tgz";
-      name = "cookiejar-2.0.1.tgz";
-      sha1 = "3d12752f6adf68a892f332433492bd5812bb668f";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."core-util-is"."~1.0.0" =
-    self.by-version."core-util-is"."1.0.1";
-  by-version."core-util-is"."1.0.1" = self.buildNodePackage {
-    name = "core-util-is-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz";
-      name = "core-util-is-1.0.1.tgz";
-      sha1 = "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."crc"."3.2.1" =
-    self.by-version."crc"."3.2.1";
-  by-version."crc"."3.2.1" = self.buildNodePackage {
-    name = "crc-3.2.1";
-    version = "3.2.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/crc/-/crc-3.2.1.tgz";
-      name = "crc-3.2.1.tgz";
-      sha1 = "5d9c8fb77a245cd5eca291e5d2d005334bab0082";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."cycle"."1.0.x" =
-    self.by-version."cycle"."1.0.3";
-  by-version."cycle"."1.0.3" = self.buildNodePackage {
-    name = "cycle-1.0.3";
-    version = "1.0.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz";
-      name = "cycle-1.0.3.tgz";
-      sha1 = "21e80b2be8580f98b468f379430662b046c34ad2";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."debug"."1.x.x" =
-    self.by-version."debug"."1.0.4";
-  by-version."debug"."1.0.4" = self.buildNodePackage {
-    name = "debug-1.0.4";
-    version = "1.0.4";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/debug/-/debug-1.0.4.tgz";
-      name = "debug-1.0.4.tgz";
-      sha1 = "5b9c256bd54b6ec02283176fa8a0ede6d154cbf8";
-    };
-    deps = {
-      "ms-0.6.2" = self.by-version."ms"."0.6.2";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."debug"."2" =
-    self.by-version."debug"."2.2.0";
-  by-version."debug"."2.2.0" = self.buildNodePackage {
-    name = "debug-2.2.0";
-    version = "2.2.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/debug/-/debug-2.2.0.tgz";
-      name = "debug-2.2.0.tgz";
-      sha1 = "f87057e995b1a1f6ae6a4960664137bc56f039da";
-    };
-    deps = {
-      "ms-0.7.1" = self.by-version."ms"."0.7.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."debug"."~2.1.1" =
-    self.by-version."debug"."2.1.3";
-  by-version."debug"."2.1.3" = self.buildNodePackage {
-    name = "debug-2.1.3";
-    version = "2.1.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/debug/-/debug-2.1.3.tgz";
-      name = "debug-2.1.3.tgz";
-      sha1 = "ce8ab1b5ee8fbee2bfa3b633cab93d366b63418e";
-    };
-    deps = {
-      "ms-0.7.0" = self.by-version."ms"."0.7.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."delayed-stream"."0.0.5" =
-    self.by-version."delayed-stream"."0.0.5";
-  by-version."delayed-stream"."0.0.5" = self.buildNodePackage {
-    name = "delayed-stream-0.0.5";
-    version = "0.0.5";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz";
-      name = "delayed-stream-0.0.5.tgz";
-      sha1 = "d4b1f43a93e8296dfe02694f4680bc37a313c73f";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."depd"."~1.0.0" =
-    self.by-version."depd"."1.0.1";
-  by-version."depd"."1.0.1" = self.buildNodePackage {
-    name = "depd-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/depd/-/depd-1.0.1.tgz";
-      name = "depd-1.0.1.tgz";
-      sha1 = "80aec64c9d6d97e65cc2a9caa93c0aa6abf73aaa";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."destroy"."1.0.3" =
-    self.by-version."destroy"."1.0.3";
-  by-version."destroy"."1.0.3" = self.buildNodePackage {
-    name = "destroy-1.0.3";
-    version = "1.0.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/destroy/-/destroy-1.0.3.tgz";
-      name = "destroy-1.0.3.tgz";
-      sha1 = "b433b4724e71fd8551d9885174851c5fc377e2c9";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."dnschain"."*" =
-    self.by-version."dnschain"."0.5.3";
-  by-version."dnschain"."0.5.3" = self.buildNodePackage {
-    name = "dnschain-0.5.3";
-    version = "0.5.3";
-    bin = true;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/dnschain/-/dnschain-0.5.3.tgz";
-      name = "dnschain-0.5.3.tgz";
-      sha1 = "9b21d9ac5e203295f372ac37df470e9f0854c470";
-    };
-    deps = {
-      "bluebird-2.9.9" = self.by-version."bluebird"."2.9.9";
-      "bottleneck-1.5.3" = self.by-version."bottleneck"."1.5.3";
-      "event-stream-3.2.2" = self.by-version."event-stream"."3.2.2";
-      "express-4.11.2" = self.by-version."express"."4.11.2";
-      "hiredis-0.4.1" = self.by-version."hiredis"."0.4.1";
-      "json-rpc2-0.8.1" = self.by-version."json-rpc2"."0.8.1";
-      "lodash-3.1.0" = self.by-version."lodash"."3.1.0";
-      "native-dns-0.6.1" = self.by-version."native-dns"."0.6.1";
-      "native-dns-packet-0.1.1" = self.by-version."native-dns-packet"."0.1.1";
-      "nconf-0.7.1" = self.by-version."nconf"."0.7.1";
-      "properties-1.2.1" = self.by-version."properties"."1.2.1";
-      "redis-0.12.1" = self.by-version."redis"."0.12.1";
-      "string-2.0.1" = self.by-version."string"."2.0.1";
-      "winston-0.8.0" = self.by-version."winston"."0.8.0";
-      "superagent-0.21.0" = self.by-version."superagent"."0.21.0";
-      "coffee-script-1.10.0" = self.by-version."coffee-script"."1.10.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  "dnschain" = self.by-version."dnschain"."0.5.3";
-  by-spec."duplexer"."~0.1.1" =
-    self.by-version."duplexer"."0.1.1";
-  by-version."duplexer"."0.1.1" = self.buildNodePackage {
-    name = "duplexer-0.1.1";
-    version = "0.1.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz";
-      name = "duplexer-0.1.1.tgz";
-      sha1 = "ace6ff808c1ce66b57d1ebf97977acb02334cfc1";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ee-first"."1.1.0" =
-    self.by-version."ee-first"."1.1.0";
-  by-version."ee-first"."1.1.0" = self.buildNodePackage {
-    name = "ee-first-1.1.0";
-    version = "1.1.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ee-first/-/ee-first-1.1.0.tgz";
-      name = "ee-first-1.1.0.tgz";
-      sha1 = "6a0d7c6221e490feefd92ec3f441c9ce8cd097f4";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."es5class"."2.x.x" =
-    self.by-version."es5class"."2.3.1";
-  by-version."es5class"."2.3.1" = self.buildNodePackage {
-    name = "es5class-2.3.1";
-    version = "2.3.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/es5class/-/es5class-2.3.1.tgz";
-      name = "es5class-2.3.1.tgz";
-      sha1 = "42c5c18a9016bcb0db28a4d340ebb831f55d1b66";
-    };
-    deps = {
-      "better-curry-1.6.0" = self.by-version."better-curry"."1.6.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."escape-html"."1.0.1" =
-    self.by-version."escape-html"."1.0.1";
-  by-version."escape-html"."1.0.1" = self.buildNodePackage {
-    name = "escape-html-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/escape-html/-/escape-html-1.0.1.tgz";
-      name = "escape-html-1.0.1.tgz";
-      sha1 = "181a286ead397a39a92857cfb1d43052e356bff0";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."etag"."~1.5.1" =
-    self.by-version."etag"."1.5.1";
-  by-version."etag"."1.5.1" = self.buildNodePackage {
-    name = "etag-1.5.1";
-    version = "1.5.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/etag/-/etag-1.5.1.tgz";
-      name = "etag-1.5.1.tgz";
-      sha1 = "54c50de04ee42695562925ac566588291be7e9ea";
-    };
-    deps = {
-      "crc-3.2.1" = self.by-version."crc"."3.2.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."event-stream"."3.2.2" =
-    self.by-version."event-stream"."3.2.2";
-  by-version."event-stream"."3.2.2" = self.buildNodePackage {
-    name = "event-stream-3.2.2";
-    version = "3.2.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/event-stream/-/event-stream-3.2.2.tgz";
-      name = "event-stream-3.2.2.tgz";
-      sha1 = "f79f9984c07ee3fd9b44ffb3cd0422b13e24084d";
-    };
-    deps = {
-      "through-2.3.8" = self.by-version."through"."2.3.8";
-      "duplexer-0.1.1" = self.by-version."duplexer"."0.1.1";
-      "from-0.1.3" = self.by-version."from"."0.1.3";
-      "map-stream-0.1.0" = self.by-version."map-stream"."0.1.0";
-      "pause-stream-0.0.11" = self.by-version."pause-stream"."0.0.11";
-      "split-0.3.3" = self.by-version."split"."0.3.3";
-      "stream-combiner-0.0.4" = self.by-version."stream-combiner"."0.0.4";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."eventemitter3"."0.x.x" =
-    self.by-version."eventemitter3"."0.1.6";
-  by-version."eventemitter3"."0.1.6" = self.buildNodePackage {
-    name = "eventemitter3-0.1.6";
-    version = "0.1.6";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/eventemitter3/-/eventemitter3-0.1.6.tgz";
-      name = "eventemitter3-0.1.6.tgz";
-      sha1 = "8c7ac44b87baab55cd50c828dc38778eac052ea5";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."express"."4.11.2" =
-    self.by-version."express"."4.11.2";
-  by-version."express"."4.11.2" = self.buildNodePackage {
-    name = "express-4.11.2";
-    version = "4.11.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/express/-/express-4.11.2.tgz";
-      name = "express-4.11.2.tgz";
-      sha1 = "8df3d5a9ac848585f00a0777601823faecd3b148";
-    };
-    deps = {
-      "accepts-1.2.13" = self.by-version."accepts"."1.2.13";
-      "content-disposition-0.5.0" = self.by-version."content-disposition"."0.5.0";
-      "cookie-signature-1.0.5" = self.by-version."cookie-signature"."1.0.5";
-      "debug-2.1.3" = self.by-version."debug"."2.1.3";
-      "depd-1.0.1" = self.by-version."depd"."1.0.1";
-      "escape-html-1.0.1" = self.by-version."escape-html"."1.0.1";
-      "etag-1.5.1" = self.by-version."etag"."1.5.1";
-      "finalhandler-0.3.3" = self.by-version."finalhandler"."0.3.3";
-      "fresh-0.2.4" = self.by-version."fresh"."0.2.4";
-      "media-typer-0.3.0" = self.by-version."media-typer"."0.3.0";
-      "methods-1.1.1" = self.by-version."methods"."1.1.1";
-      "on-finished-2.2.1" = self.by-version."on-finished"."2.2.1";
-      "parseurl-1.3.0" = self.by-version."parseurl"."1.3.0";
-      "path-to-regexp-0.1.3" = self.by-version."path-to-regexp"."0.1.3";
-      "proxy-addr-1.0.8" = self.by-version."proxy-addr"."1.0.8";
-      "qs-2.3.3" = self.by-version."qs"."2.3.3";
-      "range-parser-1.0.2" = self.by-version."range-parser"."1.0.2";
-      "send-0.11.1" = self.by-version."send"."0.11.1";
-      "serve-static-1.8.1" = self.by-version."serve-static"."1.8.1";
-      "type-is-1.5.7" = self.by-version."type-is"."1.5.7";
-      "vary-1.0.1" = self.by-version."vary"."1.0.1";
-      "cookie-0.1.2" = self.by-version."cookie"."0.1.2";
-      "merge-descriptors-0.0.2" = self.by-version."merge-descriptors"."0.0.2";
-      "utils-merge-1.0.0" = self.by-version."utils-merge"."1.0.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."extend"."~1.2.1" =
-    self.by-version."extend"."1.2.1";
-  by-version."extend"."1.2.1" = self.buildNodePackage {
-    name = "extend-1.2.1";
-    version = "1.2.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/extend/-/extend-1.2.1.tgz";
-      name = "extend-1.2.1.tgz";
-      sha1 = "a0f5fd6cfc83a5fe49ef698d60ec8a624dd4576c";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."extsprintf"."1.2.0" =
-    self.by-version."extsprintf"."1.2.0";
-  by-version."extsprintf"."1.2.0" = self.buildNodePackage {
-    name = "extsprintf-1.2.0";
-    version = "1.2.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/extsprintf/-/extsprintf-1.2.0.tgz";
-      name = "extsprintf-1.2.0.tgz";
-      sha1 = "5ad946c22f5b32ba7f8cd7426711c6e8a3fc2529";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."eyes"."0.1.x" =
-    self.by-version."eyes"."0.1.8";
-  by-version."eyes"."0.1.8" = self.buildNodePackage {
-    name = "eyes-0.1.8";
-    version = "0.1.8";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz";
-      name = "eyes-0.1.8.tgz";
-      sha1 = "62cf120234c683785d902348a800ef3e0cc20bc0";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."faye-websocket"."0.x.x" =
-    self.by-version."faye-websocket"."0.10.0";
-  by-version."faye-websocket"."0.10.0" = self.buildNodePackage {
-    name = "faye-websocket-0.10.0";
-    version = "0.10.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz";
-      name = "faye-websocket-0.10.0.tgz";
-      sha1 = "4e492f8d04dfb6f89003507f6edbf2d501e7c6f4";
-    };
-    deps = {
-      "websocket-driver-0.6.2" = self.by-version."websocket-driver"."0.6.2";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."finalhandler"."0.3.3" =
-    self.by-version."finalhandler"."0.3.3";
-  by-version."finalhandler"."0.3.3" = self.buildNodePackage {
-    name = "finalhandler-0.3.3";
-    version = "0.3.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/finalhandler/-/finalhandler-0.3.3.tgz";
-      name = "finalhandler-0.3.3.tgz";
-      sha1 = "b1a09aa1e6a607b3541669b09bcb727f460cd426";
-    };
-    deps = {
-      "debug-2.1.3" = self.by-version."debug"."2.1.3";
-      "escape-html-1.0.1" = self.by-version."escape-html"."1.0.1";
-      "on-finished-2.2.1" = self.by-version."on-finished"."2.2.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."form-data"."0.1.3" =
-    self.by-version."form-data"."0.1.3";
-  by-version."form-data"."0.1.3" = self.buildNodePackage {
-    name = "form-data-0.1.3";
-    version = "0.1.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/form-data/-/form-data-0.1.3.tgz";
-      name = "form-data-0.1.3.tgz";
-      sha1 = "4ee4346e6eb5362e8344a02075bd8dbd8c7373ea";
-    };
-    deps = {
-      "combined-stream-0.0.7" = self.by-version."combined-stream"."0.0.7";
-      "mime-1.2.11" = self.by-version."mime"."1.2.11";
-      "async-0.9.2" = self.by-version."async"."0.9.2";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."formidable"."1.0.14" =
-    self.by-version."formidable"."1.0.14";
-  by-version."formidable"."1.0.14" = self.buildNodePackage {
-    name = "formidable-1.0.14";
-    version = "1.0.14";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/formidable/-/formidable-1.0.14.tgz";
-      name = "formidable-1.0.14.tgz";
-      sha1 = "2b3f4c411cbb5fdd695c44843e2a23514a43231a";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."forwarded"."~0.1.0" =
-    self.by-version."forwarded"."0.1.0";
-  by-version."forwarded"."0.1.0" = self.buildNodePackage {
-    name = "forwarded-0.1.0";
-    version = "0.1.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz";
-      name = "forwarded-0.1.0.tgz";
-      sha1 = "19ef9874c4ae1c297bcf078fde63a09b66a84363";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."fresh"."0.2.4" =
-    self.by-version."fresh"."0.2.4";
-  by-version."fresh"."0.2.4" = self.buildNodePackage {
-    name = "fresh-0.2.4";
-    version = "0.2.4";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/fresh/-/fresh-0.2.4.tgz";
-      name = "fresh-0.2.4.tgz";
-      sha1 = "3582499206c9723714190edd74b4604feb4a614c";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."from"."~0" =
-    self.by-version."from"."0.1.3";
-  by-version."from"."0.1.3" = self.buildNodePackage {
-    name = "from-0.1.3";
-    version = "0.1.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/from/-/from-0.1.3.tgz";
-      name = "from-0.1.3.tgz";
-      sha1 = "ef63ac2062ac32acf7862e0d40b44b896f22f3bc";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."hiredis"."0.4.1" =
-    self.by-version."hiredis"."0.4.1";
-  by-version."hiredis"."0.4.1" = self.buildNodePackage {
-    name = "hiredis-0.4.1";
-    version = "0.4.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/hiredis/-/hiredis-0.4.1.tgz";
-      name = "hiredis-0.4.1.tgz";
-      sha1 = "aab4dcfd0fc4cbdb219d268005f2335a3c639e8f";
-    };
-    deps = {
-      "bindings-1.2.1" = self.by-version."bindings"."1.2.1";
-      "nan-2.0.8" = self.by-version."nan"."2.0.8";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."inherits"."~2.0.1" =
-    self.by-version."inherits"."2.0.1";
-  by-version."inherits"."2.0.1" = self.buildNodePackage {
-    name = "inherits-2.0.1";
-    version = "2.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz";
-      name = "inherits-2.0.1.tgz";
-      sha1 = "b17d08d326b4423e568eff719f91b0b1cbdf69f1";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ini"."1.x.x" =
-    self.by-version."ini"."1.3.4";
-  by-version."ini"."1.3.4" = self.buildNodePackage {
-    name = "ini-1.3.4";
-    version = "1.3.4";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ini/-/ini-1.3.4.tgz";
-      name = "ini-1.3.4.tgz";
-      sha1 = "0537cb79daf59b59a1a517dff706c86ec039162e";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ipaddr.js"."1.0.1" =
-    self.by-version."ipaddr.js"."1.0.1";
-  by-version."ipaddr.js"."1.0.1" = self.buildNodePackage {
-    name = "ipaddr.js-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.0.1.tgz";
-      name = "ipaddr.js-1.0.1.tgz";
-      sha1 = "5f38801dc73e0400fc7076386f6ed5215fbd8f95";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ipaddr.js".">= 0.1.1" =
-    self.by-version."ipaddr.js"."1.0.3";
-  by-version."ipaddr.js"."1.0.3" = self.buildNodePackage {
-    name = "ipaddr.js-1.0.3";
-    version = "1.0.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.0.3.tgz";
-      name = "ipaddr.js-1.0.3.tgz";
-      sha1 = "2a9df7be73ea92aadb0d7f377497decd8e6d01bb";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."isarray"."0.0.1" =
-    self.by-version."isarray"."0.0.1";
-  by-version."isarray"."0.0.1" = self.buildNodePackage {
-    name = "isarray-0.0.1";
-    version = "0.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz";
-      name = "isarray-0.0.1.tgz";
-      sha1 = "8a18acfca9a8f4177e09abfc6038939b05d1eedf";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."json-rpc2"."0.8.1" =
-    self.by-version."json-rpc2"."0.8.1";
-  by-version."json-rpc2"."0.8.1" = self.buildNodePackage {
-    name = "json-rpc2-0.8.1";
-    version = "0.8.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/json-rpc2/-/json-rpc2-0.8.1.tgz";
-      name = "json-rpc2-0.8.1.tgz";
-      sha1 = "efe8c9834605b556c488d1ed7bcf24ee381eeeb2";
-    };
-    deps = {
-      "jsonparse-0.0.6" = self.by-version."jsonparse"."0.0.6";
-      "debug-1.0.4" = self.by-version."debug"."1.0.4";
-      "lodash-2.4.2" = self.by-version."lodash"."2.4.2";
-      "es5class-2.3.1" = self.by-version."es5class"."2.3.1";
-      "faye-websocket-0.10.0" = self.by-version."faye-websocket"."0.10.0";
-      "eventemitter3-0.1.6" = self.by-version."eventemitter3"."0.1.6";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."jsonparse"."0.x.x" =
-    self.by-version."jsonparse"."0.0.6";
-  by-version."jsonparse"."0.0.6" = self.buildNodePackage {
-    name = "jsonparse-0.0.6";
-    version = "0.0.6";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/jsonparse/-/jsonparse-0.0.6.tgz";
-      name = "jsonparse-0.0.6.tgz";
-      sha1 = "ab599f19324d4ae178fa21a930192ab11ab61a4e";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."lodash"."2.x.x" =
-    self.by-version."lodash"."2.4.2";
-  by-version."lodash"."2.4.2" = self.buildNodePackage {
-    name = "lodash-2.4.2";
-    version = "2.4.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz";
-      name = "lodash-2.4.2.tgz";
-      sha1 = "fadd834b9683073da179b3eae6d9c0d15053f73e";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."lodash"."3.1.0" =
-    self.by-version."lodash"."3.1.0";
-  by-version."lodash"."3.1.0" = self.buildNodePackage {
-    name = "lodash-3.1.0";
-    version = "3.1.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/lodash/-/lodash-3.1.0.tgz";
-      name = "lodash-3.1.0.tgz";
-      sha1 = "d41b8b33530cb3be088853208ad30092d2c27961";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."map-stream"."~0.1.0" =
-    self.by-version."map-stream"."0.1.0";
-  by-version."map-stream"."0.1.0" = self.buildNodePackage {
-    name = "map-stream-0.1.0";
-    version = "0.1.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz";
-      name = "map-stream-0.1.0.tgz";
-      sha1 = "e56aa94c4c8055a16404a0674b78f215f7c8e194";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."media-typer"."0.3.0" =
-    self.by-version."media-typer"."0.3.0";
-  by-version."media-typer"."0.3.0" = self.buildNodePackage {
-    name = "media-typer-0.3.0";
-    version = "0.3.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz";
-      name = "media-typer-0.3.0.tgz";
-      sha1 = "8710d7af0aa626f8fffa1ce00168545263255748";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."merge-descriptors"."0.0.2" =
-    self.by-version."merge-descriptors"."0.0.2";
-  by-version."merge-descriptors"."0.0.2" = self.buildNodePackage {
-    name = "merge-descriptors-0.0.2";
-    version = "0.0.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/merge-descriptors/-/merge-descriptors-0.0.2.tgz";
-      name = "merge-descriptors-0.0.2.tgz";
-      sha1 = "c36a52a781437513c57275f39dd9d317514ac8c7";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."methods"."1.0.1" =
-    self.by-version."methods"."1.0.1";
-  by-version."methods"."1.0.1" = self.buildNodePackage {
-    name = "methods-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/methods/-/methods-1.0.1.tgz";
-      name = "methods-1.0.1.tgz";
-      sha1 = "75bc91943dffd7da037cf3eeb0ed73a0037cd14b";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."methods"."~1.1.1" =
-    self.by-version."methods"."1.1.1";
-  by-version."methods"."1.1.1" = self.buildNodePackage {
-    name = "methods-1.1.1";
-    version = "1.1.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/methods/-/methods-1.1.1.tgz";
-      name = "methods-1.1.1.tgz";
-      sha1 = "17ea6366066d00c58e375b8ec7dfd0453c89822a";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."mime"."1.2.11" =
-    self.by-version."mime"."1.2.11";
-  by-version."mime"."1.2.11" = self.buildNodePackage {
-    name = "mime-1.2.11";
-    version = "1.2.11";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz";
-      name = "mime-1.2.11.tgz";
-      sha1 = "58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."mime"."~1.2.11" =
-    self.by-version."mime"."1.2.11";
-  by-spec."mime-db"."~1.12.0" =
-    self.by-version."mime-db"."1.12.0";
-  by-version."mime-db"."1.12.0" = self.buildNodePackage {
-    name = "mime-db-1.12.0";
-    version = "1.12.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/mime-db/-/mime-db-1.12.0.tgz";
-      name = "mime-db-1.12.0.tgz";
-      sha1 = "3d0c63180f458eb10d325aaa37d7c58ae312e9d7";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."mime-db"."~1.18.0" =
-    self.by-version."mime-db"."1.18.0";
-  by-version."mime-db"."1.18.0" = self.buildNodePackage {
-    name = "mime-db-1.18.0";
-    version = "1.18.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/mime-db/-/mime-db-1.18.0.tgz";
-      name = "mime-db-1.18.0.tgz";
-      sha1 = "5317e28224c08af1d484f60973dd386ba8f389e0";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."mime-types"."~2.0.9" =
-    self.by-version."mime-types"."2.0.14";
-  by-version."mime-types"."2.0.14" = self.buildNodePackage {
-    name = "mime-types-2.0.14";
-    version = "2.0.14";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/mime-types/-/mime-types-2.0.14.tgz";
-      name = "mime-types-2.0.14.tgz";
-      sha1 = "310e159db23e077f8bb22b748dabfa4957140aa6";
-    };
-    deps = {
-      "mime-db-1.12.0" = self.by-version."mime-db"."1.12.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."mime-types"."~2.1.6" =
-    self.by-version."mime-types"."2.1.6";
-  by-version."mime-types"."2.1.6" = self.buildNodePackage {
-    name = "mime-types-2.1.6";
-    version = "2.1.6";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/mime-types/-/mime-types-2.1.6.tgz";
-      name = "mime-types-2.1.6.tgz";
-      sha1 = "949f8788411864ddc70948a0f21c43f29d25667c";
-    };
-    deps = {
-      "mime-db-1.18.0" = self.by-version."mime-db"."1.18.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."minimist"."~0.0.1" =
-    self.by-version."minimist"."0.0.10";
-  by-version."minimist"."0.0.10" = self.buildNodePackage {
-    name = "minimist-0.0.10";
-    version = "0.0.10";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz";
-      name = "minimist-0.0.10.tgz";
-      sha1 = "de3f98543dbf96082be48ad1a0c7cda836301dcf";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ms"."0.6.2" =
-    self.by-version."ms"."0.6.2";
-  by-version."ms"."0.6.2" = self.buildNodePackage {
-    name = "ms-0.6.2";
-    version = "0.6.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ms/-/ms-0.6.2.tgz";
-      name = "ms-0.6.2.tgz";
-      sha1 = "d89c2124c6fdc1353d65a8b77bf1aac4b193708c";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ms"."0.7.0" =
-    self.by-version."ms"."0.7.0";
-  by-version."ms"."0.7.0" = self.buildNodePackage {
-    name = "ms-0.7.0";
-    version = "0.7.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ms/-/ms-0.7.0.tgz";
-      name = "ms-0.7.0.tgz";
-      sha1 = "865be94c2e7397ad8a57da6a633a6e2f30798b83";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."ms"."0.7.1" =
-    self.by-version."ms"."0.7.1";
-  by-version."ms"."0.7.1" = self.buildNodePackage {
-    name = "ms-0.7.1";
-    version = "0.7.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/ms/-/ms-0.7.1.tgz";
-      name = "ms-0.7.1.tgz";
-      sha1 = "9cd13c03adbff25b65effde7ce864ee952017098";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."nan"."^2.0.5" =
-    self.by-version."nan"."2.0.8";
-  by-version."nan"."2.0.8" = self.buildNodePackage {
-    name = "nan-2.0.8";
-    version = "2.0.8";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/nan/-/nan-2.0.8.tgz";
-      name = "nan-2.0.8.tgz";
-      sha1 = "c15fd99dd4cc323d1c2f94ac426313680e606392";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."native-dns"."git+https://github.com/okTurtles/node-dns.git#08433ec98f517eed3c6d5e47bdf62603539cd402" =
-    self.by-version."native-dns"."0.6.1";
-  by-version."native-dns"."0.6.1" = self.buildNodePackage {
-    name = "native-dns-0.6.1";
-    version = "0.6.1";
-    bin = false;
-    src = fetchgit {
-      url = "https://github.com/okTurtles/node-dns.git";
-      rev = "08433ec98f517eed3c6d5e47bdf62603539cd402";
-      sha256 = "9c3faf4d39fda7bb6dd52a82036625f37ed442d5e948d295acb2f055dd367080";
-    };
-    deps = {
-      "ipaddr.js-1.0.3" = self.by-version."ipaddr.js"."1.0.3";
-      "native-dns-cache-0.0.2" = self.by-version."native-dns-cache"."0.0.2";
-      "native-dns-packet-0.0.4" = self.by-version."native-dns-packet"."0.0.4";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."native-dns-cache"."git+https://github.com/okTurtles/native-dns-cache.git#8714196bb9223cc9a4064a4fddf9e82ec50b7d4d" =
-    self.by-version."native-dns-cache"."0.0.2";
-  by-version."native-dns-cache"."0.0.2" = self.buildNodePackage {
-    name = "native-dns-cache-0.0.2";
-    version = "0.0.2";
-    bin = false;
-    src = fetchgit {
-      url = "https://github.com/okTurtles/native-dns-cache.git";
-      rev = "8714196bb9223cc9a4064a4fddf9e82ec50b7d4d";
-      sha256 = "3f06b2577afc3c1e428533baae3c51bad44a2e1e02fca147a1303943c214f841";
-    };
-    deps = {
-      "binaryheap-0.0.3" = self.by-version."binaryheap"."0.0.3";
-      "native-dns-packet-0.0.3" = self.by-version."native-dns-packet"."0.0.3";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."native-dns-packet"."0.1.1" =
-    self.by-version."native-dns-packet"."0.1.1";
-  by-version."native-dns-packet"."0.1.1" = self.buildNodePackage {
-    name = "native-dns-packet-0.1.1";
-    version = "0.1.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/native-dns-packet/-/native-dns-packet-0.1.1.tgz";
-      name = "native-dns-packet-0.1.1.tgz";
-      sha1 = "97da90570b8438a00194701ce24d011fd3cc109a";
-    };
-    deps = {
-      "buffercursor-0.0.12" = self.by-version."buffercursor"."0.0.12";
-      "ipaddr.js-1.0.3" = self.by-version."ipaddr.js"."1.0.3";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."native-dns-packet"."git+https://github.com/okTurtles/native-dns-packet.git#307e77a47ebba57a5ae9118a284e916e5ebb305a" =
-    self.by-version."native-dns-packet"."0.0.3";
-  by-version."native-dns-packet"."0.0.3" = self.buildNodePackage {
-    name = "native-dns-packet-0.0.3";
-    version = "0.0.3";
-    bin = false;
-    src = fetchgit {
-      url = "https://github.com/okTurtles/native-dns-packet.git";
-      rev = "307e77a47ebba57a5ae9118a284e916e5ebb305a";
-      sha256 = "3ab023906deb8ee86bcb34c3e67e03cebeed1ba2dcb0b1d561c362ca995b0739";
-    };
-    deps = {
-      "buffercursor-0.0.12" = self.by-version."buffercursor"."0.0.12";
-      "ipaddr.js-1.0.3" = self.by-version."ipaddr.js"."1.0.3";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."native-dns-packet"."git+https://github.com/okTurtles/native-dns-packet.git#8bf2714c318cfe7d31bca2006385882ccbf503e4" =
-    self.by-version."native-dns-packet"."0.0.4";
-  by-version."native-dns-packet"."0.0.4" = self.buildNodePackage {
-    name = "native-dns-packet-0.0.4";
-    version = "0.0.4";
-    bin = false;
-    src = fetchgit {
-      url = "https://github.com/okTurtles/native-dns-packet.git";
-      rev = "8bf2714c318cfe7d31bca2006385882ccbf503e4";
-      sha256 = "2a5951696b4e514ab5dee36e4e5394781656a8e94c6aacba83b03f7e647f8df3";
-    };
-    deps = {
-      "buffercursor-0.0.12" = self.by-version."buffercursor"."0.0.12";
-      "ipaddr.js-1.0.3" = self.by-version."ipaddr.js"."1.0.3";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."nconf"."0.7.1" =
-    self.by-version."nconf"."0.7.1";
-  by-version."nconf"."0.7.1" = self.buildNodePackage {
-    name = "nconf-0.7.1";
-    version = "0.7.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/nconf/-/nconf-0.7.1.tgz";
-      name = "nconf-0.7.1.tgz";
-      sha1 = "ee4b561dd979a3c58db122e38f196d49d61aeb5b";
-    };
-    deps = {
-      "async-0.9.2" = self.by-version."async"."0.9.2";
-      "ini-1.3.4" = self.by-version."ini"."1.3.4";
-      "optimist-0.6.1" = self.by-version."optimist"."0.6.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."negotiator"."0.5.3" =
-    self.by-version."negotiator"."0.5.3";
-  by-version."negotiator"."0.5.3" = self.buildNodePackage {
-    name = "negotiator-0.5.3";
-    version = "0.5.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/negotiator/-/negotiator-0.5.3.tgz";
-      name = "negotiator-0.5.3.tgz";
-      sha1 = "269d5c476810ec92edbe7b6c2f28316384f9a7e8";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."on-finished"."~2.2.0" =
-    self.by-version."on-finished"."2.2.1";
-  by-version."on-finished"."2.2.1" = self.buildNodePackage {
-    name = "on-finished-2.2.1";
-    version = "2.2.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/on-finished/-/on-finished-2.2.1.tgz";
-      name = "on-finished-2.2.1.tgz";
-      sha1 = "5c85c1cc36299f78029653f667f27b6b99ebc029";
-    };
-    deps = {
-      "ee-first-1.1.0" = self.by-version."ee-first"."1.1.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."optimist"."~0.6.0" =
-    self.by-version."optimist"."0.6.1";
-  by-version."optimist"."0.6.1" = self.buildNodePackage {
-    name = "optimist-0.6.1";
-    version = "0.6.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz";
-      name = "optimist-0.6.1.tgz";
-      sha1 = "da3ea74686fa21a19a111c326e90eb15a0196686";
-    };
-    deps = {
-      "wordwrap-0.0.3" = self.by-version."wordwrap"."0.0.3";
-      "minimist-0.0.10" = self.by-version."minimist"."0.0.10";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."parseurl"."~1.3.0" =
-    self.by-version."parseurl"."1.3.0";
-  by-version."parseurl"."1.3.0" = self.buildNodePackage {
-    name = "parseurl-1.3.0";
-    version = "1.3.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/parseurl/-/parseurl-1.3.0.tgz";
-      name = "parseurl-1.3.0.tgz";
-      sha1 = "b58046db4223e145afa76009e61bac87cc2281b3";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."path-to-regexp"."0.1.3" =
-    self.by-version."path-to-regexp"."0.1.3";
-  by-version."path-to-regexp"."0.1.3" = self.buildNodePackage {
-    name = "path-to-regexp-0.1.3";
-    version = "0.1.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.3.tgz";
-      name = "path-to-regexp-0.1.3.tgz";
-      sha1 = "21b9ab82274279de25b156ea08fd12ca51b8aecb";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."pause-stream"."0.0.11" =
-    self.by-version."pause-stream"."0.0.11";
-  by-version."pause-stream"."0.0.11" = self.buildNodePackage {
-    name = "pause-stream-0.0.11";
-    version = "0.0.11";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz";
-      name = "pause-stream-0.0.11.tgz";
-      sha1 = "fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445";
-    };
-    deps = {
-      "through-2.3.8" = self.by-version."through"."2.3.8";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."pkginfo"."0.3.x" =
-    self.by-version."pkginfo"."0.3.0";
-  by-version."pkginfo"."0.3.0" = self.buildNodePackage {
-    name = "pkginfo-0.3.0";
-    version = "0.3.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/pkginfo/-/pkginfo-0.3.0.tgz";
-      name = "pkginfo-0.3.0.tgz";
-      sha1 = "726411401039fe9b009eea86614295d5f3a54276";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."properties"."1.2.1" =
-    self.by-version."properties"."1.2.1";
-  by-version."properties"."1.2.1" = self.buildNodePackage {
-    name = "properties-1.2.1";
-    version = "1.2.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/properties/-/properties-1.2.1.tgz";
-      name = "properties-1.2.1.tgz";
-      sha1 = "0ee97a7fc020b1a2a55b8659eda4aa8d869094bd";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."proxy-addr"."~1.0.6" =
-    self.by-version."proxy-addr"."1.0.8";
-  by-version."proxy-addr"."1.0.8" = self.buildNodePackage {
-    name = "proxy-addr-1.0.8";
-    version = "1.0.8";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.8.tgz";
-      name = "proxy-addr-1.0.8.tgz";
-      sha1 = "db54ec878bcc1053d57646609219b3715678bafe";
-    };
-    deps = {
-      "forwarded-0.1.0" = self.by-version."forwarded"."0.1.0";
-      "ipaddr.js-1.0.1" = self.by-version."ipaddr.js"."1.0.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."qs"."1.2.0" =
-    self.by-version."qs"."1.2.0";
-  by-version."qs"."1.2.0" = self.buildNodePackage {
-    name = "qs-1.2.0";
-    version = "1.2.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/qs/-/qs-1.2.0.tgz";
-      name = "qs-1.2.0.tgz";
-      sha1 = "ed079be28682147e6fd9a34cc2b0c1e0ec6453ee";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."qs"."2.3.3" =
-    self.by-version."qs"."2.3.3";
-  by-version."qs"."2.3.3" = self.buildNodePackage {
-    name = "qs-2.3.3";
-    version = "2.3.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/qs/-/qs-2.3.3.tgz";
-      name = "qs-2.3.3.tgz";
-      sha1 = "e9e85adbe75da0bbe4c8e0476a086290f863b404";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."range-parser"."~1.0.2" =
-    self.by-version."range-parser"."1.0.2";
-  by-version."range-parser"."1.0.2" = self.buildNodePackage {
-    name = "range-parser-1.0.2";
-    version = "1.0.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/range-parser/-/range-parser-1.0.2.tgz";
-      name = "range-parser-1.0.2.tgz";
-      sha1 = "06a12a42e5131ba8e457cd892044867f2344e549";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."readable-stream"."1.0.27-1" =
-    self.by-version."readable-stream"."1.0.27-1";
-  by-version."readable-stream"."1.0.27-1" = self.buildNodePackage {
-    name = "readable-stream-1.0.27-1";
-    version = "1.0.27-1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.27-1.tgz";
-      name = "readable-stream-1.0.27-1.tgz";
-      sha1 = "6b67983c20357cefd07f0165001a16d710d91078";
-    };
-    deps = {
-      "core-util-is-1.0.1" = self.by-version."core-util-is"."1.0.1";
-      "isarray-0.0.1" = self.by-version."isarray"."0.0.1";
-      "string_decoder-0.10.31" = self.by-version."string_decoder"."0.10.31";
-      "inherits-2.0.1" = self.by-version."inherits"."2.0.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."redis"."0.12.x" =
-    self.by-version."redis"."0.12.1";
-  by-version."redis"."0.12.1" = self.buildNodePackage {
-    name = "redis-0.12.1";
-    version = "0.12.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/redis/-/redis-0.12.1.tgz";
-      name = "redis-0.12.1.tgz";
-      sha1 = "64df76ad0fc8acebaebd2a0645e8a48fac49185e";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."reduce-component"."1.0.1" =
-    self.by-version."reduce-component"."1.0.1";
-  by-version."reduce-component"."1.0.1" = self.buildNodePackage {
-    name = "reduce-component-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/reduce-component/-/reduce-component-1.0.1.tgz";
-      name = "reduce-component-1.0.1.tgz";
-      sha1 = "e0c93542c574521bea13df0f9488ed82ab77c5da";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."send"."0.11.1" =
-    self.by-version."send"."0.11.1";
-  by-version."send"."0.11.1" = self.buildNodePackage {
-    name = "send-0.11.1";
-    version = "0.11.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/send/-/send-0.11.1.tgz";
-      name = "send-0.11.1.tgz";
-      sha1 = "1beabfd42f9e2709f99028af3078ac12b47092d5";
-    };
-    deps = {
-      "debug-2.1.3" = self.by-version."debug"."2.1.3";
-      "depd-1.0.1" = self.by-version."depd"."1.0.1";
-      "destroy-1.0.3" = self.by-version."destroy"."1.0.3";
-      "escape-html-1.0.1" = self.by-version."escape-html"."1.0.1";
-      "etag-1.5.1" = self.by-version."etag"."1.5.1";
-      "fresh-0.2.4" = self.by-version."fresh"."0.2.4";
-      "mime-1.2.11" = self.by-version."mime"."1.2.11";
-      "ms-0.7.0" = self.by-version."ms"."0.7.0";
-      "on-finished-2.2.1" = self.by-version."on-finished"."2.2.1";
-      "range-parser-1.0.2" = self.by-version."range-parser"."1.0.2";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."serve-static"."~1.8.1" =
-    self.by-version."serve-static"."1.8.1";
-  by-version."serve-static"."1.8.1" = self.buildNodePackage {
-    name = "serve-static-1.8.1";
-    version = "1.8.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/serve-static/-/serve-static-1.8.1.tgz";
-      name = "serve-static-1.8.1.tgz";
-      sha1 = "08fabd39999f050fc311443f46d5888a77ecfc7c";
-    };
-    deps = {
-      "escape-html-1.0.1" = self.by-version."escape-html"."1.0.1";
-      "parseurl-1.3.0" = self.by-version."parseurl"."1.3.0";
-      "send-0.11.1" = self.by-version."send"."0.11.1";
-      "utils-merge-1.0.0" = self.by-version."utils-merge"."1.0.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."split"."0.3" =
-    self.by-version."split"."0.3.3";
-  by-version."split"."0.3.3" = self.buildNodePackage {
-    name = "split-0.3.3";
-    version = "0.3.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/split/-/split-0.3.3.tgz";
-      name = "split-0.3.3.tgz";
-      sha1 = "cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f";
-    };
-    deps = {
-      "through-2.3.8" = self.by-version."through"."2.3.8";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."stack-trace"."0.0.x" =
-    self.by-version."stack-trace"."0.0.9";
-  by-version."stack-trace"."0.0.9" = self.buildNodePackage {
-    name = "stack-trace-0.0.9";
-    version = "0.0.9";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz";
-      name = "stack-trace-0.0.9.tgz";
-      sha1 = "a8f6eaeca90674c333e7c43953f275b451510695";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."stream-combiner"."~0.0.4" =
-    self.by-version."stream-combiner"."0.0.4";
-  by-version."stream-combiner"."0.0.4" = self.buildNodePackage {
-    name = "stream-combiner-0.0.4";
-    version = "0.0.4";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz";
-      name = "stream-combiner-0.0.4.tgz";
-      sha1 = "4d5e433c185261dde623ca3f44c586bcf5c4ad14";
-    };
-    deps = {
-      "duplexer-0.1.1" = self.by-version."duplexer"."0.1.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."string"."2.0.1" =
-    self.by-version."string"."2.0.1";
-  by-version."string"."2.0.1" = self.buildNodePackage {
-    name = "string-2.0.1";
-    version = "2.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/string/-/string-2.0.1.tgz";
-      name = "string-2.0.1.tgz";
-      sha1 = "ef1473b3e11cb8158671856556959b9aff5fd759";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."string_decoder"."~0.10.x" =
-    self.by-version."string_decoder"."0.10.31";
-  by-version."string_decoder"."0.10.31" = self.buildNodePackage {
-    name = "string_decoder-0.10.31";
-    version = "0.10.31";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz";
-      name = "string_decoder-0.10.31.tgz";
-      sha1 = "62e203bc41766c6c28c9fc84301dab1c5310fa94";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."superagent"."0.21.0" =
-    self.by-version."superagent"."0.21.0";
-  by-version."superagent"."0.21.0" = self.buildNodePackage {
-    name = "superagent-0.21.0";
-    version = "0.21.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/superagent/-/superagent-0.21.0.tgz";
-      name = "superagent-0.21.0.tgz";
-      sha1 = "fb15027984751ee7152200e6cd21cd6e19a5de87";
-    };
-    deps = {
-      "qs-1.2.0" = self.by-version."qs"."1.2.0";
-      "formidable-1.0.14" = self.by-version."formidable"."1.0.14";
-      "mime-1.2.11" = self.by-version."mime"."1.2.11";
-      "component-emitter-1.1.2" = self.by-version."component-emitter"."1.1.2";
-      "methods-1.0.1" = self.by-version."methods"."1.0.1";
-      "cookiejar-2.0.1" = self.by-version."cookiejar"."2.0.1";
-      "debug-2.2.0" = self.by-version."debug"."2.2.0";
-      "reduce-component-1.0.1" = self.by-version."reduce-component"."1.0.1";
-      "extend-1.2.1" = self.by-version."extend"."1.2.1";
-      "form-data-0.1.3" = self.by-version."form-data"."0.1.3";
-      "readable-stream-1.0.27-1" = self.by-version."readable-stream"."1.0.27-1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."through"."2" =
-    self.by-version."through"."2.3.8";
-  by-version."through"."2.3.8" = self.buildNodePackage {
-    name = "through-2.3.8";
-    version = "2.3.8";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/through/-/through-2.3.8.tgz";
-      name = "through-2.3.8.tgz";
-      sha1 = "0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."through"."~2.3" =
-    self.by-version."through"."2.3.8";
-  by-spec."through"."~2.3.1" =
-    self.by-version."through"."2.3.8";
-  by-spec."type-is"."~1.5.6" =
-    self.by-version."type-is"."1.5.7";
-  by-version."type-is"."1.5.7" = self.buildNodePackage {
-    name = "type-is-1.5.7";
-    version = "1.5.7";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/type-is/-/type-is-1.5.7.tgz";
-      name = "type-is-1.5.7.tgz";
-      sha1 = "b9368a593cc6ef7d0645e78b2f4c64cbecd05e90";
-    };
-    deps = {
-      "media-typer-0.3.0" = self.by-version."media-typer"."0.3.0";
-      "mime-types-2.0.14" = self.by-version."mime-types"."2.0.14";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."utils-merge"."1.0.0" =
-    self.by-version."utils-merge"."1.0.0";
-  by-version."utils-merge"."1.0.0" = self.buildNodePackage {
-    name = "utils-merge-1.0.0";
-    version = "1.0.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz";
-      name = "utils-merge-1.0.0.tgz";
-      sha1 = "0294fb922bb9375153541c4f7096231f287c8af8";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."vary"."~1.0.0" =
-    self.by-version."vary"."1.0.1";
-  by-version."vary"."1.0.1" = self.buildNodePackage {
-    name = "vary-1.0.1";
-    version = "1.0.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/vary/-/vary-1.0.1.tgz";
-      name = "vary-1.0.1.tgz";
-      sha1 = "99e4981566a286118dfb2b817357df7993376d10";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."verror"."^1.4.0" =
-    self.by-version."verror"."1.6.0";
-  by-version."verror"."1.6.0" = self.buildNodePackage {
-    name = "verror-1.6.0";
-    version = "1.6.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/verror/-/verror-1.6.0.tgz";
-      name = "verror-1.6.0.tgz";
-      sha1 = "7d13b27b1facc2e2da90405eb5ea6e5bdd252ea5";
-    };
-    deps = {
-      "extsprintf-1.2.0" = self.by-version."extsprintf"."1.2.0";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."websocket-driver".">=0.5.1" =
-    self.by-version."websocket-driver"."0.6.2";
-  by-version."websocket-driver"."0.6.2" = self.buildNodePackage {
-    name = "websocket-driver-0.6.2";
-    version = "0.6.2";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/websocket-driver/-/websocket-driver-0.6.2.tgz";
-      name = "websocket-driver-0.6.2.tgz";
-      sha1 = "8281dba3e299e5bd7a42b65d4577a8928c26f898";
-    };
-    deps = {
-      "websocket-extensions-0.1.1" = self.by-version."websocket-extensions"."0.1.1";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."websocket-extensions".">=0.1.1" =
-    self.by-version."websocket-extensions"."0.1.1";
-  by-version."websocket-extensions"."0.1.1" = self.buildNodePackage {
-    name = "websocket-extensions-0.1.1";
-    version = "0.1.1";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.1.tgz";
-      name = "websocket-extensions-0.1.1.tgz";
-      sha1 = "76899499c184b6ef754377c2dbb0cd6cb55d29e7";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."winston"."0.8.0" =
-    self.by-version."winston"."0.8.0";
-  by-version."winston"."0.8.0" = self.buildNodePackage {
-    name = "winston-0.8.0";
-    version = "0.8.0";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/winston/-/winston-0.8.0.tgz";
-      name = "winston-0.8.0.tgz";
-      sha1 = "61d0830fa699706212206b0a2b5ca69a93043668";
-    };
-    deps = {
-      "async-0.2.10" = self.by-version."async"."0.2.10";
-      "colors-0.6.2" = self.by-version."colors"."0.6.2";
-      "cycle-1.0.3" = self.by-version."cycle"."1.0.3";
-      "eyes-0.1.8" = self.by-version."eyes"."0.1.8";
-      "pkginfo-0.3.0" = self.by-version."pkginfo"."0.3.0";
-      "stack-trace-0.0.9" = self.by-version."stack-trace"."0.0.9";
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-  by-spec."wordwrap"."~0.0.2" =
-    self.by-version."wordwrap"."0.0.3";
-  by-version."wordwrap"."0.0.3" = self.buildNodePackage {
-    name = "wordwrap-0.0.3";
-    version = "0.0.3";
-    bin = false;
-    src = fetchurl {
-      url = "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz";
-      name = "wordwrap-0.0.3.tgz";
-      sha1 = "a3d5da6cd5c0bc0008d37234bbaf1bed63059107";
-    };
-    deps = {
-    };
-    optionalDependencies = {
-    };
-    peerDependencies = [];
-    os = [ ];
-    cpu = [ ];
-  };
-}
diff --git a/pkgs/servers/elasticmq/default.nix b/pkgs/servers/elasticmq/default.nix
index 0fec6a5fe0e9..c1216becaf3d 100644
--- a/pkgs/servers/elasticmq/default.nix
+++ b/pkgs/servers/elasticmq/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
       cp bin/run.sh $out/bin/elasticmq
       substituteInPlace $out/bin/elasticmq --replace '-DBASEDIR=$BASEDIR' '-DBASEDIR=''${ELASTICMQ_DATA_PREFIX:-.}'
 
-      wrapProgram $out/bin/elasticmq --prefix PATH : "${which}/bin:${jre}/bin"
+      wrapProgram $out/bin/elasticmq --prefix PATH : "${stdenv.lib.makeBinPath [ which jre ]}"
     '';
 
   meta = {
@@ -35,5 +35,6 @@ stdenv.mkDerivation rec {
         Default.scala included in the distribution as a template.
       '';
     license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/servers/emby/default.nix b/pkgs/servers/emby/default.nix
new file mode 100644
index 000000000000..f781e1114ebe
--- /dev/null
+++ b/pkgs/servers/emby/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, pkgs, unzip, sqlite, makeWrapper, mono46, ffmpeg, ... }:
+
+stdenv.mkDerivation rec {
+  name = "emby-${version}";
+  version = "3.4.1.0";
+
+  src = fetchurl {
+    url = "https://github.com/MediaBrowser/Emby/releases/download/${version}/Emby.Mono.zip";
+    sha256 = "08jr6v8xhmiwbby0lfvpjrlma280inwh5qp6v4p93lzd07fjynh5";
+  };
+
+  buildInputs = with pkgs; [
+    unzip
+    makeWrapper
+  ];
+  propagatedBuildInputs = with pkgs; [
+    mono46
+    sqlite
+  ];
+
+  # Need to set sourceRoot as unpacker will complain about multiple directory output
+  sourceRoot = ".";
+
+  buildPhase = ''
+    substituteInPlace SQLitePCLRaw.provider.sqlite3.dll.config --replace libsqlite3.so ${sqlite.out}/lib/libsqlite3.so
+    substituteInPlace MediaBrowser.Server.Mono.exe.config --replace ProgramData-Server "/var/lib/emby/ProgramData-Server"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -r * $out/bin
+
+    makeWrapper "${mono46}/bin/mono" $out/bin/MediaBrowser.Server.Mono \
+      --add-flags "$out/bin/MediaBrowser.Server.Mono.exe -ffmpeg ${ffmpeg}/bin/ffmpeg -ffprobe ${ffmpeg}/bin/ffprobe"
+  '';
+
+  meta = {
+    description = "MediaBrowser - Bring together your videos, music, photos, and live television";
+    homepage = https://emby.media/;
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ stdenv.lib.maintainers.fadenb ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/pkgs/servers/etcd/default.nix b/pkgs/servers/etcd/default.nix
new file mode 100644
index 000000000000..29cb8c2223c0
--- /dev/null
+++ b/pkgs/servers/etcd/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, lib, libpcap, buildGoPackage, fetchFromGitHub }:
+
+with lib;
+
+buildGoPackage rec {
+  name = "etcd-${version}";
+  version = "3.3.1"; # After updating check that nixos tests pass
+  rev = "v${version}";
+
+  goPackagePath = "github.com/coreos/etcd";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "coreos";
+    repo = "etcd";
+    sha256 = "11gzmi05y4kpnzgqc737l0wk5svxai4z17nl92jazqga6zhyavyl";
+  };
+
+  subPackages = [
+    "cmd/etcd"
+    "cmd/etcdctl"
+    "cmd/tools/benchmark"
+    "cmd/tools/etcd-dump-db"
+    "cmd/tools/etcd-dump-logs"
+  ];
+
+  buildInputs = [ libpcap ];
+
+  meta = {
+    description = "Distributed reliable key-value store for the most critical data of a distributed system";
+    license = licenses.asl20;
+    homepage = https://coreos.com/etcd/;
+    maintainers = with maintainers; [offline];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/pkgs/servers/exhibitor/default.nix b/pkgs/servers/exhibitor/default.nix
new file mode 100644
index 000000000000..c1234606291d
--- /dev/null
+++ b/pkgs/servers/exhibitor/default.nix
@@ -0,0 +1,54 @@
+{ fetchFromGitHub, buildMaven, maven, jdk, makeWrapper, stdenv, ... }:
+stdenv.mkDerivation rec {
+  name = "exhibitor-${version}";
+  version = "1.5.6";
+
+  src = fetchFromGitHub {
+    owner = "soabase";
+    repo = "exhibitor";
+    sha256 = "07vikhkldxy51jbpy3jgva6wz75jksch6bjd6dqkagfgqd6baw45";
+    rev = "5fcdb411d06e8638c2380f7acb72a8a6909739cd";
+  };
+  mavenDependenciesSha256 = "00r69n9hwvrn5cbhxklx7w00sjmqvcxs7gvhbm150ggy7bc865qv";
+  # This is adapted from https://github.com/volth/nixpkgs/blob/6aa470dfd57cae46758b62010a93c5ff115215d7/pkgs/applications/networking/cluster/hadoop/default.nix#L20-L32
+  fetchedMavenDeps = stdenv.mkDerivation {
+    name = "exhibitor-${version}-maven-deps";
+    inherit src nativeBuildInputs;
+    buildPhase = ''
+      cd ${pomFileDir};
+      while timeout --kill-after=21m 20m mvn package -Dmaven.repo.local=$out/.m2; [ $? = 124 ]; do
+        echo "maven hangs while downloading :("
+      done
+    '';
+    installPhase = ''find $out/.m2 -type f \! -regex '.+\(pom\|jar\|xml\|sha1\)' -delete''; # delete files with lastModified timestamps inside
+    outputHashAlgo = "sha256";
+    outputHashMode = "recursive";
+    outputHash = mavenDependenciesSha256;
+  };
+
+  # The purpose of this is to fetch the jar file out of public Maven and use Maven
+  # to build a monolithic, standalone jar, rather than build everything from source
+  # (given the state of Maven support in Nix). We're not actually building any java
+  # source here.
+  pomFileDir = "exhibitor-standalone/src/main/resources/buildscripts/standalone/maven";
+  nativeBuildInputs = [ maven ];
+  buildInputs = [ makeWrapper ];
+  buildPhase = ''
+      cd ${pomFileDir}
+      mvn package --offline -Dmaven.repo.local=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2
+  '';
+  meta = with stdenv.lib; {
+    homepage = https://github.com/soabase/exhibitor;
+    description = "ZooKeeper co-process for instance monitoring, backup/recovery, cleanup and visualization";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/java
+    mv target/$name.jar $out/share/java/
+    makeWrapper ${jdk}/bin/java $out/bin/startExhibitor.sh --add-flags "-jar $out/share/java/$name.jar" --suffix PATH : ${stdenv.lib.makeBinPath [ jdk ]}
+  '';
+
+}
diff --git a/pkgs/servers/fcgiwrap/default.nix b/pkgs/servers/fcgiwrap/default.nix
index 84deebcb8f5b..a1ec3a7deb08 100644
--- a/pkgs/servers/fcgiwrap/default.nix
+++ b/pkgs/servers/fcgiwrap/default.nix
@@ -9,13 +9,21 @@ stdenv.mkDerivation rec {
     sha256 = "07y6s4mm86cv7p1ljz94sxnqa89y9amn3vzwsnbq5hrl4vdy0zac";
   };
 
+  NIX_CFLAGS_COMPILE = "-Wno-error=implicit-fallthrough";
   configureFlags = [ "--with-systemd" "--with-systemdsystemunitdir=$(out)/etc/systemd/system" ];
 
-  buildInputs = [ autoreconfHook systemd fcgi pkgconfig ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ systemd fcgi ];
+
+  # systemd 230 no longer has libsystemd-daemon as a separate entity from libsystemd
+  postPatch = ''
+    substituteInPlace configure.ac --replace libsystemd-daemon libsystemd
+  '';
 
   meta = with stdenv.lib; {
     homepage = https://nginx.localdomain.pl/wiki/FcgiWrap;
     description = "Simple server for running CGI applications over FastCGI";
     maintainers = with maintainers; [ lethalman ];
+    platforms = with platforms; linux;
   };
 }
diff --git a/pkgs/servers/felix/default.nix b/pkgs/servers/felix/default.nix
index 17a50506fa92..5ce680e36460 100644
--- a/pkgs/servers/felix/default.nix
+++ b/pkgs/servers/felix/default.nix
@@ -1,10 +1,11 @@
 {stdenv, fetchurl}:
 
-stdenv.mkDerivation {
-  name = "apache-felix-2.0.5";
+stdenv.mkDerivation rec {
+  name = "apache-felix-${version}";
+  version = "5.6.1";
   src = fetchurl {
-    url = http://apache.xl-mirror.nl/felix/org.apache.felix.main.distribution-2.0.5.tar.gz;
-    sha256 = "14nva0q1b45kmmalcls5yx97syd4vn3vcp8gywck1098qhidi66g";
+    url = "mirror://apache/felix/org.apache.felix.main.distribution-${version}.tar.gz";
+    sha256 = "0kis26iajzdid162j4i7g558q09x4hn9z7pqqys6ipb0fj84hz1x";
   };
   buildCommand =
   ''
@@ -15,7 +16,7 @@ stdenv.mkDerivation {
   '';
   meta = with stdenv.lib; {
     description = "An OSGi gateway";
-    homepage = http://felix.apache.org;
+    homepage = https://felix.apache.org;
     license = licenses.asl20;
     maintainers = [ maintainers.sander ];
   };
diff --git a/pkgs/servers/felix/remoteshell.nix b/pkgs/servers/felix/remoteshell.nix
index 6e8089d32e97..3ac3c98718f7 100644
--- a/pkgs/servers/felix/remoteshell.nix
+++ b/pkgs/servers/felix/remoteshell.nix
@@ -1,14 +1,15 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation rec {
-  name = "apache-felix-remoteshell-bundle-1.0.4";
+  version = "1.1.2";
+  name = "apache-felix-remoteshell-bundle-${version}";
   src = fetchurl {
-    url = http://apache.proserve.nl/felix/org.apache.felix.shell.remote-1.0.4.jar;
-    sha256 = "1bgahzs9nnnvfr0yyh9s0r6h1zp2ls6533377rp8r1qk2a4s1gzb";
+    url = "http://apache.proserve.nl/felix/org.apache.felix.shell.remote-${version}.jar";
+    sha256 = "147zw5ppn98wfl3pr32isyb267xm3gwsvdfdvjr33m9g2v1z69aq";
   };
-  buildCommand = 
+  buildCommand =
   ''
     mkdir -p $out/bundle
-    cp ${src} $out/bundle/org.apache.felix.shell.remote-1.0.4.jar
+    cp ${src} $out/bundle/org.apache.felix.shell.remote-${version}.jar
   '';
 }
diff --git a/pkgs/servers/fingerd/bsd-fingerd/default.nix b/pkgs/servers/fingerd/bsd-fingerd/default.nix
index 2fab0fd9910c..f7f2f93cf99e 100644
--- a/pkgs/servers/fingerd/bsd-fingerd/default.nix
+++ b/pkgs/servers/fingerd/bsd-fingerd/default.nix
@@ -17,4 +17,8 @@ stdenv.mkDerivation rec {
   preBuild = "cd fingerd";
 
   preInstall = '' mkdir -p $out/man/man8 $out/sbin '';
+
+  meta = {
+    platforms = stdenv.lib.platforms.linux;
+  };
 }
diff --git a/pkgs/servers/firebird/default.nix b/pkgs/servers/firebird/default.nix
index 3e778317169c..24ed1dffd4d8 100644
--- a/pkgs/servers/firebird/default.nix
+++ b/pkgs/servers/firebird/default.nix
@@ -1,5 +1,5 @@
 {stdenv, fetchurl, libedit, ncurses, automake, autoconf, libtool
-, 
+,
   # icu = null: use icu which comes with firebird
 
   # icu = pkgs.icu => you may have trouble sharing database files with windows
@@ -11,7 +11,7 @@
   # icu version missmatch may cause such error when selecting from a table:
   # "Collation unicode for character set utf8 is not installed"
 
-  # icu 3.0 can still be build easily by nix (by dropping the #elif case and
+  # icu 3.0 can still be built easily by nix (by dropping the #elif case and
   # make | make)
   icu ? null
 
@@ -38,7 +38,7 @@
 */
 
 stdenv.mkDerivation rec {
-  version = "2.5.2.26540-0";
+  version = "2.5.7.27050-0";
   name = "firebird-${version}";
 
   # enableParallelBuilding = false; build fails
@@ -62,9 +62,11 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://sourceforge/firebird/Firebird-${version}.tar.bz2";
-    sha256 = "0887a813wffp44hnc2gmwbc4ylpqw3fh3hz3bf6q3648344a9fdv";
+    sha256 = "06hp6bq5irqvm3h03s79qjgcc3jsjpq150y9aq7anklx9v4nhfqa";
   };
 
+  hardeningDisable = [ "format" ];
+
   # configurePhase = ''
   #   sed -i 's@cp /usr/share/automake-.*@@' autogen.sh
   #   sh autogen.sh $configureFlags --prefix=$out
@@ -80,7 +82,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "SQL relational database management system";
-    homepage = http://www.firebirdnews.org;
+    homepage = https://www.firebirdnews.org;
     license = ["IDPL" "Interbase-1.0"];
     maintainers = [stdenv.lib.maintainers.marcweber];
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/servers/fleet/default.nix b/pkgs/servers/fleet/default.nix
deleted file mode 100644
index 5d8620ed7758..000000000000
--- a/pkgs/servers/fleet/default.nix
+++ /dev/null
@@ -1,33 +0,0 @@
-{ stdenv, lib, go, fetchFromGitHub }:
-
-stdenv.mkDerivation rec {
-  name = "fleet-${version}";
-  version = "0.11.5";
-
-  src = fetchFromGitHub {
-    owner = "coreos";
-    repo = "fleet";
-    rev = "v${version}";
-    sha256 = "0dc95dpqqc2rclbvgdqjcilrkji7lrpigdrzpwm3nbgz58vkfnz3";
-  };
-
-  buildInputs = [ go ];
-
-  buildPhase = ''
-    patchShebangs build
-    ./build
-  '';
-
-  installPhase = ''
-    mkdir -p $out
-    mv bin $out
-  '';
-
-  meta = with stdenv.lib; {
-    description = "A distributed init system";
-    homepage = http://coreos.com/using-coreos/clustering/;
-    license = licenses.asl20;
-    maintainers = with maintainers; [ cstrahan offline ];
-    platforms = platforms.unix;
-  };
-}
diff --git a/pkgs/servers/foswiki/default.nix b/pkgs/servers/foswiki/default.nix
new file mode 100644
index 000000000000..5bfeef6f1fc1
--- /dev/null
+++ b/pkgs/servers/foswiki/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, perlPackages }:
+
+perlPackages.buildPerlPackage rec {
+  name = "foswiki-${version}";
+  version = "2.1.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/foswiki/${version}/Foswiki-${version}.tgz";
+    sha256 = "03286pb966h99zgickm2f20rgnqwp9wga5wfkdvirv084kjdh8vp";
+  };
+
+  outputs = [ "out" ];
+
+  buildInputs = with perlPackages; [
+    # minimum requirements from INSTALL.html#System_Requirements
+    AlgorithmDiff ArchiveTar AuthenSASL CGI CGISession CryptPasswdMD5
+    DigestSHA EmailMIME Encode Error FileCopyRecursive HTMLParser HTMLTree
+    IOSocketIP IOSocketSSL JSON
+    LocaleMaketext LocaleMaketextLexicon LocaleMsgfmt
+    LWP URI perlPackages.version
+    /*# optional dependencies
+    libapreq2 DBI DBDmysql DBDPg DBDSQLite FCGI FCGIProcManager
+    CryptSMIME CryptX509 ConvertPEM
+    */
+  ];
+
+  preConfigure = ''
+    touch Makefile.PL
+    patchShebangs .
+  '';
+  configureScript = "bin/configure";
+
+  # there's even no makefile
+  doCheck = false;
+  installPhase = ''cp -r . "$out" '';
+
+  meta = with stdenv.lib; {
+    description = "An open, programmable collaboration platform";
+    homepage = http://foswiki.org;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+}
+
diff --git a/pkgs/servers/foundationdb/default.nix b/pkgs/servers/foundationdb/default.nix
new file mode 100644
index 000000000000..5ebb510be467
--- /dev/null
+++ b/pkgs/servers/foundationdb/default.nix
@@ -0,0 +1,129 @@
+{ stdenv, fetchurl, fetchFromGitHub
+, which, findutils, m4, gawk
+, python, openjdk, mono58, libressl_2_6
+, boost16x
+}:
+
+let
+  makeFdb =
+    { version
+    , branch
+    , rev, sha256
+
+    # fdb 6.0+ support boost 1.6x+, so default to it
+    , boost ? boost16x
+    }: stdenv.mkDerivation rec {
+        name = "foundationdb-${version}";
+        inherit version;
+
+        src = fetchFromGitHub {
+          owner = "apple";
+          repo  = "foundationdb";
+          inherit rev sha256;
+        };
+
+        nativeBuildInputs = [ gawk which m4 findutils mono58 ];
+        buildInputs = [ python openjdk libressl_2_6 boost ];
+
+        patches =
+          [ ./fix-scm-version.patch
+            ./ldflags.patch
+          ];
+
+        postPatch = ''
+          substituteInPlace ./build/scver.mk \
+            --subst-var-by NIXOS_FDB_VERSION_ID "${rev}" \
+            --subst-var-by NIXOS_FDB_SCBRANCH   "${branch}"
+
+          substituteInPlace ./Makefile \
+            --replace 'shell which ccache' 'shell true' \
+            --replace -Werror ""
+
+          substituteInPlace ./Makefile \
+            --replace libstdc++_pic libstdc++
+
+          substituteInPlace ./build/link-validate.sh \
+            --replace 'exit 1' '#exit 1'
+
+          patchShebangs .
+        '';
+
+        enableParallelBuilding = true;
+        makeFlags = [ "all" "fdb_c" "fdb_java" "KVRELEASE=1" ];
+
+        configurePhase = ":";
+        installPhase = ''
+          mkdir -vp $out/{bin,libexec/plugins} $lib/{lib,share/java} $dev/include/foundationdb
+
+          cp -v ./lib/libfdb_c.so     $lib/lib
+          cp -v ./lib/libFDBLibTLS.so $out/libexec/plugins/FDBLibTLS.so
+
+          cp -v ./bindings/c/foundationdb/fdb_c.h           $dev/include/foundationdb
+          cp -v ./bindings/c/foundationdb/fdb_c_options.g.h $dev/include/foundationdb
+
+          cp -v ./bindings/java/foundationdb-client.jar     $lib/share/java/fdb-java.jar
+
+          for x in fdbbackup fdbcli fdbserver fdbmonitor; do
+            cp -v "./bin/$x" $out/bin;
+          done
+
+          ln -sfv $out/bin/fdbbackup $out/bin/dr_agent
+          ln -sfv $out/bin/fdbbackup $out/bin/fdbrestore
+          ln -sfv $out/bin/fdbbackup $out/bin/fdbdr
+
+          ln -sfv $out/bin/fdbbackup $out/libexec/backup_agent
+        '';
+
+        outputs = [ "out" "lib" "dev" ];
+
+        meta = with stdenv.lib; {
+          description = "Open source, distributed, transactional key-value store";
+          homepage    = https://www.foundationdb.org;
+          license     = licenses.asl20;
+          platforms   = platforms.linux;
+          maintainers = with maintainers; [ thoughtpolice ];
+       };
+    };
+
+  # hysterical raisins dictate a version of boost this old. however,
+  # we luckily do not need to build anything, we just need the header
+  # files.
+  boost152 = stdenv.mkDerivation rec {
+    name = "boost-headers-1.52.0";
+
+    src = fetchurl {
+      url = "mirror://sourceforge/boost/boost_1_52_0.tar.bz2";
+      sha256 = "14mc7gsnnahdjaxbbslzk79rc0d12h1i681cd3srdwr3fzynlar2";
+    };
+
+    configurePhase = ":";
+    buildPhase = ":";
+    installPhase = "mkdir -p $out/include && cp -R boost $out/include/";
+  };
+
+in with builtins; {
+
+  foundationdb51 = makeFdb {
+    version = "5.1.7";
+    branch  = "release-5.1";
+    rev     = "9ad8d02386d4a6a5efecf898df80f2747695c627";
+    sha256  = "1rc472ih24f9s5g3xmnlp3v62w206ny0pvvw02bzpix2sdrpbp06";
+    boost   = boost152;
+  };
+
+  foundationdb52 = makeFdb rec {
+    version = "5.2.0pre1488_${substring 0 8 rev}";
+    branch  = "master";
+    rev     = "18f345487ed8d90a5c170d813349fa625cf05b4e";
+    sha256  = "0mz30fxj6q99cvjzg39s5zm992i6h2l2cb70lc58bdhsz92dz3vc";
+    boost   = boost152;
+  };
+
+  foundationdb60 = makeFdb rec {
+    version = "6.0.0pre1636_${substring 0 8 rev}";
+    branch  = "master";
+    rev     = "1265a7b6d5e632dd562b3012e70f0727979806bd";
+    sha256  = "0z1i5bkbszsbn8cc48rlhr29m54n2s0gq3dln0n7f97gf58mi5yf";
+  };
+
+}
diff --git a/pkgs/servers/foundationdb/fix-scm-version.patch b/pkgs/servers/foundationdb/fix-scm-version.patch
new file mode 100644
index 000000000000..0e0df7ade82b
--- /dev/null
+++ b/pkgs/servers/foundationdb/fix-scm-version.patch
@@ -0,0 +1,42 @@
+diff --git a/build/scver.mk b/build/scver.mk
+index bdae8be..7539864 100644
+--- a/build/scver.mk
++++ b/build/scver.mk
+@@ -98,33 +98,10 @@ endif
+ GITPRESENT := $(wildcard $(FDBDIR)/.git)
+ HGPRESENT := $(wildcard $(FDBDIR)/.hg)
+ 
+-# Use Git, if not missing
+-ifneq ($(GITPRESENT),)
+-	SCVER := $(shell cd "$(FDBDIR)" && git --version 2>/dev/null)
+-	ifneq ($(SCVER),)
+-		VERSION_ID := $(shell cd "$(FDBDIR)" && git rev-parse --verify HEAD)
+-		SOURCE_CONTROL := GIT
+-		SCBRANCH := $(shell cd "$(FDBDIR)" && git rev-parse --abbrev-ref HEAD)
+-	else
+-$(error Missing git executable on $(PLATFORM) )
+-	endif
+-# Otherwise, use Mercurial
+-else
+-	# Otherwise, use Mercurial, if not missing
+-	ifneq ($(HGPRESENT),)
+-		SCVER := $(shell cd "$(FDBDIR)" && hg --version 2>/dev/null)
+-		ifdef SCVER
+-			VERSION_ID := $(shell cd "$(FDBDIR)" && hg id -n)
+-			SOURCE_CONTROL := MERCURIAL
+-			SCBRANCH := $(shell cd "$(FDBDIR)" && hg branch)
+-		else
+-$(error Missing hg executable on $(PLATFORM))
+-		endif
+-	else
+-	FDBFILES := (shell ls -la $(FDBDIR))
+-$(error Missing source control information for source on $(PLATFORM) in directory: $(FDBDIR) with files: $(FDBFILES))
+-	endif
+-endif
++# NixOS-specific non-VCS packaging, filled out by the nix build
++SOURCE_CONTROL := GIT
++VERSION_ID     := @NIXOS_FDB_VERSION_ID@
++SCBRANCH       := @NIXOS_FDB_SCBRANCH@
+ 
+ # Set the RELEASE variable based on the KVRELEASE variable.
+ ifeq ($(KVRELEASE),1)
diff --git a/pkgs/servers/foundationdb/ldflags.patch b/pkgs/servers/foundationdb/ldflags.patch
new file mode 100644
index 000000000000..4d523a7ecdd3
--- /dev/null
+++ b/pkgs/servers/foundationdb/ldflags.patch
@@ -0,0 +1,90 @@
+diff --git a/FDBLibTLS/local.mk b/FDBLibTLS/local.mk
+index 0b6eac8..b1891ca 100644
+--- a/FDBLibTLS/local.mk
++++ b/FDBLibTLS/local.mk
+@@ -1,6 +1,5 @@
+ FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR)
+-FDBLibTLS_STATIC_LIBS := -ltls -lssl -lcrypto
+-FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt
++FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt -ltls -lssl -lcrypto
+ FDBLibTLS_LDFLAGS += -Wl,-soname,FDBLibTLS.so -Wl,--version-script=FDBLibTLS/FDBLibTLS.map
+ 
+ # The plugin isn't a typical library, so it feels more sensible to have a copy
+diff --git a/bindings/c/local.mk b/bindings/c/local.mk
+index 44f0c31..7aea5a4 100644
+--- a/bindings/c/local.mk
++++ b/bindings/c/local.mk
+@@ -29,8 +29,8 @@ fdb_c_tests_HEADERS := -Ibindings/c
+ CLEAN_TARGETS += fdb_c_tests_clean
+ 
+ ifeq ($(PLATFORM),linux)
+-  fdb_c_LIBS += lib/libstdc++.a -lm -lpthread -lrt -ldl
+-  fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete
++  fdb_c_LIBS += lib/libstdc++.a
++  fdb_c_LDFLAGS += -Wl,--version-script=bindings/c/fdb_c.map -static-libgcc -Wl,-z,nodelete -lm -lpthread -lrt -ldl
+   fdb_c_tests_LIBS += -lpthread
+ endif
+ 
+diff --git a/bindings/flow/tester/local.mk b/bindings/flow/tester/local.mk
+index 2ef4fcb..6e59625 100644
+--- a/bindings/flow/tester/local.mk
++++ b/bindings/flow/tester/local.mk
+@@ -35,8 +35,7 @@ _fdb_flow_tester_clean:
+ 	@rm -rf bindings/flow/bin
+ 
+ ifeq ($(PLATFORM),linux)
+-  fdb_flow_tester_LIBS += -ldl -lpthread -lrt
+-  fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc
++  fdb_flow_tester_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+ else ifeq ($(PLATFORM),osx)
+   fdb_flow_tester_LDFLAGS += -lc++
+ endif
+diff --git a/fdbbackup/local.mk b/fdbbackup/local.mk
+index 033fe7d..865fc92 100644
+--- a/fdbbackup/local.mk
++++ b/fdbbackup/local.mk
+@@ -25,8 +25,7 @@ fdbbackup_LDFLAGS := $(fdbrpc_LDFLAGS)
+ fdbbackup_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+ 
+ ifeq ($(PLATFORM),linux)
+-  fdbbackup_LIBS += -ldl -lpthread -lrt
+-  fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc
++  fdbbackup_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+ 
+   # GPerfTools profiler (uncomment to use)
+   # fdbbackup_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
+diff --git a/fdbcli/local.mk b/fdbcli/local.mk
+index 81a4a42..892c079 100644
+--- a/fdbcli/local.mk
++++ b/fdbcli/local.mk
+@@ -22,14 +22,13 @@
+ 
+ fdbcli_CFLAGS := $(fdbclient_CFLAGS)
+ fdbcli_LDFLAGS := $(fdbrpc_LDFLAGS)
+-fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a -ldl
++fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+ fdbcli_STATIC_LIBS :=
+ 
+ fdbcli_GENERATED_SOURCES += versions.h
+ 
+ ifeq ($(PLATFORM),linux)
+-  fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc
+-  fdbcli_LIBS += -lpthread -lrt
++  fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc -lpthread -lrt -ldl
+ else ifeq ($(PLATFORM),osx)
+   fdbcli_LDFLAGS += -lc++
+ endif
+diff --git a/fdbserver/local.mk b/fdbserver/local.mk
+index 78cad1b..36f2c0f 100644
+--- a/fdbserver/local.mk
++++ b/fdbserver/local.mk
+@@ -25,8 +25,7 @@ fdbserver_LDFLAGS := $(fdbrpc_LDFLAGS)
+ fdbserver_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a
+ 
+ ifeq ($(PLATFORM),linux)
+-  fdbserver_LIBS += -ldl -lpthread -lrt
+-  fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc
++  fdbserver_LDFLAGS += -static-libstdc++ -static-libgcc -ldl -lpthread -lrt
+ 
+   # GPerfTools profiler (uncomment to use)
+   # fdbserver_CFLAGS += -I/opt/gperftools/include -DUSE_GPERFTOOLS=1
diff --git a/pkgs/servers/freeradius/default.nix b/pkgs/servers/freeradius/default.nix
new file mode 100644
index 000000000000..a3e83f4e069e
--- /dev/null
+++ b/pkgs/servers/freeradius/default.nix
@@ -0,0 +1,87 @@
+{ stdenv, fetchurl, autoreconfHook, talloc, finger_bsd, perl
+, openssl
+, linkOpenssl? true
+, openldap
+, withLdap ? true
+, sqlite
+, withSqlite ? true
+, libpcap
+, withPcap ? true
+, libcap
+, withCap ? true
+, libmemcached
+, withMemcached ? false
+, hiredis
+, withRedis ? false
+, mysql
+, withMysql ? false
+, json_c
+, withJson ? false
+, libyubikey
+, withYubikey ? false
+, collectd
+, withCollectd ? false
+}:
+
+assert withSqlite -> sqlite != null;
+assert withLdap -> openldap != null;
+assert withPcap -> libpcap != null;
+assert withCap -> libcap != null;
+assert withMemcached -> libmemcached != null;
+assert withRedis -> hiredis != null;
+assert withMysql -> mysql != null;
+assert withYubikey -> libyubikey != null;
+assert withCollectd -> collectd != null;
+
+## TODO: include windbind optionally (via samba?)
+## TODO: include oracle optionally
+## TODO: include ykclient optionally
+
+with stdenv.lib;
+stdenv.mkDerivation rec {
+  name = "freeradius-${version}";
+  version = "3.0.17";
+
+  src = fetchurl {
+    url = "ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-${version}.tar.gz";
+    sha256 = "0bc35knv46z729l4h22rirqns5v6jb0fzcffnjayhs8wjysfkfyy";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  buildInputs = [ openssl talloc finger_bsd perl ]
+    ++ optional withLdap openldap
+    ++ optional withSqlite sqlite
+    ++ optional withPcap libpcap
+    ++ optional withCap libcap
+    ++ optional withMemcached libmemcached
+    ++ optional withRedis hiredis
+    ++ optional withMysql mysql.connector-c
+    ++ optional withJson json_c
+    ++ optional withYubikey libyubikey
+    ++ optional withCollectd collectd;
+
+  configureFlags = [
+     "--sysconfdir=/etc"
+     "--localstatedir=/var"
+  ] ++ optional (!linkOpenssl) "--with-openssl=no";
+
+  postPatch = ''
+    substituteInPlace src/main/checkrad.in --replace "/usr/bin/finger" "${finger_bsd}/bin/finger"
+  '';
+
+  installFlags = [
+    "sysconfdir=\${out}/etc"
+    "localstatedir=\${TMPDIR}"
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://freeradius.org/;
+    description = "A modular, high performance free RADIUS suite";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ sheenobu willibutz ];
+    platforms = with platforms; linux;
+  };
+
+}
+
diff --git a/pkgs/servers/ftp/bftpd/default.nix b/pkgs/servers/ftp/bftpd/default.nix
new file mode 100644
index 000000000000..c35177e6aa90
--- /dev/null
+++ b/pkgs/servers/ftp/bftpd/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchurl }:
+
+let
+  pname = "bftpd";
+
+in stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  version = "4.9";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/${pname}/${pname}/${name}/${name}.tar.gz";
+    sha256 = "13pjil9cjggpi773m0516lszyqvwzlgcrmmj8yn9nc24rbxwvn6d";
+  };
+
+  preConfigure = ''
+    sed -re 's/-[og] 0//g' -i Makefile*
+  '';
+
+  postInstall = ''
+    mkdir -p $out/share/doc/${pname}
+    mv $out/etc/*.conf $out/share/doc/${pname}
+    rm -rf $out/{etc,var}
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    inherit version;
+    description = "A minimal ftp server";
+    downloadPage = "http://bftpd.sf.net/download.html";
+    homepage = http://bftpd.sf.net/;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/ftp/pure-ftpd/default.nix b/pkgs/servers/ftp/pure-ftpd/default.nix
new file mode 100644
index 000000000000..f41bb726a28c
--- /dev/null
+++ b/pkgs/servers/ftp/pure-ftpd/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, openssl }:
+
+stdenv.mkDerivation rec {
+  name = "pure-ftpd-1.0.47";
+
+  src = fetchurl {
+    url = "https://download.pureftpd.org/pub/pure-ftpd/releases/${name}.tar.gz";
+    sha256 = "1b97ixva8m10vln8xrfwwwzi344bkgxqji26d0nrm1yzylbc6h27";
+  };
+
+  buildInputs = [ openssl ];
+
+  configureFlags = [ "--with-tls" ];
+
+  meta = with stdenv.lib; {
+    description = "A free, secure, production-quality and standard-conformant FTP server";
+    homepage = https://www.pureftpd.org;
+    license = licenses.isc; # with some parts covered by BSD3(?)
+    maintainers = [ maintainers.lethalman ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/ftp/vsftpd/default.nix b/pkgs/servers/ftp/vsftpd/default.nix
index 17c41a9a4d46..2386acf1b79a 100644
--- a/pkgs/servers/ftp/vsftpd/default.nix
+++ b/pkgs/servers/ftp/vsftpd/default.nix
@@ -43,4 +43,8 @@ stdenv.mkDerivation rec {
     mkdir -pv $out/etc/xinetd.d
     install -v -m 644 xinetd.d/vsftpd $out/etc/xinetd.d/vsftpd
   '';
+
+  meta = {
+    platforms = stdenv.lib.platforms.linux;
+  };
 }
diff --git a/pkgs/servers/games/ghost-one/default.nix b/pkgs/servers/games/ghost-one/default.nix
deleted file mode 100644
index 3c1430157d02..000000000000
--- a/pkgs/servers/games/ghost-one/default.nix
+++ /dev/null
@@ -1,53 +0,0 @@
-{ stdenv, fetchurl, unzip, gmp, zlib, bzip2, boost, mysql }:
-stdenv.mkDerivation rec {
-
-  name = "ghost-one-${version}";
-  version = "1.7.265";
-
-  src = fetchurl {
-    url = "http://www.maxdevlon.com/ghost/ghostone${version}.zip";
-    sha256 = "1sm2ca3lcdr4vjg7v94d8zhqz8cdp44rg8yinzzwkgsr0hj74fv2";
-  };
-
-  buildInputs = [ unzip gmp zlib bzip2 boost mysql.lib ];
-
-  patchPhase = ''
-    substituteInPlace ghost/Makefile --replace "/usr/local/lib/mysql" "${mysql.lib}/lib/mysql"
-  '';
-
-  buildPhase = ''
-    cd bncsutil/src/bncsutil
-    make
-    cd ../../../StormLib/stormlib/
-    make
-    mkdir -p $out/lib
-    cd ../..
-#    cp bncsutil/src/bncsutil/libbncutil.so $out/lib
-#    cp StormLib/stormlib/libStorm.so $out/lib
-    cd ghost
-    make
-    cd ..
-  '';
-
-  installPhase = ''
-    mkdir -p $out/lib
-    cp bncsutil/src/bncsutil/libbncsutil.so $out/lib
-    cp StormLib/stormlib/libStorm.so $out/lib
-
-    mkdir -p $out/bin
-    cp ghost/ghost++ $out/bin
-
-    mkdir -p $out/share/ghost-one/languages
-    cp -r mapcfgs $out/share/ghost-one
-    cp Languages/*.cfg $out/share/ghost-one/languages
-    cp language.cfg $out/share/ghost-one/languages/English.cfg
-    cp ip-to-country.csv $out/share/ghost-one/
-  '';
-
-  meta = with stdenv.lib; {
-    homepage = http://www.codelain.com/forum/;
-    description = "A Warcraft III: Reign of Chaos and Warcraft III: The Frozen Throne game hosting bot";
-    license = licenses.asl20;
-    maintainers = [ maintainers.phreedom ];
-  };
-}
diff --git a/pkgs/servers/gopher/gofish/default.nix b/pkgs/servers/gopher/gofish/default.nix
new file mode 100644
index 000000000000..754cba588258
--- /dev/null
+++ b/pkgs/servers/gopher/gofish/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+
+  name = "gofish-${version}";
+  version = "1.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/gofish/gofish/${version}/${name}.tar.gz";
+    sha256 = "0br5nvlna86k4ya4q13gz0i7nlmk225lqmpfiqlkldxkr473kf0s";
+  };
+  	
+  meta = with stdenv.lib; {
+    description = "A lightweight Gopher server";
+    homepage = http://gofish.sourceforge.net/;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.AndersonTorres ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/gotty/default.nix b/pkgs/servers/gotty/default.nix
new file mode 100644
index 000000000000..89f1821981fc
--- /dev/null
+++ b/pkgs/servers/gotty/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "gotty-${version}";
+  version = "0.0.13";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/yudai/gotty";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "yudai";
+    repo = "gotty";
+    sha256 = "1hsfjyjjzr1zc9m8bnhid1ag6ipcbx59111y9p7k8az8jiyr112g";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Share your terminal as a web application";
+    homepage = https://github.com/yudai/gotty;
+    maintainers = with maintainers; [ ];
+    license = licenses.mit;
+  };
+}
diff --git a/pkgs/servers/gotty/deps.nix b/pkgs/servers/gotty/deps.nix
new file mode 100644
index 000000000000..4f59dc414c49
--- /dev/null
+++ b/pkgs/servers/gotty/deps.nix
@@ -0,0 +1,74 @@
+[
+  {
+    goPackagePath = "github.com/gorilla/websocket";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/websocket";
+      rev = "a622679ebd7a3b813862379232f645f8e690e43f";
+      sha256 = "1nc9jbcmgya1i6dmf6sbcqsnxi9hbjg6dz1z0k7zmc6xdwlq0y4q";
+    };
+  }
+  {
+    goPackagePath = "github.com/kr/pty";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kr/pty";
+      rev = "67e2db24c831afa6c64fc17b4a143390674365ef";
+      sha256 = "1l3z3wbb112ar9br44m8g838z0pq2gfxcp5s3ka0xvm1hjvanw2d";
+    };
+  }
+  {
+    goPackagePath = "github.com/braintree/manners";
+    fetch = {
+      type = "git";
+      url = "https://github.com/braintree/manners";
+      rev = "cab36f97339b1925cd89e158632728025557e550";
+      sha256 = "1q508c62iiklghkhwqz9c0zsn9hrij7kqb93gdywzj7ms7x6hlfh";
+    };
+  }
+  {
+    goPackagePath = "github.com/codegangsta/cli";
+    fetch = {
+      type = "git";
+      url = "https://github.com/codegangsta/cli";
+      rev = "71f57d300dd6a780ac1856c005c4b518cfd498ec";
+      sha256 = "1fxznirkvank5461789dm5aw5z8aqi0jvwligvz44659rfl376p3";
+    };
+  }
+  {
+    goPackagePath = "github.com/elazarl/go-bindata-assetfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/elazarl/go-bindata-assetfs";
+      rev = "d5cac425555ca5cf00694df246e04f05e6a55150";
+      sha256 = "636ce247ff6f85c14f38a421f46662fa77bdc29762692e1f72b3cd1f9d7a1d17";
+    };
+  }
+  {
+    goPackagePath = "github.com/fatih/structs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/fatih/structs";
+      rev = "a9f7daa9c2729e97450c2da2feda19130a367d8f";
+      sha256 = "0pyrc7svc826g37al3db19n5l4r2m9h1mlhjh3hz2r41xfaqia50";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/hcl";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/hcl";
+      rev = "54864211433d45cb780682431585b3e573b49e4a";
+      sha256 = "07l2dydzjpdgm2d4a72hkmincn455j3nrafg6hs3c23bkvizj950";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/go-multierror";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/go-multierror";
+      rev = "56912fb08d85084aa318edcf2bba735b97cf35c5";
+      sha256 = "0s01cqdab2f7fxkkjjk2wqx05a1shnwlvfn45h2pi3i4gapvcn0r";
+    };
+  }
+]
diff --git a/pkgs/servers/gpm/default.nix b/pkgs/servers/gpm/default.nix
index a9fac485f905..3cb0d3931db3 100644
--- a/pkgs/servers/gpm/default.nix
+++ b/pkgs/servers/gpm/default.nix
@@ -8,13 +8,20 @@ stdenv.mkDerivation rec {
   name = "gpm-1.20.7";
 
   src = fetchurl {
-    url = "http://www.nico.schottelius.org/software/gpm/archives/${name}.tar.bz2";
+    url = "https://www.nico.schottelius.org/software/gpm/archives/${name}.tar.bz2";
     sha256 = "13d426a8h403ckpc8zyf7s2p5rql0lqbg2bv0454x0pvgbfbf4gh";
   };
 
+  postPatch = ''
+    sed '1i#include <sys/types.h>' -i src/daemon/open_console.c
+    substituteInPlace src/prog/gpm-root.y --replace __sigemptyset sigemptyset
+  '';
+
   nativeBuildInputs = [ automake autoconf libtool flex bison texinfo ];
   buildInputs = [ ncurses ];
 
+  hardeningDisable = [ "format" ];
+
   preConfigure = ''
     ./autogen.sh
   '';
@@ -31,10 +38,10 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = http://www.nico.schottelius.org/software/gpm/;
+    homepage = https://www.nico.schottelius.org/software/gpm/;
     description = "A daemon that provides mouse support on the Linux console";
     license = licenses.gpl2;
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ platforms.cygwin;
     maintainers = with maintainers; [ eelco wkennington ];
   };
 }
diff --git a/pkgs/servers/gpsd/0001-Import-LD_LIBRARY_PATH-to-allow-running-scons-check-.patch b/pkgs/servers/gpsd/0001-Import-LD_LIBRARY_PATH-to-allow-running-scons-check-.patch
index 3a38340f43a3..a8721a3e7029 100644
--- a/pkgs/servers/gpsd/0001-Import-LD_LIBRARY_PATH-to-allow-running-scons-check-.patch
+++ b/pkgs/servers/gpsd/0001-Import-LD_LIBRARY_PATH-to-allow-running-scons-check-.patch
@@ -1,4 +1,4 @@
-From d7e56abcae8bcb85dc935e94418a2f0e9956941b Mon Sep 17 00:00:00 2001
+From e08583ddb8445241c38c88d828271be908d52f9f Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
 Date: Mon, 17 Feb 2014 20:52:50 +0000
 Subject: [PATCH 1/2] Import LD_LIBRARY_PATH to allow running 'scons check'
@@ -9,17 +9,17 @@ Subject: [PATCH 1/2] Import LD_LIBRARY_PATH to allow running 'scons check'
  1 file changed, 1 insertion(+)
 
 diff --git a/SConstruct b/SConstruct
-index 14e2f59..86b94bc 100644
+index fe444a2..f73c87e 100644
 --- a/SConstruct
 +++ b/SConstruct
-@@ -215,6 +215,7 @@ import_env = (
-     'PKG_CONFIG_LIBDIR',      # Pass more environment variables to pkg-config (required for crossbuilds)
+@@ -220,6 +220,7 @@ import_env = (
      'STAGING_DIR',     # Required by the OpenWRT and CeroWrt builds.
      'STAGING_PREFIX',  # Required by the OpenWRT and CeroWrt builds.
+     'WRITE_PAD',       # So we can test WRITE_PAD values on the fly.
 +    'LD_LIBRARY_PATH', # Allows running 'scons check' without 'chrpath'
      )
  envs = {}
  for var in import_env:
 -- 
-1.9.0
+2.9.0
 
diff --git a/pkgs/servers/gpsd/0001-Use-pkgconfig-for-dbus-library.patch b/pkgs/servers/gpsd/0001-Use-pkgconfig-for-dbus-library.patch
new file mode 100644
index 000000000000..58ae754ecfb5
--- /dev/null
+++ b/pkgs/servers/gpsd/0001-Use-pkgconfig-for-dbus-library.patch
@@ -0,0 +1,31 @@
+From b4ed6e9e89e3b7d57e5de9f2c1987a489bb5628c Mon Sep 17 00:00:00 2001
+From: Alexey Shmalko <rasen.dubi@gmail.com>
+Date: Sat, 9 Jul 2016 20:54:05 +0300
+Subject: [PATCH] Use pkgconfig for dbus library
+
+Without this, gcc can't find library path for the dbus.
+
+This is already fixed upstream, so the patch shouldn't be necessary with
+the next version of gpsd.
+---
+ SConstruct | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/SConstruct b/SConstruct
+index 0d4b29d..d8624b0 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -586,8 +586,8 @@ else:
+ 
+     if env['dbus_export'] and config.CheckPKG('dbus-1'):
+         confdefs.append("#define HAVE_DBUS 1\n")
+-        dbusflags = ["-ldbus-1"]
+-        env.MergeFlags(pkg_config("dbus-1"))
++        dbusflags = pkg_config("dbus-1")
++        env.MergeFlags(dbusflags)
+     else:
+         confdefs.append("/* #undef HAVE_DBUS */\n")
+         dbusflags = []
+-- 
+2.9.0
+
diff --git a/pkgs/servers/gpsd/0002-Import-XML_CATALOG_FILES-to-be-able-to-validate-the-.patch b/pkgs/servers/gpsd/0002-Import-XML_CATALOG_FILES-to-be-able-to-validate-the-.patch
index f12d7a52ba0c..3e387167d6fb 100644
--- a/pkgs/servers/gpsd/0002-Import-XML_CATALOG_FILES-to-be-able-to-validate-the-.patch
+++ b/pkgs/servers/gpsd/0002-Import-XML_CATALOG_FILES-to-be-able-to-validate-the-.patch
@@ -1,4 +1,4 @@
-From aed93b6ada5b9b76b85d11d9bad732ca005295af Mon Sep 17 00:00:00 2001
+From 21e5295a633c8c450629106c4603b78b2de7d786 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
 Date: Sat, 15 Mar 2014 15:08:01 +0100
 Subject: [PATCH 2/2] Import XML_CATALOG_FILES to be able to validate the
@@ -12,17 +12,17 @@ download DTD's and builders don't have network access...
  1 file changed, 1 insertion(+)
 
 diff --git a/SConstruct b/SConstruct
-index 86b94bc..a0b3d25 100644
+index f73c87e..0d4b29d 100644
 --- a/SConstruct
 +++ b/SConstruct
-@@ -216,6 +216,7 @@ import_env = (
-     'STAGING_DIR',     # Required by the OpenWRT and CeroWrt builds.
+@@ -221,6 +221,7 @@ import_env = (
      'STAGING_PREFIX',  # Required by the OpenWRT and CeroWrt builds.
+     'WRITE_PAD',       # So we can test WRITE_PAD values on the fly.
      'LD_LIBRARY_PATH', # Allows running 'scons check' without 'chrpath'
 +    'XML_CATALOG_FILES', # Enables validating the manual with 'xmlto' using nix build system
      )
  envs = {}
  for var in import_env:
 -- 
-1.9.0
+2.9.0
 
diff --git a/pkgs/servers/gpsd/default.nix b/pkgs/servers/gpsd/default.nix
index 17325ccb2914..b01e94187898 100644
--- a/pkgs/servers/gpsd/default.nix
+++ b/pkgs/servers/gpsd/default.nix
@@ -1,50 +1,54 @@
-{ fetchurl, stdenv, scons, pythonFull, pkgconfig, dbus, dbus_glib
-, ncurses, libX11, libXt, libXpm, libXaw, libXext, makeWrapper
+{ fetchurl, stdenv, scons, pkgconfig, dbus, dbus-glib
+, ncurses, libX11, libXt, libXpm, libXaw, libXext
 , libusb1, docbook_xml_dtd_412, docbook_xsl, bc
 , libxslt, xmlto, gpsdUser ? "gpsd", gpsdGroup ? "dialout"
+, python2Packages
 }:
 
-# TODO: the 'xgps' program doesn't work: "ImportError: No module named gobject"
 # TODO: put the X11 deps behind a guiSupport parameter for headless support
 
 stdenv.mkDerivation rec {
-  name = "gpsd-3.10";
+  name = "gpsd-3.16";
 
   src = fetchurl {
     url = "http://download-mirror.savannah.gnu.org/releases/gpsd/${name}.tar.gz";
-    sha256 = "0823hl5zgwnbgm0fq3i4z34lv76cpj0k6m0zjiygiyrxrz0w4vvh";
+    sha256 = "0a90ph4qrlz5kkcz2mwkfk3cmwy9fmglp94znz2y0gsd7bqrlmq3";
   };
 
   nativeBuildInputs = [
-    scons makeWrapper pkgconfig docbook_xml_dtd_412 docbook_xsl xmlto bc
-    pythonFull
+    scons pkgconfig docbook_xml_dtd_412 docbook_xsl xmlto bc
+    python2Packages.python
+    python2Packages.wrapPython
   ];
 
   buildInputs = [
-    pythonFull dbus dbus_glib ncurses libX11 libXt libXpm libXaw libXext
+    python2Packages.python dbus dbus-glib ncurses libX11 libXt libXpm libXaw libXext
     libxslt libusb1
   ];
 
+  pythonPath = [
+    python2Packages.pygobject2
+    python2Packages.pygtk
+  ];
+
   patches = [
     ./0001-Import-LD_LIBRARY_PATH-to-allow-running-scons-check-.patch
     ./0002-Import-XML_CATALOG_FILES-to-be-able-to-validate-the-.patch
+
+    # TODO: remove the patch with the next release
+    ./0001-Use-pkgconfig-for-dbus-library.patch
   ];
 
   # - leapfetch=no disables going online at build time to fetch leap-seconds
   #   info. See <gpsd-src>/build.txt for more info.
-  # - chrpath=no stops the build from using 'chrpath' (which we don't have).
-  #   'chrpath' is used to be able to run the tests from the source tree, but
-  #   we use $LD_LIBRARY_PATH instead.
   buildPhase = ''
     patchShebangs .
-    mkdir -p "$out"
-    sed -e "s|python_lib_dir = .*|python_lib_dir = \"$out/lib/${pythonFull.libPrefix}/site-packages\"|" -i SConstruct
+    sed -e "s|systemd_dir = .*|systemd_dir = '$out/lib/systemd/system'|" -i SConstruct
     scons prefix="$out" leapfetch=no gpsd_user=${gpsdUser} gpsd_group=${gpsdGroup} \
-        systemd=yes udevdir="$out/lib/udev" chrpath=no
+        systemd=yes udevdir="$out/lib/udev" \
+        python_libdir="$out/lib/${python2Packages.python.libPrefix}/site-packages"
   '';
 
-  doCheck = false;
-
   checkPhase = ''
     export LD_LIBRARY_PATH="$PWD"
     scons check
@@ -52,12 +56,13 @@ stdenv.mkDerivation rec {
 
   # TODO: the udev rules file and the hotplug script need fixes to work on NixOS
   installPhase = ''
-    scons install
     mkdir -p "$out/lib/udev/rules.d"
-    scons udev-install
+    scons install udev-install
   '';
 
-  postInstall = "wrapPythonPrograms";
+  postFixup = ''
+    wrapPythonProgramsIn $out/bin "$out $pythonPath"
+  '';
 
   meta = with stdenv.lib; {
     description = "GPS service daemon";
@@ -82,6 +87,6 @@ stdenv.mkDerivation rec {
     homepage = http://catb.org/gpsd/;
     license = "BSD-style";
     platforms = platforms.linux;
-    maintainers = [ maintainers.bjornfor ];
+    maintainers = with maintainers; [ bjornfor rasendubi ];
   };
 }
diff --git a/pkgs/servers/h2/default.nix b/pkgs/servers/h2/default.nix
new file mode 100644
index 000000000000..a5dbf74947e2
--- /dev/null
+++ b/pkgs/servers/h2/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchzip, jre, makeWrapper, unzip }:
+stdenv.mkDerivation rec {
+  name = "h2-${version}";
+
+  version = "1.4.193";
+
+  src = fetchzip {
+    url = "http://www.h2database.com/h2-2016-10-31.zip";
+    sha256 = "1da1qcfwi5gvh68i6w6y0qpcqp3rbgakizagkajmjxk2ryc4b3z9";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  installPhase =
+    let
+      h2ToolScript = ''
+        #!/usr/bin/env bash
+        dir=$(dirname "$0")
+
+        if [ -n "$1" ]; then
+          ${jre}/bin/java -cp "$dir/h2-${version}.jar:$H2DRIVERS:$CLASSPATH" $1 "''${@:2}"
+        else
+          echo "You have to provide the full java class path for the h2 tool you want to run. E.g. 'org.h2.tools.Server'"
+        fi
+      '';
+    in ''
+      mkdir -p $out
+      cp -R * $out
+
+      echo '${h2ToolScript}' > $out/bin/h2tool.sh
+
+      substituteInPlace $out/bin/h2.sh --replace "java" "${jre}/bin/java"
+
+      chmod +x $out/bin/*.sh
+    '';
+
+  meta = with stdenv.lib; {
+    description = "The Java SQL database";
+    homepage = http://www.h2database.com/html/main.html;
+    license = licenses.mpl20;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with maintainers; [ mahe ];
+  };
+}
diff --git a/pkgs/servers/hbase/default.nix b/pkgs/servers/hbase/default.nix
index 408022f650f4..dcd81fa44b05 100644
--- a/pkgs/servers/hbase/default.nix
+++ b/pkgs/servers/hbase/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, jre, makeWrapper }:
 stdenv.mkDerivation rec {
   name = "hbase-${version}";
-  version = "0.98.13";
+  version = "0.98.24";
 
   src = fetchurl {
     url = "mirror://apache/hbase/${version}/hbase-${version}-hadoop2-bin.tar.gz";
-    sha256 = "1av81nnnwivxf5ha6x9qrr2afl5sbyskl07prv0rdac954xmgg8n";
+    sha256 = "0kz72wqsii09v9hxkw10mzyvjhji5sx3l6aijjalgbybavpcxglb";
   };
 
   buildInputs = [ makeWrapper ];
diff --git a/pkgs/servers/hitch/default.nix b/pkgs/servers/hitch/default.nix
new file mode 100644
index 000000000000..366934829b86
--- /dev/null
+++ b/pkgs/servers/hitch/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, docutils, libev, openssl, pkgconfig }:
+stdenv.mkDerivation rec {
+  version = "1.4.8";
+  name = "hitch-${version}";
+
+  src = fetchurl {
+    url = "https://hitch-tls.org/source/${name}.tar.gz";
+    sha256 = "1hqs5p69gr1lb3xldbrgq7d6d0vk4za0wpizlzybn98cv68acaym";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ docutils libev openssl ];
+
+  outputs = [ "out" "doc" "man" ];
+
+  meta = with stdenv.lib; {
+    description = "Hitch is a libev-based high performance SSL/TLS proxy by Varnish Software";
+    homepage = https://hitch-tls.org/;
+    license = licenses.bsd2;
+    maintainers = [ maintainers.jflanglois ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/home-assistant/appdaemon.nix b/pkgs/servers/home-assistant/appdaemon.nix
new file mode 100644
index 000000000000..493131795034
--- /dev/null
+++ b/pkgs/servers/home-assistant/appdaemon.nix
@@ -0,0 +1,57 @@
+{ lib, python3, fetchpatch }:
+
+let
+  python = python3.override {
+    packageOverrides = self: super: {
+
+      aiohttp = super.aiohttp.overridePythonAttrs (oldAttrs: rec {
+        version = "2.3.10";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "8adda6583ba438a4c70693374e10b60168663ffa6564c5c75d3c7a9055290964";
+        };
+      });
+
+      yarl = super.yarl.overridePythonAttrs (oldAttrs: rec {
+        version = "1.1.0";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "6af895b45bd49254cc309ac0fe6e1595636a024953d710e01114257736184698";
+        };
+      });
+
+      aiohttp-jinja2 = super.aiohttp-jinja2.overridePythonAttrs (oldAttrs: rec {
+        version = "0.15.0";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "0f390693f46173d8ffb95669acbb0e2a3ec54ecce676703510ad47f1a6d9dc83";
+        };
+      });
+
+    };
+  };
+
+in python.pkgs.buildPythonApplication rec {
+  pname = "appdaemon";
+  version = "3.0.1";
+
+  src = python.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "ad16773da21e34e258970bf5740d1634a36c8202ac72c6925d960308ef1c58cf";
+  };
+
+  propagatedBuildInputs = with python.pkgs; [
+    aiohttp aiohttp-jinja2 astral bcrypt daemonize feedparser iso8601
+    jinja2 pyyaml requests sseclient voluptuous websocket_client yarl
+  ];
+
+  # no tests implemented
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Sandboxed python execution environment for writing automation apps for Home Assistant";
+    homepage = https://github.com/home-assistant/appdaemon;
+    license = licenses.mit;
+    maintainers = with maintainers; [ peterhoeg dotlambda ];
+  };
+}
diff --git a/pkgs/servers/home-assistant/component-packages.nix b/pkgs/servers/home-assistant/component-packages.nix
new file mode 100644
index 000000000000..e2acee87d1ab
--- /dev/null
+++ b/pkgs/servers/home-assistant/component-packages.nix
@@ -0,0 +1,1173 @@
+# Generated by parse-requirements.py
+# Do not edit!
+
+{
+  version = "0.69.1";
+  components = {
+    "abode" = ps: with ps; [  ];
+    "ads" = ps: with ps; [  ];
+    "alarm_control_panel" = ps: with ps; [  ];
+    "alarm_control_panel.abode" = ps: with ps; [  ];
+    "alarm_control_panel.alarmdecoder" = ps: with ps; [  ];
+    "alarm_control_panel.alarmdotcom" = ps: with ps; [  ];
+    "alarm_control_panel.arlo" = ps: with ps; [  ];
+    "alarm_control_panel.canary" = ps: with ps; [  ];
+    "alarm_control_panel.concord232" = ps: with ps; [  ];
+    "alarm_control_panel.demo" = ps: with ps; [  ];
+    "alarm_control_panel.egardia" = ps: with ps; [  ];
+    "alarm_control_panel.envisalink" = ps: with ps; [  ];
+    "alarm_control_panel.ialarm" = ps: with ps; [  ];
+    "alarm_control_panel.ifttt" = ps: with ps; [  ];
+    "alarm_control_panel.manual" = ps: with ps; [  ];
+    "alarm_control_panel.manual_mqtt" = ps: with ps; [ paho-mqtt ];
+    "alarm_control_panel.mqtt" = ps: with ps; [ paho-mqtt ];
+    "alarm_control_panel.nx584" = ps: with ps; [  ];
+    "alarm_control_panel.satel_integra" = ps: with ps; [  ];
+    "alarm_control_panel.simplisafe" = ps: with ps; [  ];
+    "alarm_control_panel.spc" = ps: with ps; [  ];
+    "alarm_control_panel.totalconnect" = ps: with ps; [  ];
+    "alarm_control_panel.verisure" = ps: with ps; [  ];
+    "alarm_control_panel.wink" = ps: with ps; [  ];
+    "alarmdecoder" = ps: with ps; [  ];
+    "alert" = ps: with ps; [  ];
+    "alexa" = ps: with ps; [ aiohttp-cors ];
+    "alexa.const" = ps: with ps; [  ];
+    "alexa.flash_briefings" = ps: with ps; [  ];
+    "alexa.intent" = ps: with ps; [  ];
+    "alexa.smart_home" = ps: with ps; [  ];
+    "amcrest" = ps: with ps; [ ha-ffmpeg ];
+    "android_ip_webcam" = ps: with ps; [  ];
+    "apcupsd" = ps: with ps; [  ];
+    "api" = ps: with ps; [ aiohttp-cors ];
+    "apple_tv" = ps: with ps; [  ];
+    "arduino" = ps: with ps; [  ];
+    "arlo" = ps: with ps; [  ];
+    "asterisk_mbox" = ps: with ps; [  ];
+    "august" = ps: with ps; [  ];
+    "auth" = ps: with ps; [ aiohttp-cors ];
+    "auth.client" = ps: with ps; [  ];
+    "automation" = ps: with ps; [  ];
+    "automation.event" = ps: with ps; [  ];
+    "automation.homeassistant" = ps: with ps; [  ];
+    "automation.litejet" = ps: with ps; [  ];
+    "automation.mqtt" = ps: with ps; [ paho-mqtt ];
+    "automation.numeric_state" = ps: with ps; [  ];
+    "automation.state" = ps: with ps; [  ];
+    "automation.sun" = ps: with ps; [  ];
+    "automation.template" = ps: with ps; [  ];
+    "automation.time" = ps: with ps; [  ];
+    "automation.zone" = ps: with ps; [  ];
+    "axis" = ps: with ps; [  ];
+    "bbb_gpio" = ps: with ps; [  ];
+    "binary_sensor" = ps: with ps; [  ];
+    "binary_sensor.abode" = ps: with ps; [  ];
+    "binary_sensor.ads" = ps: with ps; [  ];
+    "binary_sensor.alarmdecoder" = ps: with ps; [  ];
+    "binary_sensor.android_ip_webcam" = ps: with ps; [  ];
+    "binary_sensor.apcupsd" = ps: with ps; [  ];
+    "binary_sensor.arest" = ps: with ps; [  ];
+    "binary_sensor.august" = ps: with ps; [  ];
+    "binary_sensor.aurora" = ps: with ps; [  ];
+    "binary_sensor.axis" = ps: with ps; [  ];
+    "binary_sensor.bayesian" = ps: with ps; [  ];
+    "binary_sensor.bbb_gpio" = ps: with ps; [  ];
+    "binary_sensor.blink" = ps: with ps; [  ];
+    "binary_sensor.bloomsky" = ps: with ps; [  ];
+    "binary_sensor.bmw_connected_drive" = ps: with ps; [  ];
+    "binary_sensor.command_line" = ps: with ps; [  ];
+    "binary_sensor.concord232" = ps: with ps; [  ];
+    "binary_sensor.deconz" = ps: with ps; [  ];
+    "binary_sensor.demo" = ps: with ps; [  ];
+    "binary_sensor.digital_ocean" = ps: with ps; [ digital-ocean ];
+    "binary_sensor.ecobee" = ps: with ps; [  ];
+    "binary_sensor.egardia" = ps: with ps; [  ];
+    "binary_sensor.eight_sleep" = ps: with ps; [  ];
+    "binary_sensor.enocean" = ps: with ps; [  ];
+    "binary_sensor.envisalink" = ps: with ps; [  ];
+    "binary_sensor.ffmpeg_motion" = ps: with ps; [ ha-ffmpeg ];
+    "binary_sensor.ffmpeg_noise" = ps: with ps; [ ha-ffmpeg ];
+    "binary_sensor.flic" = ps: with ps; [  ];
+    "binary_sensor.gc100" = ps: with ps; [  ];
+    "binary_sensor.hikvision" = ps: with ps; [  ];
+    "binary_sensor.hive" = ps: with ps; [  ];
+    "binary_sensor.homematic" = ps: with ps; [ pyhomematic ];
+    "binary_sensor.ihc" = ps: with ps; [  ];
+    "binary_sensor.insteon_plm" = ps: with ps; [  ];
+    "binary_sensor.iss" = ps: with ps; [  ];
+    "binary_sensor.isy994" = ps: with ps; [  ];
+    "binary_sensor.knx" = ps: with ps; [  ];
+    "binary_sensor.linode" = ps: with ps; [ linode-api ];
+    "binary_sensor.maxcube" = ps: with ps; [  ];
+    "binary_sensor.modbus" = ps: with ps; [  ];
+    "binary_sensor.mqtt" = ps: with ps; [ paho-mqtt ];
+    "binary_sensor.mychevy" = ps: with ps; [  ];
+    "binary_sensor.mysensors" = ps: with ps; [  ];
+    "binary_sensor.mystrom" = ps: with ps; [ aiohttp-cors ];
+    "binary_sensor.nest" = ps: with ps; [  ];
+    "binary_sensor.netatmo" = ps: with ps; [  ];
+    "binary_sensor.nx584" = ps: with ps; [  ];
+    "binary_sensor.octoprint" = ps: with ps; [  ];
+    "binary_sensor.pilight" = ps: with ps; [  ];
+    "binary_sensor.ping" = ps: with ps; [  ];
+    "binary_sensor.qwikswitch" = ps: with ps; [  ];
+    "binary_sensor.raincloud" = ps: with ps; [  ];
+    "binary_sensor.random" = ps: with ps; [  ];
+    "binary_sensor.raspihats" = ps: with ps; [  ];
+    "binary_sensor.rest" = ps: with ps; [  ];
+    "binary_sensor.rfxtrx" = ps: with ps; [  ];
+    "binary_sensor.ring" = ps: with ps; [  ];
+    "binary_sensor.rpi_gpio" = ps: with ps; [  ];
+    "binary_sensor.rpi_pfio" = ps: with ps; [  ];
+    "binary_sensor.satel_integra" = ps: with ps; [  ];
+    "binary_sensor.skybell" = ps: with ps; [  ];
+    "binary_sensor.sleepiq" = ps: with ps; [  ];
+    "binary_sensor.spc" = ps: with ps; [  ];
+    "binary_sensor.tapsaff" = ps: with ps; [  ];
+    "binary_sensor.tcp" = ps: with ps; [  ];
+    "binary_sensor.tellduslive" = ps: with ps; [  ];
+    "binary_sensor.template" = ps: with ps; [  ];
+    "binary_sensor.tesla" = ps: with ps; [  ];
+    "binary_sensor.threshold" = ps: with ps; [  ];
+    "binary_sensor.trend" = ps: with ps; [ numpy ];
+    "binary_sensor.upcloud" = ps: with ps; [  ];
+    "binary_sensor.velbus" = ps: with ps; [  ];
+    "binary_sensor.vera" = ps: with ps; [  ];
+    "binary_sensor.verisure" = ps: with ps; [  ];
+    "binary_sensor.volvooncall" = ps: with ps; [  ];
+    "binary_sensor.vultr" = ps: with ps; [ vultr ];
+    "binary_sensor.wemo" = ps: with ps; [  ];
+    "binary_sensor.wink" = ps: with ps; [  ];
+    "binary_sensor.workday" = ps: with ps; [  ];
+    "binary_sensor.xiaomi_aqara" = ps: with ps; [  ];
+    "binary_sensor.zha" = ps: with ps; [  ];
+    "binary_sensor.zigbee" = ps: with ps; [  ];
+    "binary_sensor.zwave" = ps: with ps; [  ];
+    "blink" = ps: with ps; [  ];
+    "bloomsky" = ps: with ps; [  ];
+    "bmw_connected_drive" = ps: with ps; [  ];
+    "browser" = ps: with ps; [  ];
+    "calendar" = ps: with ps; [  ];
+    "calendar.caldav" = ps: with ps; [  ];
+    "calendar.demo" = ps: with ps; [  ];
+    "calendar.google" = ps: with ps; [  ];
+    "calendar.todoist" = ps: with ps; [ todoist ];
+    "camera" = ps: with ps; [ aiohttp-cors ];
+    "camera.abode" = ps: with ps; [  ];
+    "camera.amcrest" = ps: with ps; [ ha-ffmpeg ];
+    "camera.arlo" = ps: with ps; [ ha-ffmpeg ];
+    "camera.august" = ps: with ps; [  ];
+    "camera.axis" = ps: with ps; [  ];
+    "camera.blink" = ps: with ps; [  ];
+    "camera.bloomsky" = ps: with ps; [  ];
+    "camera.canary" = ps: with ps; [ ha-ffmpeg ];
+    "camera.demo" = ps: with ps; [  ];
+    "camera.doorbird" = ps: with ps; [  ];
+    "camera.ffmpeg" = ps: with ps; [ ha-ffmpeg ];
+    "camera.foscam" = ps: with ps; [  ];
+    "camera.generic" = ps: with ps; [  ];
+    "camera.local_file" = ps: with ps; [  ];
+    "camera.mjpeg" = ps: with ps; [  ];
+    "camera.mqtt" = ps: with ps; [ paho-mqtt ];
+    "camera.neato" = ps: with ps; [  ];
+    "camera.nest" = ps: with ps; [  ];
+    "camera.netatmo" = ps: with ps; [  ];
+    "camera.onvif" = ps: with ps; [ ha-ffmpeg ];
+    "camera.proxy" = ps: with ps; [ pillow ];
+    "camera.ring" = ps: with ps; [ ha-ffmpeg ];
+    "camera.rpi_camera" = ps: with ps; [  ];
+    "camera.skybell" = ps: with ps; [  ];
+    "camera.synology" = ps: with ps; [  ];
+    "camera.usps" = ps: with ps; [  ];
+    "camera.uvc" = ps: with ps; [  ];
+    "camera.verisure" = ps: with ps; [  ];
+    "camera.xeoma" = ps: with ps; [  ];
+    "camera.yi" = ps: with ps; [ ha-ffmpeg ];
+    "camera.zoneminder" = ps: with ps; [  ];
+    "canary" = ps: with ps; [  ];
+    "climate" = ps: with ps; [  ];
+    "climate.daikin" = ps: with ps; [  ];
+    "climate.demo" = ps: with ps; [  ];
+    "climate.ecobee" = ps: with ps; [  ];
+    "climate.econet" = ps: with ps; [  ];
+    "climate.ephember" = ps: with ps; [  ];
+    "climate.eq3btsmart" = ps: with ps; [ construct ];
+    "climate.flexit" = ps: with ps; [  ];
+    "climate.fritzbox" = ps: with ps; [  ];
+    "climate.generic_thermostat" = ps: with ps; [  ];
+    "climate.heatmiser" = ps: with ps; [  ];
+    "climate.hive" = ps: with ps; [  ];
+    "climate.homematic" = ps: with ps; [ pyhomematic ];
+    "climate.honeywell" = ps: with ps; [  ];
+    "climate.knx" = ps: with ps; [  ];
+    "climate.maxcube" = ps: with ps; [  ];
+    "climate.melissa" = ps: with ps; [  ];
+    "climate.modbus" = ps: with ps; [  ];
+    "climate.mqtt" = ps: with ps; [ paho-mqtt ];
+    "climate.mysensors" = ps: with ps; [  ];
+    "climate.nest" = ps: with ps; [  ];
+    "climate.netatmo" = ps: with ps; [  ];
+    "climate.nuheat" = ps: with ps; [  ];
+    "climate.oem" = ps: with ps; [  ];
+    "climate.proliphix" = ps: with ps; [  ];
+    "climate.radiotherm" = ps: with ps; [  ];
+    "climate.sensibo" = ps: with ps; [  ];
+    "climate.tado" = ps: with ps; [  ];
+    "climate.tesla" = ps: with ps; [  ];
+    "climate.toon" = ps: with ps; [  ];
+    "climate.touchline" = ps: with ps; [  ];
+    "climate.venstar" = ps: with ps; [  ];
+    "climate.vera" = ps: with ps; [  ];
+    "climate.wink" = ps: with ps; [  ];
+    "climate.zwave" = ps: with ps; [  ];
+    "cloud" = ps: with ps; [ aiohttp-cors warrant ];
+    "cloud.auth_api" = ps: with ps; [  ];
+    "cloud.const" = ps: with ps; [  ];
+    "cloud.http_api" = ps: with ps; [  ];
+    "cloud.iot" = ps: with ps; [  ];
+    "coinbase" = ps: with ps; [  ];
+    "comfoconnect" = ps: with ps; [  ];
+    "config" = ps: with ps; [ aiohttp-cors ];
+    "config.automation" = ps: with ps; [  ];
+    "config.config_entries" = ps: with ps; [ voluptuous-serialize ];
+    "config.core" = ps: with ps; [  ];
+    "config.customize" = ps: with ps; [  ];
+    "config.entity_registry" = ps: with ps; [  ];
+    "config.group" = ps: with ps; [  ];
+    "config.hassbian" = ps: with ps; [  ];
+    "config.script" = ps: with ps; [  ];
+    "config.zwave" = ps: with ps; [  ];
+    "configurator" = ps: with ps; [  ];
+    "conversation" = ps: with ps; [ aiohttp-cors ];
+    "counter" = ps: with ps; [  ];
+    "cover" = ps: with ps; [  ];
+    "cover.abode" = ps: with ps; [  ];
+    "cover.command_line" = ps: with ps; [  ];
+    "cover.demo" = ps: with ps; [  ];
+    "cover.garadget" = ps: with ps; [  ];
+    "cover.gogogate2" = ps: with ps; [  ];
+    "cover.group" = ps: with ps; [  ];
+    "cover.homematic" = ps: with ps; [ pyhomematic ];
+    "cover.isy994" = ps: with ps; [  ];
+    "cover.knx" = ps: with ps; [  ];
+    "cover.lutron" = ps: with ps; [  ];
+    "cover.lutron_caseta" = ps: with ps; [  ];
+    "cover.mqtt" = ps: with ps; [ paho-mqtt ];
+    "cover.myq" = ps: with ps; [  ];
+    "cover.mysensors" = ps: with ps; [  ];
+    "cover.opengarage" = ps: with ps; [  ];
+    "cover.rflink" = ps: with ps; [  ];
+    "cover.rfxtrx" = ps: with ps; [  ];
+    "cover.rpi_gpio" = ps: with ps; [  ];
+    "cover.scsgate" = ps: with ps; [  ];
+    "cover.tahoma" = ps: with ps; [  ];
+    "cover.tellduslive" = ps: with ps; [  ];
+    "cover.tellstick" = ps: with ps; [  ];
+    "cover.template" = ps: with ps; [  ];
+    "cover.velbus" = ps: with ps; [  ];
+    "cover.vera" = ps: with ps; [  ];
+    "cover.wink" = ps: with ps; [  ];
+    "cover.xiaomi_aqara" = ps: with ps; [  ];
+    "cover.zwave" = ps: with ps; [  ];
+    "daikin" = ps: with ps; [  ];
+    "datadog" = ps: with ps; [ datadog ];
+    "deconz" = ps: with ps; [  ];
+    "deconz.config_flow" = ps: with ps; [  ];
+    "deconz.const" = ps: with ps; [  ];
+    "demo" = ps: with ps; [ aiohttp-cors ];
+    "device_sun_light_trigger" = ps: with ps; [  ];
+    "device_tracker" = ps: with ps; [  ];
+    "device_tracker.actiontec" = ps: with ps; [  ];
+    "device_tracker.aruba" = ps: with ps; [ pexpect ];
+    "device_tracker.asuswrt" = ps: with ps; [ pexpect ];
+    "device_tracker.automatic" = ps: with ps; [ aiohttp-cors ];
+    "device_tracker.bbox" = ps: with ps; [  ];
+    "device_tracker.bluetooth_le_tracker" = ps: with ps; [  ];
+    "device_tracker.bluetooth_tracker" = ps: with ps; [  ];
+    "device_tracker.bmw_connected_drive" = ps: with ps; [  ];
+    "device_tracker.bt_home_hub_5" = ps: with ps; [  ];
+    "device_tracker.cisco_ios" = ps: with ps; [ pexpect ];
+    "device_tracker.ddwrt" = ps: with ps; [  ];
+    "device_tracker.demo" = ps: with ps; [  ];
+    "device_tracker.fritz" = ps: with ps; [ fritzconnection ];
+    "device_tracker.geofency" = ps: with ps; [ aiohttp-cors ];
+    "device_tracker.google_maps" = ps: with ps; [  ];
+    "device_tracker.gpslogger" = ps: with ps; [ aiohttp-cors ];
+    "device_tracker.hitron_coda" = ps: with ps; [  ];
+    "device_tracker.huawei_router" = ps: with ps; [  ];
+    "device_tracker.icloud" = ps: with ps; [  ];
+    "device_tracker.keenetic_ndms2" = ps: with ps; [  ];
+    "device_tracker.linksys_ap" = ps: with ps; [ beautifulsoup4 ];
+    "device_tracker.linksys_smart" = ps: with ps; [  ];
+    "device_tracker.locative" = ps: with ps; [ aiohttp-cors ];
+    "device_tracker.luci" = ps: with ps; [  ];
+    "device_tracker.meraki" = ps: with ps; [ aiohttp-cors ];
+    "device_tracker.mikrotik" = ps: with ps; [  ];
+    "device_tracker.mqtt" = ps: with ps; [ paho-mqtt ];
+    "device_tracker.mqtt_json" = ps: with ps; [ paho-mqtt ];
+    "device_tracker.mysensors" = ps: with ps; [  ];
+    "device_tracker.netgear" = ps: with ps; [  ];
+    "device_tracker.nmap_tracker" = ps: with ps; [  ];
+    "device_tracker.owntracks" = ps: with ps; [ libnacl paho-mqtt ];
+    "device_tracker.owntracks_http" = ps: with ps; [ aiohttp-cors libnacl ];
+    "device_tracker.ping" = ps: with ps; [  ];
+    "device_tracker.sky_hub" = ps: with ps; [  ];
+    "device_tracker.snmp" = ps: with ps; [ pysnmp ];
+    "device_tracker.swisscom" = ps: with ps; [  ];
+    "device_tracker.tado" = ps: with ps; [  ];
+    "device_tracker.tesla" = ps: with ps; [  ];
+    "device_tracker.thomson" = ps: with ps; [  ];
+    "device_tracker.tile" = ps: with ps; [  ];
+    "device_tracker.tomato" = ps: with ps; [  ];
+    "device_tracker.tplink" = ps: with ps; [  ];
+    "device_tracker.trackr" = ps: with ps; [  ];
+    "device_tracker.ubus" = ps: with ps; [  ];
+    "device_tracker.unifi" = ps: with ps; [ pyunifi ];
+    "device_tracker.unifi_direct" = ps: with ps; [ pexpect ];
+    "device_tracker.upc_connect" = ps: with ps; [ defusedxml ];
+    "device_tracker.volvooncall" = ps: with ps; [  ];
+    "device_tracker.xiaomi" = ps: with ps; [  ];
+    "device_tracker.xiaomi_miio" = ps: with ps; [ construct ];
+    "dialogflow" = ps: with ps; [ aiohttp-cors ];
+    "digital_ocean" = ps: with ps; [ digital-ocean ];
+    "discovery" = ps: with ps; [ netdisco ];
+    "dominos" = ps: with ps; [ aiohttp-cors ];
+    "doorbird" = ps: with ps; [  ];
+    "downloader" = ps: with ps; [  ];
+    "duckdns" = ps: with ps; [  ];
+    "dweet" = ps: with ps; [  ];
+    "dyson" = ps: with ps; [  ];
+    "ecobee" = ps: with ps; [  ];
+    "egardia" = ps: with ps; [  ];
+    "eight_sleep" = ps: with ps; [  ];
+    "emoncms_history" = ps: with ps; [  ];
+    "emulated_hue" = ps: with ps; [ aiohttp-cors ];
+    "emulated_hue.hue_api" = ps: with ps; [  ];
+    "emulated_hue.upnp" = ps: with ps; [  ];
+    "enocean" = ps: with ps; [  ];
+    "envisalink" = ps: with ps; [  ];
+    "eufy" = ps: with ps; [  ];
+    "fan" = ps: with ps; [  ];
+    "fan.comfoconnect" = ps: with ps; [  ];
+    "fan.demo" = ps: with ps; [  ];
+    "fan.dyson" = ps: with ps; [  ];
+    "fan.insteon_local" = ps: with ps; [  ];
+    "fan.insteon_plm" = ps: with ps; [  ];
+    "fan.isy994" = ps: with ps; [  ];
+    "fan.mqtt" = ps: with ps; [ paho-mqtt ];
+    "fan.template" = ps: with ps; [  ];
+    "fan.velbus" = ps: with ps; [  ];
+    "fan.wink" = ps: with ps; [  ];
+    "fan.xiaomi_miio" = ps: with ps; [ construct ];
+    "fan.zha" = ps: with ps; [  ];
+    "fan.zwave" = ps: with ps; [  ];
+    "feedreader" = ps: with ps; [ feedparser ];
+    "ffmpeg" = ps: with ps; [ ha-ffmpeg ];
+    "folder_watcher" = ps: with ps; [ watchdog ];
+    "foursquare" = ps: with ps; [ aiohttp-cors ];
+    "freedns" = ps: with ps; [  ];
+    "fritzbox" = ps: with ps; [  ];
+    "frontend" = ps: with ps; [ aiohttp-cors ];
+    "gc100" = ps: with ps; [  ];
+    "goalfeed" = ps: with ps; [  ];
+    "google" = ps: with ps; [ google_api_python_client oauth2client ];
+    "google_assistant" = ps: with ps; [ aiohttp-cors ];
+    "google_assistant.auth" = ps: with ps; [  ];
+    "google_assistant.const" = ps: with ps; [  ];
+    "google_assistant.helpers" = ps: with ps; [  ];
+    "google_assistant.http" = ps: with ps; [  ];
+    "google_assistant.smart_home" = ps: with ps; [  ];
+    "google_assistant.trait" = ps: with ps; [  ];
+    "google_domains" = ps: with ps; [  ];
+    "graphite" = ps: with ps; [  ];
+    "group" = ps: with ps; [  ];
+    "hassio" = ps: with ps; [ aiohttp-cors ];
+    "hassio.handler" = ps: with ps; [  ];
+    "hassio.http" = ps: with ps; [  ];
+    "hdmi_cec" = ps: with ps; [  ];
+    "history" = ps: with ps; [ aiohttp-cors sqlalchemy ];
+    "history_graph" = ps: with ps; [ aiohttp-cors sqlalchemy ];
+    "hive" = ps: with ps; [  ];
+    "homekit" = ps: with ps; [  ];
+    "homekit.const" = ps: with ps; [  ];
+    "homekit.util" = ps: with ps; [  ];
+    "homekit_controller" = ps: with ps; [  ];
+    "homematic" = ps: with ps; [ pyhomematic ];
+    "homematicip_cloud" = ps: with ps; [  ];
+    "http" = ps: with ps; [ aiohttp-cors ];
+    "http.auth" = ps: with ps; [  ];
+    "http.ban" = ps: with ps; [  ];
+    "http.const" = ps: with ps; [  ];
+    "http.cors" = ps: with ps; [  ];
+    "http.data_validator" = ps: with ps; [  ];
+    "http.real_ip" = ps: with ps; [  ];
+    "http.static" = ps: with ps; [  ];
+    "http.view" = ps: with ps; [  ];
+    "hue" = ps: with ps; [ aiohue ];
+    "hue.bridge" = ps: with ps; [  ];
+    "hue.config_flow" = ps: with ps; [  ];
+    "hue.const" = ps: with ps; [  ];
+    "hue.errors" = ps: with ps; [  ];
+    "ifttt" = ps: with ps; [  ];
+    "ihc" = ps: with ps; [  ];
+    "ihc.const" = ps: with ps; [  ];
+    "ihc.ihcdevice" = ps: with ps; [  ];
+    "image_processing" = ps: with ps; [ aiohttp-cors ];
+    "image_processing.demo" = ps: with ps; [  ];
+    "image_processing.dlib_face_detect" = ps: with ps; [ face_recognition ];
+    "image_processing.dlib_face_identify" = ps: with ps; [ face_recognition ];
+    "image_processing.microsoft_face_detect" = ps: with ps; [ aiohttp-cors ];
+    "image_processing.microsoft_face_identify" = ps: with ps; [ aiohttp-cors ];
+    "image_processing.openalpr_cloud" = ps: with ps; [  ];
+    "image_processing.openalpr_local" = ps: with ps; [  ];
+    "image_processing.opencv" = ps: with ps; [ numpy ];
+    "image_processing.seven_segments" = ps: with ps; [  ];
+    "influxdb" = ps: with ps; [ influxdb ];
+    "input_boolean" = ps: with ps; [  ];
+    "input_datetime" = ps: with ps; [  ];
+    "input_number" = ps: with ps; [  ];
+    "input_select" = ps: with ps; [  ];
+    "input_text" = ps: with ps; [  ];
+    "insteon_local" = ps: with ps; [  ];
+    "insteon_plm" = ps: with ps; [  ];
+    "intent_script" = ps: with ps; [  ];
+    "introduction" = ps: with ps; [  ];
+    "ios" = ps: with ps; [ aiohttp-cors zeroconf ];
+    "iota" = ps: with ps; [  ];
+    "isy994" = ps: with ps; [  ];
+    "joaoapps_join" = ps: with ps; [  ];
+    "juicenet" = ps: with ps; [  ];
+    "keyboard" = ps: with ps; [  ];
+    "keyboard_remote" = ps: with ps; [ evdev ];
+    "kira" = ps: with ps; [  ];
+    "knx" = ps: with ps; [  ];
+    "lametric" = ps: with ps; [  ];
+    "light" = ps: with ps; [  ];
+    "light.abode" = ps: with ps; [  ];
+    "light.ads" = ps: with ps; [  ];
+    "light.avion" = ps: with ps; [  ];
+    "light.blinksticklight" = ps: with ps; [ BlinkStick ];
+    "light.blinkt" = ps: with ps; [  ];
+    "light.deconz" = ps: with ps; [  ];
+    "light.decora" = ps: with ps; [  ];
+    "light.decora_wifi" = ps: with ps; [  ];
+    "light.demo" = ps: with ps; [  ];
+    "light.enocean" = ps: with ps; [  ];
+    "light.eufy" = ps: with ps; [  ];
+    "light.flux_led" = ps: with ps; [  ];
+    "light.greenwave" = ps: with ps; [  ];
+    "light.group" = ps: with ps; [  ];
+    "light.hive" = ps: with ps; [  ];
+    "light.homekit_controller" = ps: with ps; [  ];
+    "light.homematic" = ps: with ps; [ pyhomematic ];
+    "light.hue" = ps: with ps; [ aiohue ];
+    "light.hyperion" = ps: with ps; [  ];
+    "light.iglo" = ps: with ps; [  ];
+    "light.ihc" = ps: with ps; [  ];
+    "light.insteon_local" = ps: with ps; [  ];
+    "light.insteon_plm" = ps: with ps; [  ];
+    "light.isy994" = ps: with ps; [  ];
+    "light.knx" = ps: with ps; [  ];
+    "light.lifx" = ps: with ps; [  ];
+    "light.lifx_legacy" = ps: with ps; [  ];
+    "light.limitlessled" = ps: with ps; [  ];
+    "light.litejet" = ps: with ps; [  ];
+    "light.lutron" = ps: with ps; [  ];
+    "light.lutron_caseta" = ps: with ps; [  ];
+    "light.mochad" = ps: with ps; [  ];
+    "light.mqtt" = ps: with ps; [ paho-mqtt ];
+    "light.mqtt_json" = ps: with ps; [ paho-mqtt ];
+    "light.mqtt_template" = ps: with ps; [ paho-mqtt ];
+    "light.mysensors" = ps: with ps; [  ];
+    "light.mystrom" = ps: with ps; [  ];
+    "light.nanoleaf_aurora" = ps: with ps; [  ];
+    "light.osramlightify" = ps: with ps; [  ];
+    "light.piglow" = ps: with ps; [  ];
+    "light.qwikswitch" = ps: with ps; [  ];
+    "light.rflink" = ps: with ps; [  ];
+    "light.rfxtrx" = ps: with ps; [  ];
+    "light.rpi_gpio_pwm" = ps: with ps; [  ];
+    "light.scsgate" = ps: with ps; [  ];
+    "light.sensehat" = ps: with ps; [  ];
+    "light.skybell" = ps: with ps; [  ];
+    "light.tellduslive" = ps: with ps; [  ];
+    "light.tellstick" = ps: with ps; [  ];
+    "light.template" = ps: with ps; [  ];
+    "light.tikteck" = ps: with ps; [  ];
+    "light.tplink" = ps: with ps; [  ];
+    "light.tradfri" = ps: with ps; [  ];
+    "light.velbus" = ps: with ps; [  ];
+    "light.vera" = ps: with ps; [  ];
+    "light.wemo" = ps: with ps; [  ];
+    "light.wink" = ps: with ps; [  ];
+    "light.x10" = ps: with ps; [  ];
+    "light.xiaomi_aqara" = ps: with ps; [  ];
+    "light.xiaomi_miio" = ps: with ps; [ construct ];
+    "light.yeelight" = ps: with ps; [  ];
+    "light.yeelightsunflower" = ps: with ps; [  ];
+    "light.zengge" = ps: with ps; [  ];
+    "light.zha" = ps: with ps; [  ];
+    "light.zigbee" = ps: with ps; [  ];
+    "light.zwave" = ps: with ps; [  ];
+    "linode" = ps: with ps; [ linode-api ];
+    "lirc" = ps: with ps; [  ];
+    "litejet" = ps: with ps; [  ];
+    "lock" = ps: with ps; [  ];
+    "lock.abode" = ps: with ps; [  ];
+    "lock.august" = ps: with ps; [  ];
+    "lock.bmw_connected_drive" = ps: with ps; [  ];
+    "lock.demo" = ps: with ps; [  ];
+    "lock.homematic" = ps: with ps; [ pyhomematic ];
+    "lock.isy994" = ps: with ps; [  ];
+    "lock.lockitron" = ps: with ps; [  ];
+    "lock.mqtt" = ps: with ps; [ paho-mqtt ];
+    "lock.nello" = ps: with ps; [  ];
+    "lock.nuki" = ps: with ps; [  ];
+    "lock.sesame" = ps: with ps; [  ];
+    "lock.tesla" = ps: with ps; [  ];
+    "lock.vera" = ps: with ps; [  ];
+    "lock.verisure" = ps: with ps; [  ];
+    "lock.volvooncall" = ps: with ps; [  ];
+    "lock.wink" = ps: with ps; [  ];
+    "lock.zwave" = ps: with ps; [  ];
+    "logbook" = ps: with ps; [ aiohttp-cors sqlalchemy ];
+    "logentries" = ps: with ps; [  ];
+    "logger" = ps: with ps; [  ];
+    "lutron" = ps: with ps; [  ];
+    "lutron_caseta" = ps: with ps; [  ];
+    "mailbox" = ps: with ps; [ aiohttp-cors ];
+    "mailbox.asterisk_mbox" = ps: with ps; [  ];
+    "mailbox.demo" = ps: with ps; [  ];
+    "mailgun" = ps: with ps; [ aiohttp-cors ];
+    "map" = ps: with ps; [  ];
+    "matrix" = ps: with ps; [ matrix-client ];
+    "maxcube" = ps: with ps; [  ];
+    "media_extractor" = ps: with ps; [ aiohttp-cors youtube-dl-light ];
+    "media_player" = ps: with ps; [ aiohttp-cors ];
+    "media_player.anthemav" = ps: with ps; [  ];
+    "media_player.apple_tv" = ps: with ps; [  ];
+    "media_player.aquostv" = ps: with ps; [  ];
+    "media_player.blackbird" = ps: with ps; [  ];
+    "media_player.bluesound" = ps: with ps; [ xmltodict ];
+    "media_player.braviatv" = ps: with ps; [  ];
+    "media_player.cast" = ps: with ps; [ PyChromecast ];
+    "media_player.channels" = ps: with ps; [  ];
+    "media_player.clementine" = ps: with ps; [  ];
+    "media_player.cmus" = ps: with ps; [  ];
+    "media_player.demo" = ps: with ps; [  ];
+    "media_player.denon" = ps: with ps; [  ];
+    "media_player.denonavr" = ps: with ps; [  ];
+    "media_player.directv" = ps: with ps; [  ];
+    "media_player.dunehd" = ps: with ps; [  ];
+    "media_player.emby" = ps: with ps; [  ];
+    "media_player.firetv" = ps: with ps; [  ];
+    "media_player.frontier_silicon" = ps: with ps; [  ];
+    "media_player.gpmdp" = ps: with ps; [ websocket_client ];
+    "media_player.gstreamer" = ps: with ps; [  ];
+    "media_player.hdmi_cec" = ps: with ps; [  ];
+    "media_player.itunes" = ps: with ps; [  ];
+    "media_player.kodi" = ps: with ps; [ jsonrpc-async jsonrpc-websocket ];
+    "media_player.lg_netcast" = ps: with ps; [  ];
+    "media_player.liveboxplaytv" = ps: with ps; [  ];
+    "media_player.mediaroom" = ps: with ps; [  ];
+    "media_player.monoprice" = ps: with ps; [  ];
+    "media_player.mpchc" = ps: with ps; [  ];
+    "media_player.mpd" = ps: with ps; [ mpd2 ];
+    "media_player.nad" = ps: with ps; [  ];
+    "media_player.nadtcp" = ps: with ps; [  ];
+    "media_player.onkyo" = ps: with ps; [ onkyo-eiscp ];
+    "media_player.openhome" = ps: with ps; [  ];
+    "media_player.panasonic_viera" = ps: with ps; [ wakeonlan ];
+    "media_player.pandora" = ps: with ps; [ pexpect ];
+    "media_player.philips_js" = ps: with ps; [  ];
+    "media_player.pioneer" = ps: with ps; [  ];
+    "media_player.plex" = ps: with ps; [  ];
+    "media_player.roku" = ps: with ps; [  ];
+    "media_player.russound_rio" = ps: with ps; [  ];
+    "media_player.russound_rnet" = ps: with ps; [  ];
+    "media_player.samsungtv" = ps: with ps; [ wakeonlan ];
+    "media_player.snapcast" = ps: with ps; [  ];
+    "media_player.songpal" = ps: with ps; [  ];
+    "media_player.sonos" = ps: with ps; [  ];
+    "media_player.soundtouch" = ps: with ps; [ libsoundtouch ];
+    "media_player.spotify" = ps: with ps; [ aiohttp-cors spotipy ];
+    "media_player.squeezebox" = ps: with ps; [  ];
+    "media_player.ue_smart_radio" = ps: with ps; [  ];
+    "media_player.universal" = ps: with ps; [  ];
+    "media_player.vizio" = ps: with ps; [  ];
+    "media_player.vlc" = ps: with ps; [  ];
+    "media_player.volumio" = ps: with ps; [  ];
+    "media_player.webostv" = ps: with ps; [ websockets ];
+    "media_player.xiaomi_tv" = ps: with ps; [  ];
+    "media_player.yamaha" = ps: with ps; [  ];
+    "media_player.yamaha_musiccast" = ps: with ps; [  ];
+    "media_player.ziggo_mediabox_xl" = ps: with ps; [  ];
+    "melissa" = ps: with ps; [  ];
+    "microsoft_face" = ps: with ps; [ aiohttp-cors ];
+    "mochad" = ps: with ps; [  ];
+    "modbus" = ps: with ps; [  ];
+    "mqtt" = ps: with ps; [ paho-mqtt ];
+    "mqtt.discovery" = ps: with ps; [  ];
+    "mqtt.server" = ps: with ps; [ aiohttp-cors hbmqtt ];
+    "mqtt_eventstream" = ps: with ps; [ paho-mqtt ];
+    "mqtt_statestream" = ps: with ps; [ paho-mqtt ];
+    "mychevy" = ps: with ps; [  ];
+    "mycroft" = ps: with ps; [  ];
+    "mysensors" = ps: with ps; [  ];
+    "namecheapdns" = ps: with ps; [  ];
+    "neato" = ps: with ps; [  ];
+    "nest" = ps: with ps; [  ];
+    "netatmo" = ps: with ps; [  ];
+    "no_ip" = ps: with ps; [  ];
+    "notify" = ps: with ps; [  ];
+    "notify.apns" = ps: with ps; [  ];
+    "notify.aws_lambda" = ps: with ps; [ boto3 ];
+    "notify.aws_sns" = ps: with ps; [ boto3 ];
+    "notify.aws_sqs" = ps: with ps; [ boto3 ];
+    "notify.ciscospark" = ps: with ps; [  ];
+    "notify.clickatell" = ps: with ps; [  ];
+    "notify.clicksend" = ps: with ps; [  ];
+    "notify.clicksend_tts" = ps: with ps; [  ];
+    "notify.command_line" = ps: with ps; [  ];
+    "notify.demo" = ps: with ps; [  ];
+    "notify.discord" = ps: with ps; [  ];
+    "notify.ecobee" = ps: with ps; [  ];
+    "notify.facebook" = ps: with ps; [  ];
+    "notify.file" = ps: with ps; [  ];
+    "notify.free_mobile" = ps: with ps; [  ];
+    "notify.gntp" = ps: with ps; [  ];
+    "notify.group" = ps: with ps; [  ];
+    "notify.hipchat" = ps: with ps; [  ];
+    "notify.html5" = ps: with ps; [ pyjwt aiohttp-cors ];
+    "notify.instapush" = ps: with ps; [  ];
+    "notify.ios" = ps: with ps; [ aiohttp-cors zeroconf ];
+    "notify.joaoapps_join" = ps: with ps; [  ];
+    "notify.knx" = ps: with ps; [  ];
+    "notify.kodi" = ps: with ps; [ jsonrpc-async ];
+    "notify.lametric" = ps: with ps; [  ];
+    "notify.lannouncer" = ps: with ps; [  ];
+    "notify.llamalab_automate" = ps: with ps; [  ];
+    "notify.mailgun" = ps: with ps; [ aiohttp-cors ];
+    "notify.mastodon" = ps: with ps; [  ];
+    "notify.matrix" = ps: with ps; [ matrix-client ];
+    "notify.message_bird" = ps: with ps; [  ];
+    "notify.mycroft" = ps: with ps; [  ];
+    "notify.mysensors" = ps: with ps; [  ];
+    "notify.nfandroidtv" = ps: with ps; [  ];
+    "notify.nma" = ps: with ps; [  ];
+    "notify.prowl" = ps: with ps; [  ];
+    "notify.pushbullet" = ps: with ps; [ pushbullet ];
+    "notify.pushetta" = ps: with ps; [  ];
+    "notify.pushover" = ps: with ps; [ python-pushover ];
+    "notify.pushsafer" = ps: with ps; [  ];
+    "notify.rest" = ps: with ps; [  ];
+    "notify.rocketchat" = ps: with ps; [  ];
+    "notify.sendgrid" = ps: with ps; [  ];
+    "notify.simplepush" = ps: with ps; [  ];
+    "notify.slack" = ps: with ps; [  ];
+    "notify.smtp" = ps: with ps; [  ];
+    "notify.stride" = ps: with ps; [  ];
+    "notify.synology_chat" = ps: with ps; [  ];
+    "notify.syslog" = ps: with ps; [  ];
+    "notify.telegram" = ps: with ps; [ python-telegram-bot ];
+    "notify.telstra" = ps: with ps; [  ];
+    "notify.twilio_call" = ps: with ps; [ aiohttp-cors twilio ];
+    "notify.twilio_sms" = ps: with ps; [ aiohttp-cors twilio ];
+    "notify.twitter" = ps: with ps; [  ];
+    "notify.webostv" = ps: with ps; [  ];
+    "notify.xmpp" = ps: with ps; [ pyasn1-modules pyasn1 sleekxmpp ];
+    "notify.yessssms" = ps: with ps; [  ];
+    "nuheat" = ps: with ps; [  ];
+    "nuimo_controller" = ps: with ps; [  ];
+    "octoprint" = ps: with ps; [  ];
+    "panel_custom" = ps: with ps; [ aiohttp-cors ];
+    "panel_iframe" = ps: with ps; [ aiohttp-cors ];
+    "persistent_notification" = ps: with ps; [  ];
+    "pilight" = ps: with ps; [  ];
+    "plant" = ps: with ps; [  ];
+    "prometheus" = ps: with ps; [ aiohttp-cors prometheus_client ];
+    "proximity" = ps: with ps; [  ];
+    "python_script" = ps: with ps; [  ];
+    "qwikswitch" = ps: with ps; [  ];
+    "rainbird" = ps: with ps; [  ];
+    "raincloud" = ps: with ps; [  ];
+    "rainmachine" = ps: with ps; [  ];
+    "raspihats" = ps: with ps; [  ];
+    "recorder" = ps: with ps; [ sqlalchemy ];
+    "recorder.const" = ps: with ps; [  ];
+    "recorder.migration" = ps: with ps; [  ];
+    "recorder.purge" = ps: with ps; [  ];
+    "recorder.util" = ps: with ps; [  ];
+    "remember_the_milk" = ps: with ps; [ httplib2 ];
+    "remote" = ps: with ps; [  ];
+    "remote.apple_tv" = ps: with ps; [  ];
+    "remote.demo" = ps: with ps; [  ];
+    "remote.harmony" = ps: with ps; [  ];
+    "remote.itach" = ps: with ps; [  ];
+    "remote.kira" = ps: with ps; [  ];
+    "remote.xiaomi_miio" = ps: with ps; [ construct ];
+    "rest_command" = ps: with ps; [  ];
+    "rflink" = ps: with ps; [  ];
+    "rfxtrx" = ps: with ps; [  ];
+    "ring" = ps: with ps; [  ];
+    "rpi_gpio" = ps: with ps; [  ];
+    "rpi_pfio" = ps: with ps; [  ];
+    "rss_feed_template" = ps: with ps; [ aiohttp-cors ];
+    "satel_integra" = ps: with ps; [  ];
+    "scene" = ps: with ps; [  ];
+    "scene.deconz" = ps: with ps; [  ];
+    "scene.homeassistant" = ps: with ps; [  ];
+    "scene.hunterdouglas_powerview" = ps: with ps; [  ];
+    "scene.knx" = ps: with ps; [  ];
+    "scene.lifx_cloud" = ps: with ps; [  ];
+    "scene.litejet" = ps: with ps; [  ];
+    "scene.lutron_caseta" = ps: with ps; [  ];
+    "scene.tahoma" = ps: with ps; [  ];
+    "scene.velux" = ps: with ps; [  ];
+    "scene.vera" = ps: with ps; [  ];
+    "scene.wink" = ps: with ps; [  ];
+    "script" = ps: with ps; [  ];
+    "scsgate" = ps: with ps; [  ];
+    "sensor" = ps: with ps; [  ];
+    "sensor.abode" = ps: with ps; [  ];
+    "sensor.ads" = ps: with ps; [  ];
+    "sensor.airvisual" = ps: with ps; [ pyairvisual ];
+    "sensor.alarmdecoder" = ps: with ps; [  ];
+    "sensor.alpha_vantage" = ps: with ps; [  ];
+    "sensor.amcrest" = ps: with ps; [ ha-ffmpeg ];
+    "sensor.android_ip_webcam" = ps: with ps; [  ];
+    "sensor.apcupsd" = ps: with ps; [  ];
+    "sensor.api_streams" = ps: with ps; [  ];
+    "sensor.arduino" = ps: with ps; [  ];
+    "sensor.arest" = ps: with ps; [  ];
+    "sensor.arlo" = ps: with ps; [  ];
+    "sensor.arwn" = ps: with ps; [ paho-mqtt ];
+    "sensor.bbox" = ps: with ps; [  ];
+    "sensor.bh1750" = ps: with ps; [  ];
+    "sensor.bitcoin" = ps: with ps; [  ];
+    "sensor.blink" = ps: with ps; [  ];
+    "sensor.blockchain" = ps: with ps; [  ];
+    "sensor.bloomsky" = ps: with ps; [  ];
+    "sensor.bme280" = ps: with ps; [  ];
+    "sensor.bme680" = ps: with ps; [  ];
+    "sensor.bmw_connected_drive" = ps: with ps; [  ];
+    "sensor.bom" = ps: with ps; [  ];
+    "sensor.broadlink" = ps: with ps; [  ];
+    "sensor.buienradar" = ps: with ps; [  ];
+    "sensor.canary" = ps: with ps; [  ];
+    "sensor.cert_expiry" = ps: with ps; [  ];
+    "sensor.citybikes" = ps: with ps; [  ];
+    "sensor.coinbase" = ps: with ps; [  ];
+    "sensor.coinmarketcap" = ps: with ps; [ coinmarketcap ];
+    "sensor.comed_hourly_pricing" = ps: with ps; [  ];
+    "sensor.comfoconnect" = ps: with ps; [  ];
+    "sensor.command_line" = ps: with ps; [  ];
+    "sensor.cpuspeed" = ps: with ps; [  ];
+    "sensor.crimereports" = ps: with ps; [  ];
+    "sensor.cups" = ps: with ps; [ pycups ];
+    "sensor.currencylayer" = ps: with ps; [  ];
+    "sensor.daikin" = ps: with ps; [  ];
+    "sensor.darksky" = ps: with ps; [  ];
+    "sensor.deconz" = ps: with ps; [  ];
+    "sensor.deluge" = ps: with ps; [ deluge-client ];
+    "sensor.demo" = ps: with ps; [  ];
+    "sensor.deutsche_bahn" = ps: with ps; [  ];
+    "sensor.dht" = ps: with ps; [  ];
+    "sensor.discogs" = ps: with ps; [ discogs_client ];
+    "sensor.dnsip" = ps: with ps; [ aiodns ];
+    "sensor.dovado" = ps: with ps; [  ];
+    "sensor.dsmr" = ps: with ps; [  ];
+    "sensor.dte_energy_bridge" = ps: with ps; [  ];
+    "sensor.dublin_bus_transport" = ps: with ps; [  ];
+    "sensor.dwd_weather_warnings" = ps: with ps; [  ];
+    "sensor.dweet" = ps: with ps; [  ];
+    "sensor.dyson" = ps: with ps; [  ];
+    "sensor.ebox" = ps: with ps; [  ];
+    "sensor.ecobee" = ps: with ps; [  ];
+    "sensor.eddystone_temperature" = ps: with ps; [ construct ];
+    "sensor.efergy" = ps: with ps; [  ];
+    "sensor.eight_sleep" = ps: with ps; [  ];
+    "sensor.eliqonline" = ps: with ps; [  ];
+    "sensor.emoncms" = ps: with ps; [  ];
+    "sensor.enocean" = ps: with ps; [  ];
+    "sensor.envirophat" = ps: with ps; [  ];
+    "sensor.envisalink" = ps: with ps; [  ];
+    "sensor.etherscan" = ps: with ps; [  ];
+    "sensor.fail2ban" = ps: with ps; [  ];
+    "sensor.fastdotcom" = ps: with ps; [  ];
+    "sensor.fedex" = ps: with ps; [  ];
+    "sensor.fido" = ps: with ps; [  ];
+    "sensor.file" = ps: with ps; [  ];
+    "sensor.filesize" = ps: with ps; [  ];
+    "sensor.filter" = ps: with ps; [  ];
+    "sensor.fitbit" = ps: with ps; [ aiohttp-cors ];
+    "sensor.fixer" = ps: with ps; [  ];
+    "sensor.folder" = ps: with ps; [  ];
+    "sensor.foobot" = ps: with ps; [  ];
+    "sensor.fritzbox_callmonitor" = ps: with ps; [ fritzconnection ];
+    "sensor.fritzbox_netmonitor" = ps: with ps; [ fritzconnection ];
+    "sensor.gearbest" = ps: with ps; [  ];
+    "sensor.geizhals" = ps: with ps; [ beautifulsoup4 ];
+    "sensor.geo_rss_events" = ps: with ps; [ feedparser ];
+    "sensor.gitter" = ps: with ps; [  ];
+    "sensor.glances" = ps: with ps; [  ];
+    "sensor.google_travel_time" = ps: with ps; [  ];
+    "sensor.google_wifi" = ps: with ps; [  ];
+    "sensor.gpsd" = ps: with ps; [  ];
+    "sensor.gtfs" = ps: with ps; [  ];
+    "sensor.haveibeenpwned" = ps: with ps; [  ];
+    "sensor.hddtemp" = ps: with ps; [  ];
+    "sensor.history_stats" = ps: with ps; [ aiohttp-cors sqlalchemy ];
+    "sensor.hive" = ps: with ps; [  ];
+    "sensor.homematic" = ps: with ps; [ pyhomematic ];
+    "sensor.homematicip_cloud" = ps: with ps; [  ];
+    "sensor.hp_ilo" = ps: with ps; [  ];
+    "sensor.htu21d" = ps: with ps; [  ];
+    "sensor.hydroquebec" = ps: with ps; [  ];
+    "sensor.ihc" = ps: with ps; [  ];
+    "sensor.imap" = ps: with ps; [ aioimaplib ];
+    "sensor.imap_email_content" = ps: with ps; [  ];
+    "sensor.influxdb" = ps: with ps; [ influxdb ];
+    "sensor.insteon_plm" = ps: with ps; [  ];
+    "sensor.ios" = ps: with ps; [ aiohttp-cors zeroconf ];
+    "sensor.iota" = ps: with ps; [  ];
+    "sensor.irish_rail_transport" = ps: with ps; [  ];
+    "sensor.isy994" = ps: with ps; [  ];
+    "sensor.juicenet" = ps: with ps; [  ];
+    "sensor.kira" = ps: with ps; [  ];
+    "sensor.knx" = ps: with ps; [  ];
+    "sensor.kwb" = ps: with ps; [  ];
+    "sensor.lacrosse" = ps: with ps; [  ];
+    "sensor.lastfm" = ps: with ps; [ pylast ];
+    "sensor.linux_battery" = ps: with ps; [ batinfo ];
+    "sensor.london_air" = ps: with ps; [  ];
+    "sensor.london_underground" = ps: with ps; [  ];
+    "sensor.loopenergy" = ps: with ps; [  ];
+    "sensor.luftdaten" = ps: with ps; [ luftdaten ];
+    "sensor.lyft" = ps: with ps; [  ];
+    "sensor.melissa" = ps: with ps; [  ];
+    "sensor.metoffice" = ps: with ps; [  ];
+    "sensor.mfi" = ps: with ps; [  ];
+    "sensor.mhz19" = ps: with ps; [  ];
+    "sensor.miflora" = ps: with ps; [  ];
+    "sensor.min_max" = ps: with ps; [  ];
+    "sensor.mitemp_bt" = ps: with ps; [  ];
+    "sensor.modbus" = ps: with ps; [  ];
+    "sensor.modem_callerid" = ps: with ps; [  ];
+    "sensor.mold_indicator" = ps: with ps; [  ];
+    "sensor.moon" = ps: with ps; [  ];
+    "sensor.mopar" = ps: with ps; [  ];
+    "sensor.mqtt" = ps: with ps; [ paho-mqtt ];
+    "sensor.mqtt_room" = ps: with ps; [ paho-mqtt ];
+    "sensor.mvglive" = ps: with ps; [ PyMVGLive ];
+    "sensor.mychevy" = ps: with ps; [  ];
+    "sensor.mysensors" = ps: with ps; [  ];
+    "sensor.nederlandse_spoorwegen" = ps: with ps; [  ];
+    "sensor.nest" = ps: with ps; [  ];
+    "sensor.netatmo" = ps: with ps; [  ];
+    "sensor.netdata" = ps: with ps; [  ];
+    "sensor.neurio_energy" = ps: with ps; [  ];
+    "sensor.nut" = ps: with ps; [  ];
+    "sensor.nzbget" = ps: with ps; [  ];
+    "sensor.octoprint" = ps: with ps; [  ];
+    "sensor.ohmconnect" = ps: with ps; [  ];
+    "sensor.onewire" = ps: with ps; [  ];
+    "sensor.openevse" = ps: with ps; [  ];
+    "sensor.openexchangerates" = ps: with ps; [  ];
+    "sensor.openhardwaremonitor" = ps: with ps; [  ];
+    "sensor.opensky" = ps: with ps; [  ];
+    "sensor.openweathermap" = ps: with ps; [ pyowm ];
+    "sensor.otp" = ps: with ps; [  ];
+    "sensor.pi_hole" = ps: with ps; [  ];
+    "sensor.pilight" = ps: with ps; [  ];
+    "sensor.plex" = ps: with ps; [  ];
+    "sensor.pocketcasts" = ps: with ps; [  ];
+    "sensor.pollen" = ps: with ps; [  ];
+    "sensor.postnl" = ps: with ps; [  ];
+    "sensor.pushbullet" = ps: with ps; [ pushbullet ];
+    "sensor.pvoutput" = ps: with ps; [  ];
+    "sensor.pyload" = ps: with ps; [  ];
+    "sensor.qnap" = ps: with ps; [  ];
+    "sensor.qwikswitch" = ps: with ps; [  ];
+    "sensor.radarr" = ps: with ps; [  ];
+    "sensor.rainbird" = ps: with ps; [  ];
+    "sensor.raincloud" = ps: with ps; [  ];
+    "sensor.random" = ps: with ps; [  ];
+    "sensor.rest" = ps: with ps; [  ];
+    "sensor.rflink" = ps: with ps; [  ];
+    "sensor.rfxtrx" = ps: with ps; [  ];
+    "sensor.ring" = ps: with ps; [  ];
+    "sensor.ripple" = ps: with ps; [  ];
+    "sensor.sabnzbd" = ps: with ps; [  ];
+    "sensor.scrape" = ps: with ps; [ beautifulsoup4 ];
+    "sensor.season" = ps: with ps; [ ephem ];
+    "sensor.sense" = ps: with ps; [  ];
+    "sensor.sensehat" = ps: with ps; [  ];
+    "sensor.serial" = ps: with ps; [  ];
+    "sensor.serial_pm" = ps: with ps; [  ];
+    "sensor.shodan" = ps: with ps; [  ];
+    "sensor.sht31" = ps: with ps; [  ];
+    "sensor.sigfox" = ps: with ps; [  ];
+    "sensor.simulated" = ps: with ps; [  ];
+    "sensor.skybeacon" = ps: with ps; [  ];
+    "sensor.skybell" = ps: with ps; [  ];
+    "sensor.sleepiq" = ps: with ps; [  ];
+    "sensor.sma" = ps: with ps; [  ];
+    "sensor.smappee" = ps: with ps; [  ];
+    "sensor.snmp" = ps: with ps; [ pysnmp ];
+    "sensor.sochain" = ps: with ps; [  ];
+    "sensor.socialblade" = ps: with ps; [  ];
+    "sensor.sonarr" = ps: with ps; [  ];
+    "sensor.speedtest" = ps: with ps; [  ];
+    "sensor.spotcrime" = ps: with ps; [  ];
+    "sensor.sql" = ps: with ps; [ sqlalchemy ];
+    "sensor.startca" = ps: with ps; [ xmltodict ];
+    "sensor.statistics" = ps: with ps; [  ];
+    "sensor.steam_online" = ps: with ps; [  ];
+    "sensor.supervisord" = ps: with ps; [  ];
+    "sensor.swiss_hydrological_data" = ps: with ps; [ xmltodict ];
+    "sensor.swiss_public_transport" = ps: with ps; [  ];
+    "sensor.syncthru" = ps: with ps; [  ];
+    "sensor.synologydsm" = ps: with ps; [  ];
+    "sensor.systemmonitor" = ps: with ps; [ psutil ];
+    "sensor.sytadin" = ps: with ps; [ beautifulsoup4 ];
+    "sensor.tado" = ps: with ps; [  ];
+    "sensor.tahoma" = ps: with ps; [  ];
+    "sensor.tank_utility" = ps: with ps; [  ];
+    "sensor.tcp" = ps: with ps; [  ];
+    "sensor.ted5000" = ps: with ps; [ xmltodict ];
+    "sensor.teksavvy" = ps: with ps; [  ];
+    "sensor.tellduslive" = ps: with ps; [  ];
+    "sensor.tellstick" = ps: with ps; [  ];
+    "sensor.temper" = ps: with ps; [  ];
+    "sensor.template" = ps: with ps; [  ];
+    "sensor.tesla" = ps: with ps; [  ];
+    "sensor.thethingsnetwork" = ps: with ps; [  ];
+    "sensor.thinkingcleaner" = ps: with ps; [  ];
+    "sensor.tibber" = ps: with ps; [  ];
+    "sensor.time_date" = ps: with ps; [  ];
+    "sensor.toon" = ps: with ps; [  ];
+    "sensor.torque" = ps: with ps; [ aiohttp-cors ];
+    "sensor.tradfri" = ps: with ps; [  ];
+    "sensor.trafikverket_weatherstation" = ps: with ps; [  ];
+    "sensor.transmission" = ps: with ps; [ transmissionrpc ];
+    "sensor.travisci" = ps: with ps; [  ];
+    "sensor.twitch" = ps: with ps; [  ];
+    "sensor.uber" = ps: with ps; [  ];
+    "sensor.uk_transport" = ps: with ps; [  ];
+    "sensor.upnp" = ps: with ps; [ aiohttp-cors ];
+    "sensor.ups" = ps: with ps; [  ];
+    "sensor.uptime" = ps: with ps; [  ];
+    "sensor.uscis" = ps: with ps; [  ];
+    "sensor.usps" = ps: with ps; [  ];
+    "sensor.vasttrafik" = ps: with ps; [  ];
+    "sensor.vera" = ps: with ps; [  ];
+    "sensor.verisure" = ps: with ps; [  ];
+    "sensor.version" = ps: with ps; [  ];
+    "sensor.viaggiatreno" = ps: with ps; [  ];
+    "sensor.volvooncall" = ps: with ps; [  ];
+    "sensor.vultr" = ps: with ps; [ vultr ];
+    "sensor.waqi" = ps: with ps; [  ];
+    "sensor.waterfurnace" = ps: with ps; [  ];
+    "sensor.waze_travel_time" = ps: with ps; [  ];
+    "sensor.whois" = ps: with ps; [  ];
+    "sensor.wink" = ps: with ps; [  ];
+    "sensor.worldclock" = ps: with ps; [  ];
+    "sensor.worldtidesinfo" = ps: with ps; [  ];
+    "sensor.worxlandroid" = ps: with ps; [  ];
+    "sensor.wsdot" = ps: with ps; [  ];
+    "sensor.wunderground" = ps: with ps; [  ];
+    "sensor.xbox_live" = ps: with ps; [  ];
+    "sensor.xiaomi_aqara" = ps: with ps; [  ];
+    "sensor.xiaomi_miio" = ps: with ps; [ construct ];
+    "sensor.yahoo_finance" = ps: with ps; [  ];
+    "sensor.yr" = ps: with ps; [ xmltodict ];
+    "sensor.yweather" = ps: with ps; [ yahooweather ];
+    "sensor.zabbix" = ps: with ps; [  ];
+    "sensor.zamg" = ps: with ps; [  ];
+    "sensor.zestimate" = ps: with ps; [ xmltodict ];
+    "sensor.zha" = ps: with ps; [  ];
+    "sensor.zigbee" = ps: with ps; [  ];
+    "sensor.zoneminder" = ps: with ps; [  ];
+    "sensor.zwave" = ps: with ps; [  ];
+    "shell_command" = ps: with ps; [  ];
+    "shiftr" = ps: with ps; [ paho-mqtt ];
+    "shopping_list" = ps: with ps; [ aiohttp-cors ];
+    "skybell" = ps: with ps; [  ];
+    "sleepiq" = ps: with ps; [  ];
+    "smappee" = ps: with ps; [  ];
+    "snips" = ps: with ps; [ paho-mqtt ];
+    "spc" = ps: with ps; [ websockets ];
+    "splunk" = ps: with ps; [  ];
+    "statsd" = ps: with ps; [ statsd ];
+    "sun" = ps: with ps; [  ];
+    "switch" = ps: with ps; [  ];
+    "switch.abode" = ps: with ps; [  ];
+    "switch.acer_projector" = ps: with ps; [ pyserial ];
+    "switch.ads" = ps: with ps; [  ];
+    "switch.amcrest" = ps: with ps; [ ha-ffmpeg ];
+    "switch.android_ip_webcam" = ps: with ps; [  ];
+    "switch.anel_pwrctrl" = ps: with ps; [  ];
+    "switch.arduino" = ps: with ps; [  ];
+    "switch.arest" = ps: with ps; [  ];
+    "switch.bbb_gpio" = ps: with ps; [  ];
+    "switch.broadlink" = ps: with ps; [  ];
+    "switch.command_line" = ps: with ps; [  ];
+    "switch.deluge" = ps: with ps; [ deluge-client ];
+    "switch.demo" = ps: with ps; [  ];
+    "switch.digital_ocean" = ps: with ps; [ digital-ocean ];
+    "switch.digitalloggers" = ps: with ps; [  ];
+    "switch.dlink" = ps: with ps; [  ];
+    "switch.doorbird" = ps: with ps; [  ];
+    "switch.edimax" = ps: with ps; [  ];
+    "switch.enocean" = ps: with ps; [  ];
+    "switch.eufy" = ps: with ps; [  ];
+    "switch.flux" = ps: with ps; [  ];
+    "switch.fritzbox" = ps: with ps; [  ];
+    "switch.fritzdect" = ps: with ps; [  ];
+    "switch.gc100" = ps: with ps; [  ];
+    "switch.hdmi_cec" = ps: with ps; [  ];
+    "switch.hikvisioncam" = ps: with ps; [  ];
+    "switch.hive" = ps: with ps; [  ];
+    "switch.homekit_controller" = ps: with ps; [  ];
+    "switch.homematic" = ps: with ps; [ pyhomematic ];
+    "switch.hook" = ps: with ps; [  ];
+    "switch.ihc" = ps: with ps; [  ];
+    "switch.insteon_local" = ps: with ps; [  ];
+    "switch.insteon_plm" = ps: with ps; [  ];
+    "switch.isy994" = ps: with ps; [  ];
+    "switch.kankun" = ps: with ps; [  ];
+    "switch.knx" = ps: with ps; [  ];
+    "switch.linode" = ps: with ps; [ linode-api ];
+    "switch.litejet" = ps: with ps; [  ];
+    "switch.lutron_caseta" = ps: with ps; [  ];
+    "switch.mfi" = ps: with ps; [  ];
+    "switch.mochad" = ps: with ps; [  ];
+    "switch.modbus" = ps: with ps; [  ];
+    "switch.mqtt" = ps: with ps; [ paho-mqtt ];
+    "switch.mysensors" = ps: with ps; [  ];
+    "switch.mystrom" = ps: with ps; [  ];
+    "switch.neato" = ps: with ps; [  ];
+    "switch.netio" = ps: with ps; [ aiohttp-cors ];
+    "switch.orvibo" = ps: with ps; [  ];
+    "switch.pilight" = ps: with ps; [  ];
+    "switch.pulseaudio_loopback" = ps: with ps; [  ];
+    "switch.qwikswitch" = ps: with ps; [  ];
+    "switch.rachio" = ps: with ps; [  ];
+    "switch.rainbird" = ps: with ps; [  ];
+    "switch.raincloud" = ps: with ps; [  ];
+    "switch.rainmachine" = ps: with ps; [  ];
+    "switch.raspihats" = ps: with ps; [  ];
+    "switch.rest" = ps: with ps; [  ];
+    "switch.rflink" = ps: with ps; [  ];
+    "switch.rfxtrx" = ps: with ps; [  ];
+    "switch.rpi_gpio" = ps: with ps; [  ];
+    "switch.rpi_pfio" = ps: with ps; [  ];
+    "switch.rpi_rf" = ps: with ps; [  ];
+    "switch.scsgate" = ps: with ps; [  ];
+    "switch.skybell" = ps: with ps; [  ];
+    "switch.smappee" = ps: with ps; [  ];
+    "switch.snmp" = ps: with ps; [ pysnmp ];
+    "switch.tahoma" = ps: with ps; [  ];
+    "switch.tellduslive" = ps: with ps; [  ];
+    "switch.tellstick" = ps: with ps; [  ];
+    "switch.telnet" = ps: with ps; [  ];
+    "switch.template" = ps: with ps; [  ];
+    "switch.tesla" = ps: with ps; [  ];
+    "switch.thinkingcleaner" = ps: with ps; [  ];
+    "switch.toon" = ps: with ps; [  ];
+    "switch.tplink" = ps: with ps; [  ];
+    "switch.transmission" = ps: with ps; [ transmissionrpc ];
+    "switch.upcloud" = ps: with ps; [  ];
+    "switch.velbus" = ps: with ps; [  ];
+    "switch.vera" = ps: with ps; [  ];
+    "switch.verisure" = ps: with ps; [  ];
+    "switch.vesync" = ps: with ps; [  ];
+    "switch.volvooncall" = ps: with ps; [  ];
+    "switch.vultr" = ps: with ps; [ vultr ];
+    "switch.wake_on_lan" = ps: with ps; [ wakeonlan ];
+    "switch.wemo" = ps: with ps; [  ];
+    "switch.wink" = ps: with ps; [  ];
+    "switch.xiaomi_aqara" = ps: with ps; [  ];
+    "switch.xiaomi_miio" = ps: with ps; [ construct ];
+    "switch.zha" = ps: with ps; [  ];
+    "switch.zigbee" = ps: with ps; [  ];
+    "switch.zoneminder" = ps: with ps; [  ];
+    "switch.zwave" = ps: with ps; [  ];
+    "system_log" = ps: with ps; [ aiohttp-cors ];
+    "tado" = ps: with ps; [  ];
+    "tahoma" = ps: with ps; [  ];
+    "telegram_bot" = ps: with ps; [ python-telegram-bot ];
+    "telegram_bot.broadcast" = ps: with ps; [  ];
+    "telegram_bot.polling" = ps: with ps; [  ];
+    "telegram_bot.webhooks" = ps: with ps; [ aiohttp-cors ];
+    "tellduslive" = ps: with ps; [  ];
+    "tellstick" = ps: with ps; [  ];
+    "tesla" = ps: with ps; [  ];
+    "thethingsnetwork" = ps: with ps; [  ];
+    "thingspeak" = ps: with ps; [  ];
+    "timer" = ps: with ps; [  ];
+    "toon" = ps: with ps; [  ];
+    "tradfri" = ps: with ps; [  ];
+    "tts" = ps: with ps; [ aiohttp-cors mutagen ];
+    "tts.amazon_polly" = ps: with ps; [ boto3 ];
+    "tts.baidu" = ps: with ps; [  ];
+    "tts.demo" = ps: with ps; [  ];
+    "tts.google" = ps: with ps; [  ];
+    "tts.marytts" = ps: with ps; [  ];
+    "tts.microsoft" = ps: with ps; [  ];
+    "tts.picotts" = ps: with ps; [  ];
+    "tts.voicerss" = ps: with ps; [  ];
+    "tts.yandextts" = ps: with ps; [  ];
+    "twilio" = ps: with ps; [ aiohttp-cors twilio ];
+    "upcloud" = ps: with ps; [  ];
+    "updater" = ps: with ps; [ distro ];
+    "upnp" = ps: with ps; [ aiohttp-cors ];
+    "usps" = ps: with ps; [  ];
+    "vacuum" = ps: with ps; [  ];
+    "vacuum.demo" = ps: with ps; [  ];
+    "vacuum.dyson" = ps: with ps; [  ];
+    "vacuum.mqtt" = ps: with ps; [ paho-mqtt ];
+    "vacuum.neato" = ps: with ps; [  ];
+    "vacuum.roomba" = ps: with ps; [  ];
+    "vacuum.xiaomi_miio" = ps: with ps; [ construct ];
+    "velbus" = ps: with ps; [  ];
+    "velux" = ps: with ps; [  ];
+    "vera" = ps: with ps; [  ];
+    "verisure" = ps: with ps; [  ];
+    "volvooncall" = ps: with ps; [  ];
+    "vultr" = ps: with ps; [ vultr ];
+    "wake_on_lan" = ps: with ps; [ wakeonlan ];
+    "waterfurnace" = ps: with ps; [  ];
+    "weather" = ps: with ps; [  ];
+    "weather.bom" = ps: with ps; [  ];
+    "weather.buienradar" = ps: with ps; [  ];
+    "weather.darksky" = ps: with ps; [  ];
+    "weather.demo" = ps: with ps; [  ];
+    "weather.ecobee" = ps: with ps; [  ];
+    "weather.metoffice" = ps: with ps; [  ];
+    "weather.openweathermap" = ps: with ps; [ pyowm ];
+    "weather.yweather" = ps: with ps; [ yahooweather ];
+    "weather.zamg" = ps: with ps; [  ];
+    "weblink" = ps: with ps; [  ];
+    "websocket_api" = ps: with ps; [ aiohttp-cors ];
+    "wemo" = ps: with ps; [  ];
+    "wink" = ps: with ps; [  ];
+    "xiaomi_aqara" = ps: with ps; [  ];
+    "zabbix" = ps: with ps; [  ];
+    "zeroconf" = ps: with ps; [ aiohttp-cors zeroconf ];
+    "zha" = ps: with ps; [  ];
+    "zha.const" = ps: with ps; [  ];
+    "zigbee" = ps: with ps; [  ];
+    "zone" = ps: with ps; [  ];
+    "zone.config_flow" = ps: with ps; [  ];
+    "zone.const" = ps: with ps; [  ];
+    "zone.zone" = ps: with ps; [  ];
+    "zoneminder" = ps: with ps; [  ];
+    "zwave" = ps: with ps; [ pydispatcher python_openzwave ];
+    "zwave.const" = ps: with ps; [  ];
+    "zwave.discovery_schemas" = ps: with ps; [  ];
+    "zwave.node_entity" = ps: with ps; [  ];
+    "zwave.util" = ps: with ps; [  ];
+    "zwave.workaround" = ps: with ps; [  ];
+  };
+}
diff --git a/pkgs/servers/home-assistant/default.nix b/pkgs/servers/home-assistant/default.nix
new file mode 100644
index 000000000000..fbc233398735
--- /dev/null
+++ b/pkgs/servers/home-assistant/default.nix
@@ -0,0 +1,123 @@
+{ lib, fetchFromGitHub, python3
+, extraComponents ? []
+, extraPackages ? ps: []
+, skipPip ? true }:
+
+let
+
+  py = python3.override {
+    packageOverrides = self: super: {
+      aiohttp = super.aiohttp.overridePythonAttrs (oldAttrs: rec {
+        version = "3.1.3";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "9fcef0489e3335b200d31a9c1fb6ba80fdafe14cd82b971168c2f9fa1e4508ad";
+        };
+      });
+      pytest = super.pytest.overridePythonAttrs (oldAttrs: rec {
+        version = "3.4.2";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "117bad36c1a787e1a8a659df35de53ba05f9f3398fb9e4ac17e80ad5903eb8c5";
+        };
+      });
+      voluptuous = super.voluptuous.overridePythonAttrs (oldAttrs: rec {
+        version = "0.11.1";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "af7315c9fa99e0bfd195a21106c82c81619b42f0bd9b6e287b797c6b6b6a9918";
+        };
+      });
+      attrs = super.attrs.overridePythonAttrs (oldAttrs: rec {
+        version = "18.1.0";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b";
+        };
+      });
+      astral = super.astral.overridePythonAttrs (oldAttrs: rec {
+        version = "1.6.1";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "ab0c08f2467d35fcaeb7bad15274743d3ac1ad18b5391f64a0058a9cd192d37d";
+        };
+      });
+      async-timeout = super.async-timeout.overridePythonAttrs (oldAttrs: rec {
+        version = "2.0.1";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "00cff4d2dce744607335cba84e9929c3165632da2d27970dbc55802a0c7873d0";
+        };
+      });
+      # used by check_config script
+      # can be unpinned once https://github.com/home-assistant/home-assistant/issues/11917 is resolved
+      colorlog = super.colorlog.overridePythonAttrs (oldAttrs: rec {
+        version = "3.1.4";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "418db638c9577f37f0fae4914074f395847a728158a011be2a193ac491b9779d";
+        };
+      });
+      hass-frontend = super.callPackage ./frontend.nix { };
+    };
+  };
+
+  componentPackages = import ./component-packages.nix;
+
+  availableComponents = builtins.attrNames componentPackages.components;
+
+  getPackages = component: builtins.getAttr component componentPackages.components;
+
+  componentBuildInputs = lib.concatMap (component: getPackages component py.pkgs) extraComponents;
+
+  # Ensure that we are using a consistent package set
+  extraBuildInputs = extraPackages py.pkgs;
+
+  # Don't forget to run parse-requirements.py after updating
+  hassVersion = "0.69.1";
+
+in with py.pkgs; buildPythonApplication rec {
+  pname = "homeassistant";
+  version = assert (componentPackages.version == hassVersion); hassVersion;
+
+  disabled = pythonOlder "3.5";
+
+  inherit availableComponents;
+
+  # PyPI tarball is missing tests/ directory
+  src = fetchFromGitHub {
+    owner = "home-assistant";
+    repo = "home-assistant";
+    rev = version;
+    sha256 = "1y74zq1nah9k6rif8k384ri11h1f23ggr613f7qnn0107b23asr4";
+  };
+
+  propagatedBuildInputs = [
+    # From setup.py
+    requests pyyaml pytz pip jinja2 voluptuous typing aiohttp async-timeout astral certifi attrs
+    # From http, frontend, recorder and config.config_entries components
+    sqlalchemy aiohttp-cors hass-frontend voluptuous-serialize
+  ] ++ componentBuildInputs ++ extraBuildInputs;
+
+  checkInputs = [
+    pytest requests-mock pydispatcher pytest-aiohttp
+  ];
+
+  checkPhase = ''
+    # The components' dependencies are not included, so they cannot be tested
+    py.test --ignore tests/components
+    # Some basic components should be tested however
+    py.test \
+      tests/components/{group,http} \
+      tests/components/test_{api,configurator,demo,discovery,frontend,init,introduction,logger,script,shell_command,system_log,websocket_api}.py
+  '';
+
+  makeWrapperArgs = lib.optional skipPip "--add-flags --skip-pip";
+
+  meta = with lib; {
+    homepage = https://home-assistant.io/;
+    description = "Open-source home automation platform running on Python 3";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ f-breidenstein dotlambda ];
+  };
+}
diff --git a/pkgs/servers/home-assistant/frontend.nix b/pkgs/servers/home-assistant/frontend.nix
new file mode 100644
index 000000000000..168a1ec3b9dd
--- /dev/null
+++ b/pkgs/servers/home-assistant/frontend.nix
@@ -0,0 +1,13 @@
+{ stdenv, fetchPypi, buildPythonPackage, user-agents }:
+
+buildPythonPackage rec {
+  pname = "home-assistant-frontend";
+  version = "20180509.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "11d9c4a07565358e6ee001f5c57c8393b4aaadac0d993a0a39a0387a33644fba";
+  };
+
+  propagatedBuildInputs = [ user-agents ];
+}
diff --git a/pkgs/servers/home-assistant/parse-requirements.py b/pkgs/servers/home-assistant/parse-requirements.py
new file mode 100755
index 000000000000..068b89d9a9fe
--- /dev/null
+++ b/pkgs/servers/home-assistant/parse-requirements.py
@@ -0,0 +1,131 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ requests pyyaml pytz pip jinja2 voluptuous typing aiohttp async-timeout astral certifi attrs ])"
+#
+# This script downloads Home Assistant's source tarball.
+# Inside the homeassistant/components directory, each component has an associated .py file,
+# specifying required packages and other components it depends on:
+#
+# REQUIREMENTS = [ 'package==1.2.3' ]
+# DEPENDENCIES = [ 'component' ]
+#
+# By parsing the files, a dictionary mapping component to requirements and dependencies is created.
+# For all of these requirements and the dependencies' requirements,
+# Nixpkgs' python3Packages are searched for appropriate names.
+# Then, a Nix attribute set mapping component name to dependencies is created.
+
+from urllib.request import urlopen
+import tempfile
+from io import BytesIO
+import tarfile
+import importlib
+import subprocess
+import os
+import sys
+import json
+import re
+
+COMPONENT_PREFIX = 'homeassistant.components'
+PKG_SET = 'python3Packages'
+
+# If some requirements are matched by multiple python packages,
+# the following can be used to choose one of them
+PKG_PREFERENCES = {
+    # Use python3Packages.youtube-dl-light instead of python3Packages.youtube-dl
+    'youtube-dl': 'youtube-dl-light'
+}
+
+def get_version():
+    with open(os.path.dirname(sys.argv[0]) + '/default.nix') as f:
+        m = re.search('hassVersion = "([\\d\\.]+)";', f.read())
+        return m.group(1)
+
+def parse_components(version='master'):
+    components = {}
+    with tempfile.TemporaryDirectory() as tmp:
+        with urlopen('https://github.com/home-assistant/home-assistant/archive/{}.tar.gz'.format(version)) as response:
+            tarfile.open(fileobj=BytesIO(response.read())).extractall(tmp)
+        # Use part of a script from the Home Assistant codebase
+        sys.path.append(tmp + '/home-assistant-{}'.format(version))
+        from script.gen_requirements_all import explore_module
+        for package in explore_module(COMPONENT_PREFIX, True):
+            # Remove 'homeassistant.components.' prefix
+            component = package[len(COMPONENT_PREFIX + '.'):]
+            try:
+                module = importlib.import_module(package)
+                components[component] = {}
+                components[component]['requirements'] = getattr(module, 'REQUIREMENTS', [])
+                components[component]['dependencies'] = getattr(module, 'DEPENDENCIES', [])
+            # If there is an ImportError, the imported file is not the main file of the component
+            except ImportError:
+                continue
+    return components
+
+# Recursively get the requirements of a component and its dependencies
+def get_reqs(components, component):
+    requirements = set(components[component]['requirements'])
+    for dependency in components[component]['dependencies']:
+        requirements.update(get_reqs(components, dependency))
+    return requirements
+
+# Store a JSON dump of Nixpkgs' python3Packages
+output = subprocess.check_output(['nix-env', '-f', os.path.dirname(sys.argv[0]) + '/../../..', '-qa', '-A', PKG_SET, '--json'])
+packages = json.loads(output)
+
+def name_to_attr_path(req):
+    attr_paths = set()
+    names = [req]
+    # E.g. python-mpd2 is actually called python3.6-mpd2
+    # instead of python-3.6-python-mpd2 inside Nixpkgs
+    if req.startswith('python-') or req.startswith('python_'):
+        names.append(req[len('python-'):])
+    for name in names:
+        # treat "-" and "_" equally
+        name = re.sub('[-_]', '[-_]', name)
+        pattern = re.compile('^python\\d\\.\\d-{}-\\d'.format(name), re.I)
+        for attr_path, package in packages.items():
+            if pattern.match(package['name']):
+                attr_paths.add(attr_path)
+    if len(attr_paths) > 1:
+        for to_replace, replacement in PKG_PREFERENCES.items():
+            try:
+                attr_paths.remove(PKG_SET + '.' + to_replace)
+                attr_paths.add(PKG_SET + '.' + replacement)
+            except KeyError:
+                pass
+    # Let's hope there's only one derivation with a matching name
+    assert(len(attr_paths) <= 1)
+    if len(attr_paths) == 1:
+        return attr_paths.pop()
+    else:
+        return None
+
+version = get_version()
+print('Generating component-packages.nix for version {}'.format(version))
+components = parse_components(version=version)
+build_inputs = {}
+for component in sorted(components.keys()):
+    attr_paths = []
+    for req in sorted(get_reqs(components, component)):
+        # Some requirements are specified by url, e.g. https://example.org/foobar#xyz==1.0.0
+        # Therefore, if there's a "#" in the line, only take the part after it
+        req = req[req.find('#') + 1:]
+        name = req.split('==')[0]
+        attr_path = name_to_attr_path(name)
+        if attr_path is not None:
+            # Add attribute path without "python3Packages." prefix
+            attr_paths.append(attr_path[len(PKG_SET + '.'):])
+    else:
+        build_inputs[component] = attr_paths
+
+with open(os.path.dirname(sys.argv[0]) + '/component-packages.nix', 'w') as f:
+    f.write('# Generated by parse-requirements.py\n')
+    f.write('# Do not edit!\n\n')
+    f.write('{\n')
+    f.write('  version = "{}";\n'.format(version))
+    f.write('  components = {\n')
+    for component, attr_paths in build_inputs.items():
+        f.write('    "{}" = ps: with ps; [ '.format(component))
+        f.write(' '.join(attr_paths))
+        f.write(' ];\n')
+    f.write('  };\n')
+    f.write('}\n')
diff --git a/pkgs/servers/http/4store/4store-1.1.6-glibc-2.26.patch b/pkgs/servers/http/4store/4store-1.1.6-glibc-2.26.patch
new file mode 100644
index 000000000000..dda21c54f693
--- /dev/null
+++ b/pkgs/servers/http/4store/4store-1.1.6-glibc-2.26.patch
@@ -0,0 +1,12 @@
+diff --git a/src/frontend/filter-datatypes.c b/src/frontend/filter-datatypes.c
+index 8aae1dd..49ed358 100644
+--- a/src/frontend/filter-datatypes.c
++++ b/src/frontend/filter-datatypes.c
+@@ -23,6 +23,7 @@
+ #include <string.h>
+ #include <math.h>
+ #define __USE_MISC
++#define __USE_XOPEN_EXTENDED
+ #include <time.h>
+ 
+ #include "filter.h"
diff --git a/pkgs/servers/http/4store/default.nix b/pkgs/servers/http/4store/default.nix
index 4854f9e18dda..664953ca34dc 100644
--- a/pkgs/servers/http/4store/default.nix
+++ b/pkgs/servers/http/4store/default.nix
@@ -1,48 +1,50 @@
-x@{builderDefsPackage
-  , librdf_raptor, librdf_rasqal,
-  glib, libxml2, pcre, avahi,
-  readline, ncurses, expat,
-  zlib, pkgconfig, which,
-  perl, libuuid, gmp, mpfr
-  , db_dir ? "/var/lib/4store"
-  , ...}:
-builderDefsPackage
-(a :  
-let 
-  s = import ./src-for-default.nix;
-  helperArgNames = ["stdenv" "fetchurl" "builderDefsPackage"] ++ 
-    ["db_dir"];
-  buildInputs = map (n: builtins.getAttr n x)
-    (builtins.attrNames (builtins.removeAttrs x helperArgNames));
-in
-rec {
-  src = a.fetchUrlFromSrcInfo s;
-
-  inherit (s) name;
-  inherit buildInputs;
-
-  /* doConfigure should be removed if not needed */
-  phaseNames = ["doFixConfigure" "doConfigure" "doMakeInstall"
-    "fixInterpreter"];
-
-  doFixConfigure = a.fullDepEntry ''
-    sed -e 's@#! */bin/bash@#! ${a.stdenv.shell}@' -i configure
+{ stdenv, fetchFromGitHub, librdf_raptor
+, librdf_rasqal, glib, libxml2, pcre
+, avahi, readline, ncurses, expat, autoreconfHook
+, zlib, pkgconfig, which, perl, libuuid
+, gmp, mpfr
+, db_dir ? "/var/lib/4store" }:
+
+
+stdenv.mkDerivation rec {
+  name = "4store-${version}";
+  version = "1.1.6";
+
+  src = fetchFromGitHub {
+    owner = "4store";
+    repo = "4store";
+    rev = "v${version}";
+    sha256 = "1kzdfmwpzy64cgqlkcz5v4klwx99w0jk7afckyf7yqbqb4rydmpk";
+  };
+
+  patches = [ ./4store-1.1.6-glibc-2.26.patch ];
+
+  nativeBuildInputs = [ autoreconfHook perl pkgconfig which ];
+
+  buildInputs = [ librdf_raptor librdf_rasqal glib libxml2 pcre
+    avahi readline ncurses expat zlib libuuid gmp mpfr ];
+
+  # needed for ./autogen.sh
+  prePatch = ''
+    echo "${version}" > .version
+  '';
+
+  preConfigure =  ''
+    sed -e 's@#! */bin/bash@#! ${stdenv.shell}@' -i configure
     find . -name Makefile -exec sed -e "s@/usr/local@$out@g" -i '{}' ';'
-    
-    sed -e 's@/var/lib/4store@${db_dir}@g' -i src/common/params.h src/utilities/*
+
+    rm src/utilities/4s-backend
+    sed -e 's@/var/lib/4store@${db_dir}@g' -i configure.ac src/utilities/*
     sed -e '/FS_STORE_ROOT/d' -i src/utilities/Makefile*
-  '' ["minInit" "doUnpack"];
+  '';
+
+  enableParallelBuilding = true;
 
-  fixInterpreter = (a.doPatchShebangs "$out/bin");
-      
-  meta = {
+  meta = with stdenv.lib; {
     description = "SparQL query server (RDF storage)";
-    homepage = http://4store.org/;
-    maintainers = with a.lib.maintainers;
-    [
-      raskin
-    ];
-    platforms = with a.lib.platforms;
-      linux;
+    homepage = https://4store.danielknoell.de/;
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux;
+    broken = true; # since 2018-04-11
   };
-}) x
+}
diff --git a/pkgs/servers/http/apache-httpd/2.2.nix b/pkgs/servers/http/apache-httpd/2.2.nix
deleted file mode 100644
index 99d6fe12aa1c..000000000000
--- a/pkgs/servers/http/apache-httpd/2.2.nix
+++ /dev/null
@@ -1,68 +0,0 @@
-{ stdenv, fetchurl, openssl, perl, zlib
-, sslSupport, proxySupport ? true
-, apr, aprutil, pcre
-, ldapSupport ? true, openldap
-, # Multi-processing module to use.  This is built into the server and
-  # cannot be selected at runtime.
-  mpm ? "prefork"
-}:
-
-assert sslSupport -> openssl != null;
-assert ldapSupport -> aprutil.ldapSupport && openldap != null;
-assert mpm == "prefork" || mpm == "worker" || mpm == "event";
-
-stdenv.mkDerivation rec {
-  version = "2.2.31";
-  name = "apache-httpd-${version}";
-
-  src = fetchurl {
-    url = "mirror://apache/httpd/httpd-${version}.tar.bz2";
-    sha256 = "1b165zi7jrrlz5wmyy3b34lcs3dl4g0dymfb0qxwdnimylcrsbzk";
-  };
-
-  buildInputs = [perl apr aprutil pcre] ++
-    stdenv.lib.optional sslSupport openssl;
-
-  # An apr-util header file includes an apr header file
-  # through #include "" (quotes)
-  # passing simply CFLAGS did not help, then I go by NIX_CFLAGS_COMPILE
-  NIX_CFLAGS_COMPILE = "-iquote ${apr}/include/apr-1";
-
-  # Required for ‘pthread_cancel’.
-  NIX_LDFLAGS = (if stdenv.isDarwin then "" else "-lgcc_s");
-
-  configureFlags = ''
-    --with-z=${zlib}
-    --with-pcre=${pcre}
-    --enable-mods-shared=all
-    --enable-authn-alias
-    ${if proxySupport then "--enable-proxy" else ""}
-    ${if sslSupport then "--enable-ssl --with-ssl=${openssl}" else ""}
-    ${if ldapSupport then "--enable-ldap --enable-authnz-ldap" else ""}
-    --with-mpm=${mpm}
-    --enable-cache
-    --enable-disk-cache
-    --enable-file-cache
-    --enable-mem-cache
-  '';
-
-  enableParallelBuilding = true;
-
-  postInstall = ''
-    echo "removing manual"
-    rm -rf $out/manual
-  '';
-
-  passthru = {
-    inherit apr aprutil sslSupport proxySupport;
-  };
-
-  meta = {
-    description = "Apache HTTPD, the world's most popular web server";
-    branch      = "2.2";
-    homepage    = http://httpd.apache.org/;
-    license     = stdenv.lib.licenses.asl20;
-    platforms   = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
-    maintainers = with stdenv.lib.maintainers; [ eelco simons lovek323 ];
-  };
-}
diff --git a/pkgs/servers/http/apache-httpd/2.4.nix b/pkgs/servers/http/apache-httpd/2.4.nix
index 29f8a9621c9e..dd076606da5b 100644
--- a/pkgs/servers/http/apache-httpd/2.4.nix
+++ b/pkgs/servers/http/apache-httpd/2.4.nix
@@ -1,39 +1,57 @@
-{ stdenv, fetchurl, perl, zlib, apr, aprutil, pcre
+{ stdenv, fetchurl, perl, zlib, apr, aprutil, pcre, libiconv
 , proxySupport ? true
 , sslSupport ? true, openssl
+, http2Support ? true, nghttp2
 , ldapSupport ? true, openldap
 , libxml2Support ? true, libxml2
+, brotliSupport ? true, brotli
 , luaSupport ? false, lua5
 }:
 
-let optional       = stdenv.lib.optional;
-    optionalString = stdenv.lib.optionalString;
+let inherit (stdenv.lib) optional optionalString;
 in
 
 assert sslSupport -> aprutil.sslSupport && openssl != null;
 assert ldapSupport -> aprutil.ldapSupport && openldap != null;
+assert http2Support -> nghttp2 != null;
 
 stdenv.mkDerivation rec {
-  version = "2.4.16";
+  version = "2.4.33";
   name = "apache-httpd-${version}";
 
   src = fetchurl {
     url = "mirror://apache/httpd/httpd-${version}.tar.bz2";
-    sha256 = "0hrpy6gjwma0kba7p7m61vwh82qcnkf08123lrwpg257m93hnrmc";
+    sha256 = "de02511859b00d17845b9abdd1f975d5ccb5d0b280c567da5bf2ad4b70846f05";
   };
 
+  # FIXME: -dev depends on -doc
+  outputs = [ "out" "dev" "man" "doc" ];
+  setOutputFlags = false; # it would move $out/modules, etc.
+
   buildInputs = [perl] ++
+    optional brotliSupport brotli ++
+    optional sslSupport openssl ++
     optional ldapSupport openldap ++    # there is no --with-ldap flag
-    optional libxml2Support libxml2;
+    optional libxml2Support libxml2 ++
+    optional http2Support nghttp2 ++
+    optional stdenv.isDarwin libiconv;
+
+  prePatch = ''
+    sed -i config.layout -e "s|installbuilddir:.*|installbuilddir: $dev/share/build|"
+  '';
 
   # Required for ‘pthread_cancel’.
   NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
 
+  preConfigure = ''
+    configureFlags="$configureFlags --includedir=$dev/include"
+  '';
+
   configureFlags = ''
-    --with-apr=${apr}
-    --with-apr-util=${aprutil}
-    --with-z=${zlib}
-    --with-pcre=${pcre}
+    --with-apr=${apr.dev}
+    --with-apr-util=${aprutil.dev}
+    --with-z=${zlib.dev}
+    --with-pcre=${pcre.dev}
     --disable-maintainer-mode
     --disable-debugger-mode
     --enable-mods-shared=all
@@ -41,19 +59,26 @@ stdenv.mkDerivation rec {
     --enable-cern-meta
     --enable-imagemap
     --enable-cgi
+    ${optionalString brotliSupport "--enable-brotli --with-brotli=${brotli}"}
     ${optionalString proxySupport "--enable-proxy"}
-    ${optionalString sslSupport "--enable-ssl --with-ssl=${openssl}"}
+    ${optionalString sslSupport "--enable-ssl"}
+    ${optionalString http2Support "--enable-http2 --with-nghttp2"}
     ${optionalString luaSupport "--enable-lua --with-lua=${lua5}"}
-    ${optionalString libxml2Support "--with-libxml2=${libxml2}/include/libxml2"}
+    ${optionalString libxml2Support "--with-libxml2=${libxml2.dev}/include/libxml2"}
+    --docdir=$(doc)/share/doc
   '';
 
+  enableParallelBuilding = true;
+
+  stripDebugList = "lib modules bin";
+
   postInstall = ''
-    echo "removing manual"
-    rm -rf $out/manual
+    mkdir -p $doc/share/doc/httpd
+    mv $out/manual $doc/share/doc/httpd
+    mkdir -p $dev/bin
+    mv $out/bin/apxs $dev/bin/apxs
   '';
 
-  enableParallelBuilding = true;
-
   passthru = {
     inherit apr aprutil sslSupport proxySupport ldapSupport;
   };
@@ -63,6 +88,6 @@ stdenv.mkDerivation rec {
     homepage    = http://httpd.apache.org/;
     license     = licenses.asl20;
     platforms   = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
-    maintainers = with maintainers; [ lovek323 simons ];
+    maintainers = with maintainers; [ lovek323 peti ];
   };
 }
diff --git a/pkgs/servers/http/apache-modules/mod_auth_mellon/default.nix b/pkgs/servers/http/apache-modules/mod_auth_mellon/default.nix
new file mode 100644
index 000000000000..8a773631ee6c
--- /dev/null
+++ b/pkgs/servers/http/apache-modules/mod_auth_mellon/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, apacheHttpd, autoconf, automake, autoreconfHook, curl, fetchFromGitHub, glib, lasso, libtool, libxml2, libxslt, openssl, pkgconfig, xmlsec }:
+
+stdenv.mkDerivation rec {
+
+  name = "mod_auth_mellon-${version}";
+  version = "0.13.1";
+
+  src = fetchFromGitHub {
+    owner = "UNINETT";
+    repo = "mod_auth_mellon";
+    rev = "v${version}";
+    sha256 = "16b43y5a5p8g1287x04rv923230cy8dfs2j18cx6208n4bv4dvnk";
+  };
+
+  patches = [
+    ./fixdeps.patch
+  ];
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ apacheHttpd autoconf automake curl glib lasso libtool libxml2 libxslt openssl xmlsec ];
+
+  configureFlags = ["--with-apxs2=${apacheHttpd.dev}/bin/apxs" "--exec-prefix=$out"];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ./mellon_create_metadata.sh $out/bin
+    mkdir -p $out/modules
+    cp ./.libs/mod_auth_mellon.so $out/modules
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/UNINETT/mod_auth_mellon;
+    description = "An Apache module with a simple SAML 2.0 service provider";
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ womfoo ];
+  };
+
+}
diff --git a/pkgs/servers/http/apache-modules/mod_auth_mellon/fixdeps.patch b/pkgs/servers/http/apache-modules/mod_auth_mellon/fixdeps.patch
new file mode 100644
index 000000000000..63b69fb142f6
--- /dev/null
+++ b/pkgs/servers/http/apache-modules/mod_auth_mellon/fixdeps.patch
@@ -0,0 +1,30 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -74,6 +74,16 @@ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.12])
+ AC_SUBST(GLIB_CFLAGS)
+ AC_SUBST(GLIB_LIBS)
+ 
++#include <libxml/uri.h>
++PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
++AC_SUBST(LIBXML2_CFLAGS)
++AC_SUBST(LIBXML2_LIBS)
++
++#include <xmlsec/xmlenc.h>
++PKG_CHECK_MODULES(XMLSEC, xmlsec1-openssl)
++AC_SUBST(XMLSEC_CFLAGS)
++AC_SUBST(XMLSEC_LIBS)
++
+ # Test to see if we can include lasso/utils.h
+ # AC_CHECK_HEADER won't work correctly unless we specifiy the include directories
+ # found in the LASSO_CFLAGS. Save and restore CFLAGS and CPPFLAGS.
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -25,7 +25,7 @@
+ all:	mod_auth_mellon.la
+ 
+ mod_auth_mellon.la: $(SRC) auth_mellon.h auth_mellon_compat.h
+-	@APXS2@ -Wc,"-std=c99 @OPENSSL_CFLAGS@ @LASSO_CFLAGS@ @CURL_CFLAGS@ @GLIB_CFLAGS@ @CFLAGS@" -Wl,"@OPENSSL_LIBS@ @LASSO_LIBS@ @CURL_LIBS@ @GLIB_LIBS@" -Wc,-Wall -Wc,-g -c $(SRC)
++	@APXS2@ -Wc,"-std=c99 @OPENSSL_CFLAGS@ @LASSO_CFLAGS@ @CURL_CFLAGS@ @GLIB_CFLAGS@ @CFLAGS@ @LIBXML2_CFLAGS@ @XMLSEC_CFLAGS@ @CFLAGS@" -Wl,"@OPENSSL_LIBS@ @LASSO_LIBS@ @CURL_LIBS@ @GLIB_LIBS@ @LIBXML2_LIBS@ @XMLSEC_LIBS@" -Wc,-Wall -Wc,-g -c $(SRC)
+ 
+ 
+ # Building configure (for distribution)
diff --git a/pkgs/servers/http/apache-modules/mod_dnssd/default.nix b/pkgs/servers/http/apache-modules/mod_dnssd/default.nix
index 06f12820a10d..d681146eee5d 100644
--- a/pkgs/servers/http/apache-modules/mod_dnssd/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_dnssd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, apacheHttpd_2_2, apr, avahi }:
+{ stdenv, fetchurl, fetchpatch, pkgconfig, apacheHttpd, apr, avahi }:
 
 stdenv.mkDerivation rec {
   name = "mod_dnssd-0.6";
@@ -10,7 +10,13 @@ stdenv.mkDerivation rec {
 
   configureFlags = [ "--disable-lynx" ];
 
-  buildInputs = [ pkgconfig apacheHttpd_2_2 avahi apr ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ apacheHttpd avahi apr ];
+
+  patches = [ (fetchpatch {
+    url = "http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/vivid/mod-dnssd/vivid/download/package-import%40ubuntu.com-20130530193334-kqebiy78q534or5k/portforapache2.4.pat-20130530222510-7tlw5btqchd04edb-3/port-for-apache2.4.patch";
+    sha256 = "1hgcxwy1q8fsxfqyg95w8m45zbvxzskf1jxd87ljj57l7x1wwp4r";
+  }) ];
 
   installPhase = ''
     mkdir -p $out/modules
@@ -25,4 +31,3 @@ stdenv.mkDerivation rec {
     maintainers = with maintainers; [ lethalman ];
   };
 }
-
diff --git a/pkgs/servers/http/apache-modules/mod_evasive/default.nix b/pkgs/servers/http/apache-modules/mod_evasive/default.nix
index c89e4100d38b..2b8693f7379d 100644
--- a/pkgs/servers/http/apache-modules/mod_evasive/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_evasive/default.nix
@@ -28,7 +28,7 @@ stdenv.mkDerivation {
   '';
 
   meta = {
-    homepage = "http://www.zdziarski.com/blog/?page_id=442";
+    homepage = http://www.zdziarski.com/blog/?page_id=442;
     description = "Evasive maneuvers module for Apache to provide evasive action in the event of an HTTP DoS or DDoS attack or brute force attack";
     platforms = stdenv.lib.platforms.linux;
   };
diff --git a/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix b/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix
index e70c3105408f..647589621029 100644
--- a/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_fastcgi/default.nix
@@ -20,11 +20,11 @@ stdenv.mkDerivation rec {
 
   preBuild = ''
     cp Makefile.AP2 Makefile
-    makeFlags="top_dir=${apacheHttpd} prefix=$out"
+    makeFlags="top_dir=${apacheHttpd.dev}/share prefix=$out"
   '';
 
   meta = {
-    homepage = "http://www.fastcgi.com/";
+    homepage = http://www.fastcgi.com/;
     description = "Provide support for the FastCGI protocol";
 
     longDescription = ''
@@ -39,6 +39,6 @@ stdenv.mkDerivation rec {
     '';
 
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    maintainers = [ stdenv.lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/servers/http/apache-modules/mod_perl/default.nix b/pkgs/servers/http/apache-modules/mod_perl/default.nix
new file mode 100644
index 000000000000..04746d678c52
--- /dev/null
+++ b/pkgs/servers/http/apache-modules/mod_perl/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, apacheHttpd, perl }:
+
+stdenv.mkDerivation rec {
+  name = "mod_perl-2.0.10";
+
+  src = fetchurl {
+    url = "mirror://apache/perl/${name}.tar.gz";
+    sha256 = "0r1bhzwl5gr0202r6448943hjxsickzn55kdmb7dzad39vnq7kyi";
+  };
+
+  buildInputs = [ apacheHttpd perl ];
+  buildPhase = ''
+    perl Makefile.PL \
+      MP_APXS=${apacheHttpd.dev}/bin/apxs
+    make
+  '';
+  installPhase = ''
+    mkdir -p $out
+    make install DESTDIR=$out
+    mv $out${apacheHttpd}/* $out
+    mv $out${apacheHttpd.dev}/* $out
+    mv $out${perl}/* $out
+    rm $out/nix -rf
+  '';
+}
diff --git a/pkgs/servers/http/apache-modules/mod_python/default.nix b/pkgs/servers/http/apache-modules/mod_python/default.nix
index d156576b21a8..f947bf535cc9 100644
--- a/pkgs/servers/http/apache-modules/mod_python/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_python/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, apacheHttpd, python }:
+{ stdenv, fetchurl, apacheHttpd, python2 }:
 
 stdenv.mkDerivation rec {
   name = "mod_python-3.5.0";
@@ -23,10 +23,11 @@ stdenv.mkDerivation rec {
 
   passthru = { inherit apacheHttpd; };
 
-  buildInputs = [ apacheHttpd python ];
+  buildInputs = [ apacheHttpd python2 ];
 
   meta = {
     homepage = http://modpython.org/;
     description = "An Apache module that embeds the Python interpreter within the server";
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/servers/http/apache-modules/mod_wsgi/default.nix b/pkgs/servers/http/apache-modules/mod_wsgi/default.nix
index 7aded47dad18..948ef345e10d 100644
--- a/pkgs/servers/http/apache-modules/mod_wsgi/default.nix
+++ b/pkgs/servers/http/apache-modules/mod_wsgi/default.nix
@@ -1,15 +1,15 @@
-{ stdenv, fetchurl, apacheHttpd, python }:
+{ stdenv, fetchurl, apacheHttpd, python2 }:
 
 stdenv.mkDerivation rec {
   name = "mod_wsgi-${version}";
-  version = "3.5";
+  version = "4.6.4";
 
   src = fetchurl {
     url = "https://github.com/GrahamDumpleton/mod_wsgi/archive/${version}.tar.gz";
-    sha256 = "14xz422jlakdhxzsl8xs9if86yf1fnkwdg0havjyqs7my0w4qrzh";
+    sha256 = "1hyaxr9km7cj4k6b0d6xx3bplpa8483fhyk9x802sl22m3f2vc1k";
   };
 
-  buildInputs = [ apacheHttpd python ];
+  buildInputs = [ apacheHttpd python2 ];
 
   patchPhase = ''
     sed -r -i -e "s|^LIBEXECDIR=.*$|LIBEXECDIR=$out/modules|" \
@@ -18,11 +18,9 @@ stdenv.mkDerivation rec {
   '';
 
   meta = {
-    homepage = http://code.google.com/p/modwsgi/;
+    homepage = https://github.com/GrahamDumpleton/mod_wsgi;
     description = "Host Python applications in Apache through the WSGI interface";
     license = stdenv.lib.licenses.asl20;
-
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.simons ];
   };
 }
diff --git a/pkgs/servers/http/apache-modules/tomcat-connectors/default.nix b/pkgs/servers/http/apache-modules/tomcat-connectors/default.nix
index 90d0fb899c31..5768e7badea0 100644
--- a/pkgs/servers/http/apache-modules/tomcat-connectors/default.nix
+++ b/pkgs/servers/http/apache-modules/tomcat-connectors/default.nix
@@ -8,9 +8,11 @@ stdenv.mkDerivation rec {
     sha256 = "11khipjpy3y84j1pp7yyx76y64jccvyhh3klwzqxylff49vjc2fc";
   };
 
-  configureFlags = "--with-apxs=${apacheHttpd}/bin/apxs --with-java-home=${jdk}";
+  configureFlags = "--with-apxs=${apacheHttpd.dev}/bin/apxs --with-java-home=${jdk}";
 
-  sourceRoot = "${name}-src/native";
+  setSourceRoot = ''
+    sourceRoot=$(echo */native)
+  '';
 
   installPhase = ''
     mkdir -p $out/modules
@@ -18,4 +20,8 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs = [ apacheHttpd jdk ];
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
 }
diff --git a/pkgs/servers/http/apt-cacher-ng/default.nix b/pkgs/servers/http/apt-cacher-ng/default.nix
new file mode 100644
index 000000000000..415b1fb48a2a
--- /dev/null
+++ b/pkgs/servers/http/apt-cacher-ng/default.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, bzip2
+, cmake
+, doxygen
+, fetchurl
+, fuse
+, lzma
+, openssl
+, pkgconfig
+, systemd
+, tcp_wrappers
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  name = "apt-cacher-ng-${version}";
+  version = "3.1";
+
+  src = fetchurl {
+    url = "http://ftp.debian.org/debian/pool/main/a/apt-cacher-ng/apt-cacher-ng_${version}.orig.tar.xz";
+    sha256 = "0p8cdig70vz1dgw2v8brjin5wqrk8amncphyf11f53bza5grlc91";
+  };
+
+  nativeBuildInputs = [ cmake doxygen pkgconfig ];
+  buildInputs = [ bzip2 fuse lzma openssl systemd tcp_wrappers zlib ];
+
+  meta = with stdenv.lib; {
+    description = "A caching proxy specialized for linux distribution files";
+    homepage = https://www.unix-ag.uni-kl.de/~bloch/acng/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.makefu ];
+  };
+}
diff --git a/pkgs/servers/http/couchdb/2.0.0.nix b/pkgs/servers/http/couchdb/2.0.0.nix
new file mode 100644
index 000000000000..f94ff56373d4
--- /dev/null
+++ b/pkgs/servers/http/couchdb/2.0.0.nix
@@ -0,0 +1,54 @@
+{ stdenv, fetchurl, erlang, icu, openssl, spidermonkey
+, coreutils, bash, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "couchdb-${version}";
+  version = "2.1.1";
+
+  src = fetchurl {
+    url = "mirror://apache/couchdb/source/${version}/apache-${name}.tar.gz";
+    sha256 = "1k3v9v05417087b6fcj5yv03wl6i61xqrrhp0prl9b3ir2mmbwnm";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ erlang icu openssl spidermonkey ];
+
+  patches = [ ./jsapi.patch ];
+  postPatch = ''
+    substituteInPlace src/couch/rebar.config.script --replace '-DHAVE_CURL -I/usr/local/include' "-DHAVE_CURL -I/usr/local/include $NIX_CFLAGS_COMPILE"
+
+    patch bin/rebar <<EOF
+    1c1
+    < #!/usr/bin/env escript
+    ---
+    > #!${coreutils}/bin/env escript
+    EOF
+
+  '';
+
+  # Configure a username.  The build system would use "couchdb" as
+  # default if none is provided.  Note that it is unclear where this
+  # username is actually used in the build, as any choice seems to be
+  # working.
+  configurePhase = ''
+    ./configure -u nobody
+  '';
+
+  buildPhase = ''
+    make release
+  '';
+
+  installPhase = ''
+    mkdir -p $out
+    cp -r rel/couchdb/* $out
+    wrapProgram $out/bin/couchdb --suffix PATH : ${bash}/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A database that uses JSON for documents, JavaScript for MapReduce queries, and regular HTTP for an API";
+    homepage = http://couchdb.apache.org;
+    license = licenses.asl20;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ garbas ];
+  };
+}
diff --git a/pkgs/servers/http/couchdb/default.nix b/pkgs/servers/http/couchdb/default.nix
index 54412d2ab400..43334819dc56 100644
--- a/pkgs/servers/http/couchdb/default.nix
+++ b/pkgs/servers/http/couchdb/default.nix
@@ -3,30 +3,18 @@
 
 stdenv.mkDerivation rec {
   name = "couchdb-${version}";
-  version = "1.6.1";
+  version = "1.7.1";
 
   src = fetchurl {
     url = "mirror://apache/couchdb/source/${version}/apache-${name}.tar.gz";
-    sha256 = "09w6ijj9l5jzh81nvc3hrlqp345ajg3haj353g9kxkik6wbinq2s";
+    sha256 = "1b9cbdrmh1i71mrwvhm17v4cf7lckpil1vvq7lpmxyn6zfk0l84i";
   };
 
-  buildInputs = [ erlang icu openssl spidermonkey curl help2man sphinx which
-    file pkgconfig ];
-
-  /* This patch removes the `-Werror` flag as there are warnings due to
-   * _BSD_SOURCE being deprecated in glibc >= 2.20
-   */
-  patchPhase = ''
-    patch src/couchdb/priv/Makefile.in <<EOF
-    392c392
-    < couchjs_CFLAGS = -g -Wall -Werror -D_BSD_SOURCE \$(CURL_CFLAGS) \$(JS_CFLAGS)
-    ---
-    > couchjs_CFLAGS = -g -Wall -D_BSD_SOURCE \$(CURL_CFLAGS) \$(JS_CFLAGS)
-    EOF
-  '';
+  nativeBuildInputs = [ help2man which file pkgconfig sphinx ];
+  buildInputs = [ erlang icu openssl spidermonkey curl ];
 
   postInstall = ''
-    sed -i -e "s|\`getopt|\`${getopt}/bin/getopt|" $out/bin/couchdb
+    substituteInPlace $out/bin/couchdb --replace getopt "${getopt}/bin/getopt"
   '';
 
   /*
@@ -41,10 +29,11 @@ stdenv.mkDerivation rec {
     --enable-js-trunk
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "A database that uses JSON for documents, JavaScript for MapReduce queries, and regular HTTP for an API";
-    homepage = "http://couchdb.apache.org";
-    license = stdenv.lib.licenses.asl20;
-    maintainers = with stdenv.lib.maintainers; [ viric garbas ];
+    homepage = http://couchdb.apache.org;
+    license = licenses.asl20;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ garbas ];
   };
 }
diff --git a/pkgs/servers/http/couchdb/jsapi.patch b/pkgs/servers/http/couchdb/jsapi.patch
new file mode 100644
index 000000000000..bb7d4ca610c7
--- /dev/null
+++ b/pkgs/servers/http/couchdb/jsapi.patch
@@ -0,0 +1,60 @@
+diff -ru couch_js/http.c couch_js-patched/http.c
+--- apache-couchdb-2.0.0/src/couch/priv/couch_js/http.c	2016-09-12 11:28:51.000000000 +0200
++++ apache-couchdb-2.0.0-patched/src/couch/priv/couch_js/http.c	2017-02-10 10:52:33.025854045 +0100
+@@ -15,7 +15,7 @@
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+-#include <jsapi.h>
++#include <js/jsapi.h>
+ #include "config.h"
+ #include "utf8.h"
+ #include "util.h"
+diff -ru couch_js/main.c couch_js-patched/main.c
+--- apache-couchdb-2.0.0/src/couch/priv/couch_js/main.c	2016-09-12 11:28:51.000000000 +0200
++++ apache-couchdb-2.0.0-patched/src/couch/priv/couch_js/main.c	2017-02-10 10:52:33.001854154 +0100
+@@ -20,7 +20,7 @@
+ #include <unistd.h>
+ #endif
+ 
+-#include <jsapi.h>
++#include <js/jsapi.h>
+ #include "config.h"
+ #include "http.h"
+ #include "utf8.h"
+diff -ru couch_js/utf8.c couch_js-patched/utf8.c
+--- apache-couchdb-2.0.0/src/couch/priv/couch_js/utf8.c	2016-09-12 11:28:51.000000000 +0200
++++ apache-couchdb-2.0.0-patched/src/couch/priv/couch_js/utf8.c	2017-02-10 10:52:33.009854117 +0100
+@@ -10,7 +10,7 @@
+ // License for the specific language governing permissions and limitations under
+ // the License.
+ 
+-#include <jsapi.h>
++#include <js/jsapi.h>
+ #include "config.h"
+ 
+ static int
+diff -ru couch_js/util.c couch_js-patched/util.c
+--- apache-couchdb-2.0.0/src/couch/priv/couch_js/util.c	2016-09-12 11:28:51.000000000 +0200
++++ apache-couchdb-2.0.0-patched/src/couch/priv/couch_js/util.c	2017-02-10 10:52:33.017854081 +0100
+@@ -13,7 +13,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
+-#include <jsapi.h>
++#include <js/jsapi.h>
+ 
+ #include "help.h"
+ #include "util.h"
+diff -ru couch_js/util.h couch_js-patched/util.h
+--- apache-couchdb-2.0.0/src/couch/priv/couch_js/util.h	2016-09-12 11:28:51.000000000 +0200
++++ apache-couchdb-2.0.0-patched/src/couch/priv/couch_js/util.h	2017-02-10 10:52:32.988854212 +0100
+@@ -13,7 +13,7 @@
+ #ifndef COUCHJS_UTIL_H
+ #define COUCHJS_UTIL_H
+ 
+-#include <jsapi.h>
++#include <js/jsapi.h>
+ 
+ typedef struct {
+     int          no_eval;
diff --git a/pkgs/servers/http/darkhttpd/default.nix b/pkgs/servers/http/darkhttpd/default.nix
new file mode 100644
index 000000000000..3efc97f6296b
--- /dev/null
+++ b/pkgs/servers/http/darkhttpd/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "darkhttpd-${version}";
+  version = "1.12";
+
+  src = fetchurl {
+    url = "https://unix4lyfe.org/darkhttpd/${name}.tar.bz2";
+    sha256 = "0185wlyx4iqiwfigp1zvql14zw7gxfacncii3d15yaxk4av1f155";
+  };
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    # install darkhttpd
+    install -Dm755 "darkhttpd" "$out/bin/darkhttpd"
+
+    # install license
+    install -d "$out/share/licenses/darkhttpd"
+    head -n 18 darkhttpd.c > "$out/share/licenses/darkhttpd/LICENSE"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Small and secure static webserver";
+    homepage    = https://unix4lyfe.org/darkhttpd/;
+    license     = licenses.bsd3;
+    maintainers = with maintainers; [ bobvanderlinden ];
+    platforms   = platforms.all;
+  };
+}
diff --git a/pkgs/servers/http/gatling/default.nix b/pkgs/servers/http/gatling/default.nix
new file mode 100644
index 000000000000..19b2d01f5be8
--- /dev/null
+++ b/pkgs/servers/http/gatling/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, libowfat, zlib, openssl }:
+
+let
+  version = "0.15";
+in
+stdenv.mkDerivation rec {
+  name = "gatling-${version}";
+
+  src = fetchurl {
+    url = "https://www.fefe.de/gatling/${name}.tar.xz";
+    sha256 = "194srqyja3pczpbl6l169zlvx179v7ln0m6yipmhvj6hrv82k8vg";
+  };
+
+  buildInputs = [  libowfat zlib openssl.dev ];
+
+  configurePhase = ''
+    substituteInPlace Makefile --replace "/usr/local" "$out"
+    substituteInPlace GNUmakefile --replace "/opt/diet" "$out"
+  '';
+
+  buildPhase = ''
+    make gatling
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A high performance web server";
+    homepage = http://www.fefe.de/gatling/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.the-kenny ];
+  };
+}
diff --git a/pkgs/servers/http/h2o/default.nix b/pkgs/servers/http/h2o/default.nix
new file mode 100644
index 000000000000..e05624fa46c8
--- /dev/null
+++ b/pkgs/servers/http/h2o/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub
+, pkgconfig, cmake
+, libressl_2_6, libuv, zlib
+}:
+
+with builtins;
+
+stdenv.mkDerivation rec {
+  name = "h2o-${version}";
+  version = "2.2.5";
+
+  src = fetchFromGitHub {
+    owner  = "h2o";
+    repo   = "h2o";
+    rev    = "refs/tags/v${version}";
+    sha256 = "0jyvbp6cjiirj44nxqa2fi5y473gnc8awfn8zv82hb1y9rlxqfyv";
+  };
+
+  nativeBuildInputs = [ pkgconfig cmake ];
+  buildInputs = [ libressl_2_6 libuv zlib ];
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Optimized HTTP/1 and HTTP/2 server";
+    homepage    = https://h2o.examp1e.net;
+    license     = stdenv.lib.licenses.mit;
+    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    platforms   = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/servers/http/hiawatha/default.nix b/pkgs/servers/http/hiawatha/default.nix
new file mode 100644
index 000000000000..39722c6d831f
--- /dev/null
+++ b/pkgs/servers/http/hiawatha/default.nix
@@ -0,0 +1,55 @@
+{ stdenv
+, fetchFromGitLab
+
+, cmake
+, ninja
+
+, libxslt
+, libxml2
+
+, enableSSL ? true
+, enableMonitor ? false
+, enableRproxy ? true
+, enableTomahawk ? false
+, enableXSLT ? true
+, enableToolkit ? true
+}:
+
+stdenv.mkDerivation rec {
+  name = "hiawatha-${version}";
+  version = "10.8.1";
+
+  src = fetchFromGitLab {
+    owner = "hsleisink";
+    repo = "hiawatha";
+    rev = "v${version}";
+    sha256 = "1428byx0xpzzwyc0j157q70sjx18dykvg6fd5vp70kj85ank0xpa";
+  };
+
+  nativeBuildInputs = [ cmake ninja ];
+  buildInputs = [ libxslt libxml2 ];
+
+  prePatch = ''
+    substituteInPlace CMakeLists.txt --replace SETUID ""
+  '';
+
+  cmakeFlags = [
+    (
+      # FIXME: 2018-06-08: Uses bundled library, with external ("-DUSE_SYSTEM_MBEDTLS=on") asks:
+      # ../src/tls.c:46:2: error: #error "The mbed TLS library must be compiled with MBEDTLS_THREADING_PTHREAD and MBEDTLS_THREADING_C enabled."
+      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" )
+  ];
+
+  meta = with stdenv.lib; {
+    description = "An advanced and secure webserver";
+    license = licenses.gpl2;
+    homepage = https://www.hiawatha-webserver.org;
+    maintainers = [ maintainers.ndowens ];
+  };
+
+}
diff --git a/pkgs/servers/http/hyp/default.nix b/pkgs/servers/http/hyp/default.nix
new file mode 100644
index 000000000000..3a1eb50f05be
--- /dev/null
+++ b/pkgs/servers/http/hyp/default.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchurl, python3Packages }:
+
+python3Packages.buildPythonPackage rec {
+  name = "hyp-server-${version}";
+  version = "1.2.0";
+
+  src = fetchurl {
+    url    = "mirror://pypi/h/hyp-server/${name}.tar.gz";
+    sha256 = "1lafjdcn9nnq6xc3hhyizfwh6l69lc7rixn6dx65aq71c913jc15";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Hyperminimal https server";
+    homepage    = https://github.com/rnhmjoj/hyp;
+    license     = with licenses; [gpl3Plus mit];
+    maintainers = with maintainers; [ rnhmjoj ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/http/jboss/default.nix b/pkgs/servers/http/jboss/default.nix
index d0d336ad08e6..068053d71f09 100644
--- a/pkgs/servers/http/jboss/default.nix
+++ b/pkgs/servers/http/jboss/default.nix
@@ -21,5 +21,9 @@ stdenv.mkDerivation {
     description = "Open Source J2EE application server";
     license = licenses.lgpl21;
     maintainers = [ maintainers.sander ];
+    platforms = platforms.unix;
+    knownVulnerabilities = [
+      "CVE-2015-7501: remote code execution in apache-commons-collections: InvokerTransformer during deserialisation"
+    ];
   };
 }
diff --git a/pkgs/servers/http/jboss/jdbc/mysql/default.nix b/pkgs/servers/http/jboss/jdbc/mysql/default.nix
index 8544ce050afd..dbc5c73414cd 100644
--- a/pkgs/servers/http/jboss/jdbc/mysql/default.nix
+++ b/pkgs/servers/http/jboss/jdbc/mysql/default.nix
@@ -6,4 +6,8 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
 
   inherit mysql_jdbc;
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
 }
diff --git a/pkgs/servers/http/jetty/6.1/bin-builder.sh b/pkgs/servers/http/jetty/6.1/bin-builder.sh
deleted file mode 100644
index bec0663bee78..000000000000
--- a/pkgs/servers/http/jetty/6.1/bin-builder.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-set -e
-
-source $stdenv/setup
-
-unzip $src
-mkdir -p $out/$name
-mv jetty*/* $out/$name
diff --git a/pkgs/servers/http/jetty/6.1/default.nix b/pkgs/servers/http/jetty/6.1/default.nix
deleted file mode 100644
index 894a21fdece9..000000000000
--- a/pkgs/servers/http/jetty/6.1/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, unzip}:
-
-stdenv.mkDerivation {
-  name = "jetty-6.1.26";
-
-  builder = ./bin-builder.sh;
-  buildInputs = [unzip];
-
-  src = fetchurl {
-    url = http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26.zip;
-    sha256 = "11w1ciayv8zvxjg45xzs0kwc7k45x97sbnxkqb62sxy3gsw8xh4n";
-  };
-}
diff --git a/pkgs/servers/http/jetty/9.2.nix b/pkgs/servers/http/jetty/9.2.nix
deleted file mode 100644
index 7bef32f3db2a..000000000000
--- a/pkgs/servers/http/jetty/9.2.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ stdenv, fetchurl }:
-
-stdenv.mkDerivation rec {
-  name = "jetty-9.2.5";
-
-  src = fetchurl {
-    url = "http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.2.11.v20150529.tar.gz&r=1";
-    name = "jetty-distribution-9.2.11.v20150529.tar.gz";
-    sha256 = "1d9s9l64b1l3x6vkx8qwgzfqwm55iq5g9xjjm2h2akf494yx1mrd";
-  };
-
-  phases = [ "unpackPhase" "installPhase" ];
-
-  installPhase = ''
-    mkdir -p $out
-    mv etc lib modules start.jar $out
-  '';
-
-  meta = {
-    description = "A Web server and javax.servlet container";
-
-    homepage = http://www.eclipse.org/jetty/;
-
-    platforms = stdenv.lib.platforms.all;
-
-    license = [ stdenv.lib.licenses.asl20 stdenv.lib.licenses.epl10 ];
-  };
-}
diff --git a/pkgs/servers/http/jetty/bin-builder.sh b/pkgs/servers/http/jetty/bin-builder.sh
deleted file mode 100644
index 1da42099dca4..000000000000
--- a/pkgs/servers/http/jetty/bin-builder.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-set -e
-
-source $stdenv/setup
-
-unzip $src
-mkdir $out
-mv jetty*/* $out
diff --git a/pkgs/servers/http/jetty/default.nix b/pkgs/servers/http/jetty/default.nix
index 78b6e4cc7eee..1e99aab24c60 100644
--- a/pkgs/servers/http/jetty/default.nix
+++ b/pkgs/servers/http/jetty/default.nix
@@ -1,13 +1,25 @@
-{stdenv, fetchurl, unzip}:
+{ stdenv, fetchurl }:
 
-stdenv.mkDerivation {
-  name = "jetty-6.1.4";
+stdenv.mkDerivation rec {
+  name = "jetty-${version}";
+  version = "9.4.8.v20171121";
+  src = fetchurl {
+    url = "http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${version}/jetty-distribution-${version}.tar.gz";
+    name = "jetty-distribution-${version}.tar.gz";
+    sha256 = "0bvwi70vdk468yqgvgq99lwrpy2y5znrl0b1cr8j6ygmsgnvvmjh";
+  };
 
-  builder = ./bin-builder.sh;
-  buildInputs = [unzip];
+  phases = [ "unpackPhase" "installPhase" ];
 
-  src = fetchurl {
-    url = mirror://sourceforge/jetty/jetty-6.1.4.zip;
-    sha256 = "061cx442g5a5szzms9zhnfmr4aipmqyy9r8m5r84gr79gz9z6dv0";
+  installPhase = ''
+    mkdir -p $out
+    mv etc lib modules start.ini start.jar $out
+  '';
+
+  meta = {
+    description = "A Web server and javax.servlet container";
+    homepage = http://www.eclipse.org/jetty/;
+    platforms = stdenv.lib.platforms.all;
+    license = [ stdenv.lib.licenses.asl20 stdenv.lib.licenses.epl10 ];
   };
 }
diff --git a/pkgs/servers/http/joseki/default.nix b/pkgs/servers/http/joseki/default.nix
deleted file mode 100644
index 59f9fd8624d1..000000000000
--- a/pkgs/servers/http/joseki/default.nix
+++ /dev/null
@@ -1,112 +0,0 @@
-x@{builderDefsPackage
-  , unzip
-  , ...}:
-builderDefsPackage
-(a :
-let
-  helperArgNames = ["stdenv" "fetchurl" "builderDefsPackage"] ++
-    [];
-
-  buildInputs = map (n: builtins.getAttr n x)
-    (builtins.attrNames (builtins.removeAttrs x helperArgNames));
-  sourceInfo = rec {
-    baseName="jena-joseki";
-    version="3.4.3-201103";
-    name="${baseName}-${version}";
-  };
-in
-rec {
-  inherit (sourceInfo) name version;
-  inherit buildInputs;
-
-  tarballs = {
-    jenaBin = a.fetchurl {
-      url = "mirror://sourceforge/project/jena/Jena/Jena-2.6.4/jena-2.6.4.zip";
-      sha256 = "ec23a24eee9148b1ddb366ab035a48eacd43c2b50c534a7bdd9cf31c6f8a9e7c";
-    };
-    josekiBin = a.fetchurl {
-      url = "mirror://sourceforge/project/joseki/Joseki-SPARQL/Joseki-3.4.3/joseki-3.4.3.zip";
-      sha256 = "cde1138e7bafcc2db7800dcde08f268237accd76c0a3e4b4c95cc96eacdcad12";
-    };
-    tdbBin = a.fetchurl {
-      url = "mirror://sourceforge/project/jena/TDB/TDB-0.8.9/tdb-0.8.9.zip";
-      sha256 = "78fd4b6cea5a6e412f1d58ba8a9e1fc72315becdf06f3675e4e604cd4435779e";
-    };
-    arqBin = a.fetchurl {
-      url = "mirror://sourceforge/project/jena/ARQ/ARQ-2.8.7/arq-2.8.7.zip";
-      sha256 = "66990e92514a85a9596a7efaf128041002cd098e063964dd5d2264cfcdd26070";
-    };
-    jettyBin = a.fetchurl {
-      url = "http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26.zip";
-      sha256 = "96c08eb87ec3772dccc2b3dba54fea85ccc3f804faf7429eecfba3ed55648187";
-    };
-  };
-  tarballFiles = map (x: builtins.getAttr x tarballs) (builtins.attrNames tarballs);
-
-  /* doConfigure should be removed if not needed */
-  phaseNames = ["doDeploy" "fixScripts"];
-
-  fixScripts = a.doPatchShebangs ''$TARGET/bin'';
-
-  doDeploy = a.fullDepEntry (''
-    ${a.lib.concatStringsSep ";" (map (y : "unzip ${y}") tarballFiles)}
-    for i in */; do cp -rTf $i merged; done
-    cd merged
-
-    for i in "lib/"jsp-*/*.jar; do
-      ln -s "''${i#lib/}" "lib" || true
-    done
-
-    cp [Cc]opyright* doc
-    mkdir lib/obsolete
-    (
-      ls "lib/"log4j-[0-9]*.jar | sort | tac | tail -n +2 ;
-      ls "lib/"slf4j-api-[0-9]*.jar | sort | tac | tail -n +2 ;
-      ls "lib/"xercesImpl-[0-9]*.jar | sort | tac | tail -n +2 ;
-      ls "lib/"arq-[0-9]*.jar | sort | tac | tail -n +2
-      ls "lib/"tdb-[0-9]*.jar | sort | tac | tail -n +2
-      ls "lib/"jetty-[0-9]*.jar | sort | tac | tail -n +2
-      ls "lib/"jetty-util-[0-9]*.jar | sort | tac | tail -n +2
-    ) |
-      xargs -I @@ mv @@  lib/obsolete
-
-    mv lib/slf4j-simple-*.jar lib/obsolete
-
-    mkdir -p "$out/share"
-    TARGET="$out/share/${name}-dist"
-    cp -r . "$TARGET"
-    ln -s  "$TARGET/lib" "$out/lib"
-    chmod a+x "$TARGET/bin/"*
-    mkdir -p "$out/bin"
-
-    sed -e 's/\r//g' -i "$TARGET/bin"/*
-
-    echo -e '#! ${a.stdenv.shell}\nls "'"$TARGET"'"/bin' > "$out/bin/jena-list-commands"
-    echo '#! ${a.stdenv.shell}' >> "$out/bin/jena-command"
-    echo 'export JENAROOT="'"$TARGET"'"' >> "$out/bin/jena-command"
-    echo 'export JOSEKIROOT="'"$TARGET"'"' >> "$out/bin/jena-command"
-    echo 'export TDBROOT="'"$TARGET"'"' >> "$out/bin/jena-command"
-    echo 'export ARQROOT="'"$TARGET"'"' >> "$out/bin/jena-command"
-    echo 'sh "'"$TARGET"'"/bin/"$@"' >> "$out/bin/jena-command"
-
-    chmod a+x "$out/bin/"*
-  '') ["defEnsureDir" "minInit" "addInputs"];
-
-  trimVersions = a.fullDepEntry (''
-  '') ["doDeploy" "minInit"];
-
-  passthru = {
-    inherit tarballs;
-  };
-
-  meta = {
-    description = "An RDF database with SparQL interface over HTTP";
-    maintainers = with a.lib.maintainers;
-    [
-      raskin
-    ];
-    hydraPlatforms = []; # Builder is just unpacking/mixing what is needed
-    license = a.lib.licenses.free; # mix of packages under different licenses
-    homepage = "http://openjena.org/";
-  };
-}) x
diff --git a/pkgs/servers/http/lighttpd/default.nix b/pkgs/servers/http/lighttpd/default.nix
index 60848516155d..31b3449d5f64 100644
--- a/pkgs/servers/http/lighttpd/default.nix
+++ b/pkgs/servers/http/lighttpd/default.nix
@@ -1,31 +1,52 @@
 { stdenv, fetchurl, pkgconfig, pcre, libxml2, zlib, attr, bzip2, which, file
 , openssl, enableMagnet ? false, lua5_1 ? null
 , enableMysql ? false, mysql ? null
+, enableLdap ? false, openldap ? null
+, enableWebDAV ? true, sqlite ? null, libuuid ? null
 }:
 
 assert enableMagnet -> lua5_1 != null;
 assert enableMysql -> mysql != null;
+assert enableLdap -> openldap != null;
+assert enableWebDAV -> sqlite != null;
+assert enableWebDAV -> libuuid != null;
 
 stdenv.mkDerivation rec {
-  name = "lighttpd-1.4.37";
+  name = "lighttpd-1.4.49";
 
   src = fetchurl {
     url = "http://download.lighttpd.net/lighttpd/releases-1.4.x/${name}.tar.xz";
-    sha256 = "1gbri5avg1jv2g585wk0jp53mf9jjdz2py9774mxm8bwarh6ykl0";
+    sha256 = "02ff77cpvy1006cwfym38vf78xm18plyj636ll74r7kx2bblkpxf";
   };
 
-  buildInputs = [ pkgconfig pcre libxml2 zlib attr bzip2 which file openssl ]
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ pcre libxml2 zlib attr bzip2 which file openssl ]
              ++ stdenv.lib.optional enableMagnet lua5_1
-             ++ stdenv.lib.optional enableMysql mysql.lib;
+             ++ stdenv.lib.optional enableMysql mysql.connector-c
+             ++ stdenv.lib.optional enableLdap openldap
+             ++ stdenv.lib.optional enableWebDAV sqlite
+             ++ stdenv.lib.optional enableWebDAV libuuid;
 
   configureFlags = [ "--with-openssl" ]
                 ++ stdenv.lib.optional enableMagnet "--with-lua"
-                ++ stdenv.lib.optional enableMysql "--with-mysql";
+                ++ stdenv.lib.optional enableMysql "--with-mysql"
+                ++ stdenv.lib.optional enableLdap "--with-ldap"
+                ++ stdenv.lib.optional enableWebDAV "--with-webdav-props"
+                ++ stdenv.lib.optional enableWebDAV "--with-webdav-locks";
 
   preConfigure = ''
     sed -i "s:/usr/bin/file:${file}/bin/file:g" configure
   '';
 
+  postInstall = ''
+    mkdir -p "$out/share/lighttpd/doc/config"
+    cp -vr doc/config "$out/share/lighttpd/doc/"
+    # Remove files that references needless store paths (dependency bloat)
+    rm "$out/share/lighttpd/doc/config/Makefile"*
+    rm "$out/share/lighttpd/doc/config/conf.d/Makefile"*
+    rm "$out/share/lighttpd/doc/config/vhosts.d/Makefile"*
+  '';
+
   meta = with stdenv.lib; {
     description = "Lightweight high-performance web server";
     homepage = http://www.lighttpd.net/;
diff --git a/pkgs/servers/http/lwan/default.nix b/pkgs/servers/http/lwan/default.nix
new file mode 100644
index 000000000000..878211ebf024
--- /dev/null
+++ b/pkgs/servers/http/lwan/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, pkgconfig, zlib, cmake, jemalloc }:
+
+stdenv.mkDerivation rec {
+  pname = "lwan";
+  version = "0.1";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "lpereira";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1mckryzb06smky0bx2bkqwqzpnq4pb8vlgmmwsvqmwi4mmw9wmi1";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  buildInputs = [ jemalloc zlib ];
+
+  meta = with stdenv.lib; {
+    description = "Lightweight high-performance multi-threaded web server";
+    longDescription = "A lightweight and speedy web server with a low memory
+      footprint (~500KiB for 10k idle connections), with minimal system calls and
+      memory allocation.  Lwan contains a hand-crafted HTTP request parser. Files are
+      served using the most efficient way according to their size: no copies between
+      kernel and userland for files larger than 16KiB.  Smaller files are sent using
+      vectored I/O of memory-mapped buffers. Header overhead is considered before
+      compressing small files.  Features include: mustache templating engine and IPv6
+      support.
+    ";
+    homepage = "https://lwan.ws/";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ leenaars ];
+  };
+}
diff --git a/pkgs/servers/http/micro-httpd/default.nix b/pkgs/servers/http/micro-httpd/default.nix
index ba7c69ef7dbf..02cf49854ac8 100644
--- a/pkgs/servers/http/micro-httpd/default.nix
+++ b/pkgs/servers/http/micro-httpd/default.nix
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     homepage    = "http://acme.com/software/micro_httpd/";
-    description = "a really small HTTP server";
+    description = "A really small HTTP server";
     license     = licenses.bsd2;
     platforms   = platforms.unix;
     maintainers = with maintainers; [ copumpkin ];
diff --git a/pkgs/servers/http/mini-httpd/default.nix b/pkgs/servers/http/mini-httpd/default.nix
index 4cba9bc06687..99b13dab84d0 100644
--- a/pkgs/servers/http/mini-httpd/default.nix
+++ b/pkgs/servers/http/mini-httpd/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, boost }:
 
 stdenv.mkDerivation rec {
-  name = "mini-httpd-1.5";
+  name = "mini-httpd-1.7";
 
   src = fetchurl {
-    url = "mirror://savannah/mini-httpd/${name}.tar.gz";
-    sha256 = "1x4b6x40ymbaamqqq9p97lc0mnah4q7bza04fjs35c8agpm19zir";
+    url = "http://download-mirror.savannah.gnu.org/releases/mini-httpd/${name}.tar.gz";
+    sha256 = "0jggmlaywjfbdljzv5hyiz49plnxh0har2bnc9dq4xmj1pmjgs49";
   };
 
   buildInputs = [ boost ];
@@ -13,10 +13,10 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   meta = {
-    homepage = "http://mini-httpd.nongnu.org/";
-    description = "a minimalistic high-performance web server";
+    homepage = http://mini-httpd.nongnu.org/;
+    description = "minimalistic high-performance web server";
     license = stdenv.lib.licenses.gpl3;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/servers/http/myserver/default.nix b/pkgs/servers/http/myserver/default.nix
index 3e1c94e79b4b..fa3b57a0b22e 100644
--- a/pkgs/servers/http/myserver/default.nix
+++ b/pkgs/servers/http/myserver/default.nix
@@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
     license = lib.licenses.gpl3Plus;
 
     # libevent fails to build on Cygwin and Guile has troubles on Darwin.
-    platforms = lib.platforms.gnu;
+    platforms = lib.platforms.gnu ++ lib.platforms.linux;
 
     broken = true; # needs patch for gets()
   };
diff --git a/pkgs/servers/http/nginx/default.nix b/pkgs/servers/http/nginx/default.nix
deleted file mode 100644
index 54f4e1599b8c..000000000000
--- a/pkgs/servers/http/nginx/default.nix
+++ /dev/null
@@ -1,162 +0,0 @@
-{ stdenv, fetchurl, fetchFromGitHub, openssl, zlib, pcre, libxml2, libxslt, expat
-, gd, geoip, luajit
-, curl, apr, aprutil, apacheHttpd, yajl, libcap, modsecurity_standalone
-, rtmp ? false
-, fullWebDAV ? false
-, syslog ? false
-, moreheaders ? false
-, echo ? false
-, modsecurity ? false
-, ngx_lua ? modsecurity || false
-, set_misc ? false
-, fluent ? false
-, extraModules ? []
-}:
-
-with stdenv.lib;
-
-let
-  version = "1.8.0";
-  mainSrc = fetchurl {
-    url = "http://nginx.org/download/nginx-${version}.tar.gz";
-    sha256 = "1mgkkmmwkhmpn68sdvbd73ssv6lpqhh864fsyvc1ij4hk4is3k13";
-  };
-
-  rtmp-ext = fetchFromGitHub {
-    owner = "arut";
-    repo = "nginx-rtmp-module";
-    rev = "v1.1.7";
-    sha256 = "0i0fa1znkj7cipy5nlkw4k40klhp9jzk28wxy2vrvd2jvh91x3ma";
-  };
-
-  dav-ext = fetchFromGitHub {
-    owner = "arut";
-    repo = "nginx-dav-ext-module";
-    rev = "v0.0.3";
-    sha256 = "1qck8jclxddncjad8yv911s9z7lrd58bp96jf13m0iqk54xghx91";
-  };
-
-  syslog-ext = fetchFromGitHub {
-    owner = "yaoweibin";
-    repo = "nginx_syslog_patch";
-    rev = "3ca5ba65541637f74467038aa032e2586321d0cb";
-    sha256 = "0y8dxkx8m1jw4v5zsvw1gfah9vh3ryq0hfmrcbjzcmwp5b5lb1i8";
-  };
-
-  moreheaders-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "headers-more-nginx-module";
-    rev = "v0.26";
-    sha256 = "01wkqhk8mk8jgmzi7jbzmg5kamffx3lmhj5yfwryvnvs6xqs74wn";
-  };
-
-  modsecurity-ext = modsecurity_standalone.nginx;
-
-  echo-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "echo-nginx-module";
-    rev = "v0.57";
-    sha256 = "1q0f0zprcn0ypl2qh964cq186l3f40p0z7n7x22m8cxj367vf000";
-  };
-
-  lua-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "lua-nginx-module";
-    rev = "v0.9.16";
-    sha256 = "0dvdam228jhsrayb22ishljdkgib08bakh8ygn84sq0c2xbidzlp";
-  };
-
-  set-misc-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "set-misc-nginx-module";
-    rev = "v0.28";
-    sha256 = "1vixj60q0liri7k5ax85grj7q9vvgybkx421bwphbhai5xrjip96";
-  };
-
-  fluentd = fetchFromGitHub {
-    owner = "fluent";
-    repo = "nginx-fluentd-module";
-    rev = "8af234043059c857be27879bc547c141eafd5c13";
-    sha256 = "1ycb5zd9sw60ra53jpak1m73zwrjikwhrrh9q6266h1mlyns7zxm";
-  };
-
-  develkit-ext = fetchFromGitHub {
-    owner = "simpl";
-    repo = "ngx_devel_kit";
-    rev = "v0.2.19";
-    sha256 = "1cqcasp4lc6yq5pihfcdw4vp4wicngvdc3nqg3bg52r63c1qrz76";
-  };
-
-
-in
-
-stdenv.mkDerivation rec {
-  name = "nginx-${version}";
-  src = mainSrc;
-
-  buildInputs =
-    [ openssl zlib pcre libxml2 libxslt gd geoip
-    ] ++ optional fullWebDAV expat
-      ++ optional ngx_lua luajit
-      ++ optionals modsecurity [ curl apr aprutil apacheHttpd yajl ];
-
-  LUAJIT_LIB = if ngx_lua then "${luajit}/lib" else "";
-  LUAJIT_INC = if ngx_lua then "${luajit}/include/luajit-2.0" else "";
-
-  patches = if syslog then [ "${syslog-ext}/syslog-1.5.6.patch" ] else [];
-
-  configureFlags = [
-    "--with-select_module"
-    "--with-poll_module"
-    "--with-threads"
-    "--with-http_ssl_module"
-    "--with-http_spdy_module"
-    "--with-http_realip_module"
-    "--with-http_addition_module"
-    "--with-http_xslt_module"
-    "--with-http_image_filter_module"
-    "--with-http_geoip_module"
-    "--with-http_sub_module"
-    "--with-http_dav_module"
-    "--with-http_flv_module"
-    "--with-http_mp4_module"
-    "--with-http_gunzip_module"
-    "--with-http_gzip_static_module"
-    "--with-http_auth_request_module"
-    "--with-http_random_index_module"
-    "--with-http_secure_link_module"
-    "--with-http_degradation_module"
-    "--with-http_stub_status_module"
-    "--with-ipv6"
-    # Install destination problems
-    # "--with-http_perl_module"
-  ] ++ optional rtmp "--add-module=${rtmp-ext}"
-    ++ optional fullWebDAV "--add-module=${dav-ext}"
-    ++ optional syslog "--add-module=${syslog-ext}"
-    ++ optional moreheaders "--add-module=${moreheaders-ext}"
-    ++ optional echo "--add-module=${echo-ext}"
-    ++ optional ngx_lua "--add-module=${develkit-ext} --add-module=${lua-ext}"
-    ++ optional set_misc "--add-module=${set-misc-ext}"
-    ++ optionals (elem stdenv.system (with platforms; linux ++ freebsd))
-        [ "--with-file-aio" "--with-aio_module" ]
-    ++ optional fluent "--add-module=${fluentd}"
-    ++ optional modsecurity "--add-module=${modsecurity-ext}/nginx/modsecurity"
-    ++ (map (m: "--add-module=${m}") extraModules);
-
-
-  additionalFlags = optionalString stdenv.isDarwin "-Wno-error=deprecated-declarations -Wno-error=conditional-uninitialized";
-
-  NIX_CFLAGS_COMPILE = optionalString modsecurity "-I${aprutil}/include/apr-1 -I${apacheHttpd}/include -I${apr}/include/apr-1 -I${yajl}/include";
-
-  preConfigure = ''
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2}/include/libxml2 $additionalFlags"
-  '';
-
-  meta = {
-    description = "A reverse proxy and lightweight webserver";
-    homepage    = http://nginx.org;
-    license     = licenses.bsd2;
-    platforms   = platforms.all;
-    maintainers = with maintainers; [ thoughtpolice raskin ];
-  };
-}
diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix
new file mode 100644
index 000000000000..ff0a4c65b4a6
--- /dev/null
+++ b/pkgs/servers/http/nginx/generic.nix
@@ -0,0 +1,78 @@
+{ stdenv, fetchurl, fetchFromGitHub, openssl, zlib, pcre, libxml2, libxslt, expat
+, gd, geoip
+, withStream ? true
+, withMail ? false
+, modules ? []
+, hardening ? true
+, version, sha256, ...
+}:
+
+with stdenv.lib;
+
+stdenv.mkDerivation {
+  name = "nginx-${version}";
+
+  src = fetchurl {
+    url = "http://nginx.org/download/nginx-${version}.tar.gz";
+    inherit sha256;
+  };
+
+
+  buildInputs =
+    [ openssl zlib pcre libxml2 libxslt gd geoip ]
+    ++ concatMap (mod: mod.inputs or []) modules;
+
+  configureFlags = [
+    "--with-http_ssl_module"
+    "--with-http_v2_module"
+    "--with-http_realip_module"
+    "--with-http_addition_module"
+    "--with-http_xslt_module"
+    "--with-http_geoip_module"
+    "--with-http_sub_module"
+    "--with-http_dav_module"
+    "--with-http_flv_module"
+    "--with-http_mp4_module"
+    "--with-http_gunzip_module"
+    "--with-http_gzip_static_module"
+    "--with-http_auth_request_module"
+    "--with-http_random_index_module"
+    "--with-http_secure_link_module"
+    "--with-http_degradation_module"
+    "--with-http_stub_status_module"
+    "--with-threads"
+    "--with-pcre-jit"
+    # Install destination problems
+    # "--with-http_perl_module"
+  ] ++ optional withStream [
+    "--with-stream"
+    "--with-stream_geoip_module"
+    "--with-stream_realip_module"
+    "--with-stream_ssl_module"
+    "--with-stream_ssl_preread_module"
+  ] ++ optional withMail [
+    "--with-mail"
+    "--with-mail_ssl_module"
+  ]
+    ++ optional (gd != null) "--with-http_image_filter_module"
+    ++ optional (with stdenv.hostPlatform; isLinux || isFreeBSD) "--with-file-aio"
+    ++ map (mod: "--add-module=${mod.src}") modules;
+
+  NIX_CFLAGS_COMPILE = [ "-I${libxml2.dev}/include/libxml2" ] ++ optional stdenv.isDarwin "-Wno-error=deprecated-declarations";
+
+  preConfigure = (concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules);
+
+  hardeningEnable = optional (!stdenv.isDarwin) "pie";
+
+  postInstall = ''
+    mv $out/sbin $out/bin
+  '';
+
+  meta = {
+    description = "A reverse proxy and lightweight webserver";
+    homepage    = http://nginx.org;
+    license     = licenses.bsd2;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ thoughtpolice raskin fpletz ];
+  };
+}
diff --git a/pkgs/servers/http/nginx/mainline.nix b/pkgs/servers/http/nginx/mainline.nix
new file mode 100644
index 000000000000..71cb6fc72ab9
--- /dev/null
+++ b/pkgs/servers/http/nginx/mainline.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... }@args:
+
+callPackage ./generic.nix (args // {
+  version = "1.13.12";
+  sha256 = "1pl5ii1w2ycxprxk8zdnxlpdd1dia6hyrns7mnqkm3fv5ihgb4pv";
+})
diff --git a/pkgs/servers/http/nginx/unstable.upstream b/pkgs/servers/http/nginx/mainline.upstream
index 7bb025499592..7bb025499592 100644
--- a/pkgs/servers/http/nginx/unstable.upstream
+++ b/pkgs/servers/http/nginx/mainline.upstream
diff --git a/pkgs/servers/http/nginx/modules.nix b/pkgs/servers/http/nginx/modules.nix
new file mode 100644
index 000000000000..f482c92ed9f7
--- /dev/null
+++ b/pkgs/servers/http/nginx/modules.nix
@@ -0,0 +1,199 @@
+{ fetchFromGitHub, fetchurl, lib, pkgs }:
+
+{
+  brotli = {
+    src = let gitsrc = pkgs.fetchFromGitHub {
+      owner = "eustas";
+      repo = "ngx_brotli";
+      rev = "37ab9b2933a0b756ba3447000b7f31d432ed8228"; # v0.1.1
+      sha256 = "114ai8v9ns23qm12wp9dgdjvldqjnrmb3cmarkn0d3k6n3bm01bf";
+    }; in pkgs.runCommandNoCC "ngx_brotli-src" {} ''
+      cp -a ${gitsrc} $out
+      substituteInPlace $out/config \
+        --replace /usr/local ${lib.getDev pkgs.brotli}
+    '';
+    inputs = [ pkgs.brotli ];
+  };
+
+  ipscrub = {
+    src = fetchFromGitHub {
+      owner = "masonicboom";
+      repo = "ipscrub";
+      rev = "99230f66d5afe1f929cf4ed217901acb6206f620";
+      sha256 = "0mfrwkg4srql38w713pg6qxi0h4hgy8inkvgc9cm80bwlv2ng9s1";
+    } + "/ipscrub";
+  };
+
+  rtmp ={
+    src = fetchFromGitHub {
+      owner = "arut";
+      repo = "nginx-rtmp-module";
+      rev = "v1.2.1";
+      sha256 = "0na1aam176irz6w148hnvamqy1ilbn4abhdzkva0yrm35a3ksbzn";
+    };
+  };
+
+  dav = {
+    src = fetchFromGitHub {
+      owner = "arut";
+      repo = "nginx-dav-ext-module";
+      rev = "v0.1.0";
+      sha256 = "1ifahd69vz715g3zim618jbmxb7kcmzykc696grskxm0svpy294k";
+    };
+    inputs = [ pkgs.expat ];
+  };
+
+  moreheaders = {
+    src = fetchFromGitHub {
+      owner = "openresty";
+      repo = "headers-more-nginx-module";
+      rev = "v0.26";
+      sha256 = "0zhr3ai4xf5yghxvlbrwv8n06fgx33f1n1d4a6gmsczdfjzf8g6g";
+    };
+  };
+
+  modsecurity = {
+    src = "${pkgs.modsecurity_standalone.nginx}/nginx/modsecurity";
+    inputs = [ pkgs.curl pkgs.apr pkgs.aprutil pkgs.apacheHttpd pkgs.yajl ];
+    preConfigure = ''
+      export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${pkgs.aprutil.dev}/include/apr-1 -I${pkgs.apacheHttpd.dev}/include -I${pkgs.apr.dev}/include/apr-1 -I${pkgs.yajl}/include"
+    '';
+  };
+
+  modsecurity-nginx = {
+    src = fetchFromGitHub {
+      owner = "SpiderLabs";
+      repo = "ModSecurity-nginx";
+      rev = "v1.0.0";
+      sha256 = "0zzpdqhbdqqy8kjkszv0mrq6136ah9v3zwr1jbh312j8izmzdyi7";
+    };
+    inputs = [ pkgs.curl pkgs.geoip pkgs.libmodsecurity pkgs.libxml2 pkgs.lmdb pkgs.yajl ];
+  };
+
+  echo = {
+    src = fetchFromGitHub {
+      owner = "openresty";
+      repo = "echo-nginx-module";
+      rev = "v0.61";
+      sha256 = "0brjhhphi94ms4gia7za0mfx0png4jbhvq6j0nzjwp537iyiy23k";
+    };
+  };
+
+  develkit = {
+    src = fetchFromGitHub {
+      owner = "simpl";
+      repo = "ngx_devel_kit";
+      rev = "v0.3.0";
+      sha256 = "1br1997zqsjcb1aqm6h6xmi5yx7akxk0qvk8wxc0fnvmyhgzxgx0";
+    };
+  };
+
+  lua = {
+    src = fetchFromGitHub {
+      owner = "openresty";
+      repo = "lua-nginx-module";
+      rev = "v0.10.10";
+      sha256 = "1dlqnlkpn3pnhk2m09jdx3iw3m6xk31pw2m5xrpcmqk3bll68mw6";
+    };
+    inputs = [ pkgs.luajit ];
+    preConfigure = ''
+      export LUAJIT_LIB="${pkgs.luajit}/lib"
+      export LUAJIT_INC="${pkgs.luajit}/include/luajit-2.0"
+    '';
+  };
+
+  set-misc = {
+    src = fetchFromGitHub {
+      owner = "openresty";
+      repo = "set-misc-nginx-module";
+      rev = "v0.28";
+      sha256 = "1vixj60q0liri7k5ax85grj7q9vvgybkx421bwphbhai5xrjip96";
+    };
+  };
+
+  fluentd = {
+    src = fetchFromGitHub {
+      owner = "fluent";
+      repo = "nginx-fluentd-module";
+      rev = "8af234043059c857be27879bc547c141eafd5c13";
+      sha256 = "1ycb5zd9sw60ra53jpak1m73zwrjikwhrrh9q6266h1mlyns7zxm";
+    };
+  };
+
+  pam = {
+    src = fetchFromGitHub {
+      owner = "stogh";
+      repo = "ngx_http_auth_pam_module";
+      rev = "v1.4";
+      sha256 = "068zwyrc1dji55rlaj2kx6n0v2n5rpj7nz26ipvz26ida712md35";
+    };
+    inputs = [ pkgs.pam ];
+  };
+
+  statsd = {
+    src = fetchFromGitHub {
+      owner = "apcera";
+      repo = "nginx-statsd";
+      rev = "2147d61dc31dd4865604be92349e6192a905d21a";
+      sha256 = "19s3kwjgf51jkwknh7cfi82p6kifl8rl146wxc3ijds12776ilsv";
+    };
+  };
+
+  upstream-check = {
+    src = fetchFromGitHub {
+      owner = "yaoweibin";
+      repo = "nginx_upstream_check_module";
+      rev = "10782eaff51872a8f44e65eed89bbe286004bcb1";
+      sha256 = "0h98a8kiw2qkqfavysm1v16kf4cs4h39j583wapif4p0qx3bbm89";
+    };
+  };
+
+  # For an example usage, see https://easyengine.io/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
+  fastcgi-cache-purge = {
+    src = fetchFromGitHub {
+      owner  = "FRiCKLE";
+      repo   = "ngx_cache_purge";
+      rev    = "2.3";
+      sha256 = "0ib2jrbjwrhvmihhnzkp4w87fxssbbmmmj6lfdwpm6ni8p9g60dw";
+    };
+  };
+
+  pagespeed =
+    let
+      version = pkgs.psol.version;
+
+      moduleSrc = fetchFromGitHub {
+        owner  = "pagespeed";
+        repo   = "ngx_pagespeed";
+        rev    = "v${version}-stable";
+        sha256 = "0ry7vmkb2bx0sspl1kgjlrzzz6lbz07313ks2lr80rrdm2zb16wp";
+      };
+
+      ngx_pagespeed = pkgs.runCommand
+        "ngx_pagespeed"
+        {
+          meta = {
+            description = "PageSpeed module for Nginx";
+            homepage    = "https://developers.google.com/speed/pagespeed/module/";
+            license     = pkgs.stdenv.lib.licenses.asl20;
+          };
+        }
+        ''
+          cp -r "${moduleSrc}" "$out"
+          chmod -R +w "$out"
+          ln -s "${pkgs.psol}" "$out/psol"
+        '';
+    in {
+      src = ngx_pagespeed;
+      inputs = [ pkgs.zlib pkgs.libuuid ]; # psol deps
+    };
+
+    shibboleth = {
+      src = fetchFromGitHub {
+        owner = "nginx-shib";
+        repo = "nginx-http-shibboleth";
+        rev = "48b70d87bf7796d7813813a837e52b3a86e6f6f4";
+        sha256 = "0k8xcln5sf0m4r0m550dkhl07zhncp285dpysk6r4v6vqzqmhzdc";
+      };
+    };
+}
diff --git a/pkgs/servers/http/nginx/stable.nix b/pkgs/servers/http/nginx/stable.nix
new file mode 100644
index 000000000000..1b61cb87c9af
--- /dev/null
+++ b/pkgs/servers/http/nginx/stable.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix (args // {
+  version = "1.14.0";
+  sha256 = "1d9c0avfpbwvzyg53b59ks8shpnrxnbnshcd7ziizflsyv5vw5ax";
+})
diff --git a/pkgs/servers/http/nginx/default.upstream b/pkgs/servers/http/nginx/stable.upstream
index c20139017436..c20139017436 100644
--- a/pkgs/servers/http/nginx/default.upstream
+++ b/pkgs/servers/http/nginx/stable.upstream
diff --git a/pkgs/servers/http/nginx/unstable.nix b/pkgs/servers/http/nginx/unstable.nix
deleted file mode 100644
index e71adba3e572..000000000000
--- a/pkgs/servers/http/nginx/unstable.nix
+++ /dev/null
@@ -1,134 +0,0 @@
-{ stdenv, fetchurl, fetchFromGitHub, openssl, zlib, pcre, libxml2, libxslt, expat
-, gd, geoip, luajit
-, rtmp ? false
-, fullWebDAV ? false
-, syslog ? false
-, moreheaders ? false
-, echo ? false
-, ngx_lua ? false
-, withStream ? false }:
-
-with stdenv.lib;
-
-let
-  version = "1.9.4";
-  mainSrc = fetchurl {
-    url = "http://nginx.org/download/nginx-${version}.tar.gz";
-    sha256 = "1a1bixw2a4s5c3qzw3583s4a4y6i0sdzhihhlbab5rkyfh1hr6s7";
-  };
-
-  rtmp-ext = fetchFromGitHub {
-    owner = "arut";
-    repo = "nginx-rtmp-module";
-    rev = "v1.1.5";
-    sha256 = "1d9ws4prxz22yq3nhh5h18jrs331zivrdh784l6wznc1chg3gphn";
-  };
-
-  dav-ext = fetchFromGitHub {
-    owner = "arut";
-    repo = "nginx-dav-ext-module";
-    rev = "v0.0.3";
-    sha256 = "1qck8jclxddncjad8yv911s9z7lrd58bp96jf13m0iqk54xghx91";
-  };
-
-  syslog-ext = fetchFromGitHub {
-    owner = "yaoweibin";
-    repo = "nginx_syslog_patch";
-    rev = "v0.25";
-    sha256 = "0734f884838wcjyrrddn8wzj834wid1zffrk093jrx18447cryxl";
-  };
-
-  moreheaders-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "headers-more-nginx-module";
-    rev = "v0.25";
-    sha256 = "1d71y1i0smi4gkzz731fhn58gr03b3s6jz6ipnfzxxaizmgxm3rb";
-  };
-
-  echo-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "echo-nginx-module";
-    rev = "v0.56";
-    sha256 = "03vaf1ffhkj2s089f90h45n079h3zw47h6y5zpk752f4ydiagpgd";
-  };
-
-  develkit-ext = fetchFromGitHub {
-    owner = "simpl";
-    repo = "ngx_devel_kit";
-    rev = "v0.2.19";
-    sha256 = "1cqcasp4lc6yq5pihfcdw4vp4wicngvdc3nqg3bg52r63c1qrz76";
-  };
-
-  lua-ext = fetchFromGitHub {
-    owner = "openresty";
-    repo = "lua-nginx-module";
-    rev = "v0.9.16";
-    sha256 = "0dvdam228jhsrayb22ishljdkgib08bakh8ygn84sq0c2xbidzlp";
-  };
-
-in
-
-stdenv.mkDerivation rec {
-  name = "nginx-${version}";
-  src = mainSrc;
-
-  buildInputs =
-    [ openssl zlib pcre libxml2 libxslt gd geoip
-    ] ++ optional fullWebDAV expat
-      ++ optional ngx_lua luajit;
-
-  LUAJIT_LIB = if ngx_lua then "${luajit}/lib" else "";
-  LUAJIT_INC = if ngx_lua then "${luajit}/include/luajit-2.0" else "";
-
-  patches = if syslog then [ "${syslog-ext}/syslog-1.5.6.patch" ] else [];
-
-  configureFlags = [
-    "--with-http_ssl_module"
-    "--with-http_spdy_module"
-    "--with-http_realip_module"
-    "--with-http_addition_module"
-    "--with-http_xslt_module"
-    "--with-http_image_filter_module"
-    "--with-http_geoip_module"
-    "--with-http_sub_module"
-    "--with-http_dav_module"
-    "--with-http_flv_module"
-    "--with-http_mp4_module"
-    "--with-http_gunzip_module"
-    "--with-http_gzip_static_module"
-    "--with-http_auth_request_module"
-    "--with-http_random_index_module"
-    "--with-http_secure_link_module"
-    "--with-http_degradation_module"
-    "--with-http_stub_status_module"
-    "--with-ipv6"
-    # Install destination problems
-    # "--with-http_perl_module"
-  ] ++ optional rtmp "--add-module=${rtmp-ext}"
-    ++ optional fullWebDAV "--add-module=${dav-ext}"
-    ++ optional syslog "--add-module=${syslog-ext}"
-    ++ optional moreheaders "--add-module=${moreheaders-ext}"
-    ++ optional echo "--add-module=${echo-ext}"
-    ++ optional ngx_lua "--add-module=${develkit-ext} --add-module=${lua-ext}"
-    ++ optional withStream "--with-stream"
-    ++ optional (elem stdenv.system (with platforms; linux ++ freebsd)) "--with-file-aio";
-
-
-  additionalFlags = optionalString stdenv.isDarwin "-Wno-error=deprecated-declarations";
-
-  preConfigure = ''
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2}/include/libxml2 $additionalFlags"
-  '';
-
-  postInstall = ''
-    mv $out/sbin $out/bin
-  '';
-
-  meta = {
-    description = "A reverse proxy and lightweight webserver";
-    homepage    = http://nginx.org;
-    license     = licenses.bsd2;
-    platforms   = platforms.all;
-    maintainers = with maintainers; [ thoughtpolice raskin ];
-  };
-}
diff --git a/pkgs/servers/http/nix-binary-cache/default.nix b/pkgs/servers/http/nix-binary-cache/default.nix
index b007c09b0560..33801c8cd326 100644
--- a/pkgs/servers/http/nix-binary-cache/default.nix
+++ b/pkgs/servers/http/nix-binary-cache/default.nix
@@ -14,12 +14,12 @@ stdenv.mkDerivation rec {
       --replace @shell@ "${stdenv.shell}" \
       --replace @coreutils@ "${coreutils}/bin" \
       --replace @findutils@ "${findutils}/bin" \
-      --replace @nix@ "${nix}/bin" \
-      --replace @xz@ "${xz}/bin" \
-      --replace @bzip2@ "${bzip2}/bin" \
+      --replace @nix@ "${nix.out}/bin" \
+      --replace @xz@ "${xz.bin}/bin" \
+      --replace @bzip2@ "${bzip2.bin}/bin" \
       --replace @gnused@ "${gnused}/bin" \
       --replace @gnugrep@ "${gnugrep}/bin" \
-      --replace @openssl@ "${openssl}/bin" \
+      --replace @openssl@ "${openssl.bin}/bin" \
       --replace @lighttpd@ "${lighttpd}/sbin" \
       --replace @iproute@ "${iproute}/sbin" \
       --replace "xXxXx" "xXxXx"
@@ -31,12 +31,12 @@ stdenv.mkDerivation rec {
       --replace @shell@ "${stdenv.shell}" \
       --replace @coreutils@ "${coreutils}/bin" \
       --replace @findutils@ "${findutils}/bin" \
-      --replace @nix@ "${nix}/bin" \
-      --replace @xz@ "${xz}/bin" \
-      --replace @bzip2@ "${bzip2}/bin" \
+      --replace @nix@ "${nix.out}/bin" \
+      --replace @xz@ "${xz.bin}/bin" \
+      --replace @bzip2@ "${bzip2.bin}/bin" \
       --replace @gnused@ "${gnused}/bin" \
       --replace @gnugrep@ "${gnugrep}/bin" \
-      --replace @openssl@ "${openssl}/bin" \
+      --replace @openssl@ "${openssl.bin}/bin" \
       --replace @lighttpd@ "${lighttpd}/sbin" \
       --replace @iproute@ "${iproute}/sbin" \
       --replace "xXxXx" "xXxXx"
diff --git a/pkgs/servers/http/openresty/default.nix b/pkgs/servers/http/openresty/default.nix
index 14f95761cfb1..252e1a97dfdb 100644
--- a/pkgs/servers/http/openresty/default.nix
+++ b/pkgs/servers/http/openresty/default.nix
@@ -1,25 +1,30 @@
-{ stdenv, fetchurl, fetchgit, openssl, zlib, pcre, libxml2, libxslt, gd, geoip
-, perl }:
-
-assert stdenv.isLinux;
+{ stdenv, fetchurl, fetchgit, openssl, zlib, pcre, postgresql, libxml2, libxslt,
+gd, geoip, perl }:
 
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "openresty-${version}";
-  version = "1.9.3.1";
+  version = "1.13.6.2";
 
   src = fetchurl {
-    url = "http://openresty.org/download/ngx_openresty-${version}.tar.gz";
-    sha256 = "1fw8yxjndf5gsk44l4bsixm270fxv7f5cdiwzq9ps6j3hhgx5kyv";
+    url = "http://openresty.org/download/openresty-${version}.tar.gz";
+    sha256 = "0hi9zw4344a4i636g3nbnnlm8qbnq37f50irhd1xncih4xc1jvll";
   };
 
-  buildInputs = [ openssl zlib pcre libxml2 libxslt gd geoip perl ];
+  buildInputs = [ openssl zlib pcre libxml2 libxslt gd geoip postgresql ];
+  nativeBuildInputs = [ perl ];
+
+  NIX_CFLAGS_COMPILE = ["-I${libxml2.dev}/include/libxml2"];
+
+  preConfigure = ''
+    patchShebangs .
+  '';
 
   configureFlags = [
     "--with-pcre-jit"
     "--with-http_ssl_module"
-    "--with-http_spdy_module"
+    "--with-http_v2_module"
     "--with-http_realip_module"
     "--with-http_addition_module"
     "--with-http_xslt_module"
@@ -36,26 +41,22 @@ stdenv.mkDerivation rec {
     "--with-http_secure_link_module"
     "--with-http_degradation_module"
     "--with-http_stub_status_module"
+    "--with-http_postgres_module"
     "--with-ipv6"
   ];
 
-  postInstall = ''
-    mv $out/nginx/sbin/nginx $out/bin
-    mv $out/luajit/bin/luajit-2.1.0-alpha $out/bin/luajit-openresty
-    ln -s $out/bin/nginx $out/bin/openresty
-  '';
+  enableParallelBuilding = true;
 
-  preConfigure = ''
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2}/include/libxml2 $additionalFlags"
-    export PATH="$PATH:${stdenv.cc.libc}/sbin"
-    patchShebangs .
+  postInstall = ''
+    ln -s $out/luajit/bin/luajit-2.1.0-beta3 $out/bin/luajit-openresty
+    ln -s $out/nginx/sbin/nginx $out/bin/nginx
   '';
 
   meta = {
     description = "A fast web application server built on Nginx";
     homepage    = http://openresty.org;
     license     = licenses.bsd2;
-    platforms   = platforms.linux;
-    maintainers = with maintainers; [ thoughtpolice ];
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ thoughtpolice lblasc ];
   };
 }
diff --git a/pkgs/servers/http/pshs/default.nix b/pkgs/servers/http/pshs/default.nix
index 141f58417fb6..a0a1addeeebf 100644
--- a/pkgs/servers/http/pshs/default.nix
+++ b/pkgs/servers/http/pshs/default.nix
@@ -1,25 +1,27 @@
-{ stdenv, fetchurl, pkgconfig, libevent, file, qrencode }:
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, libevent, file, qrencode, miniupnpc }:
 
-let
-  version = "0.2.6";
-in stdenv.mkDerivation {
+stdenv.mkDerivation rec {
   name = "pshs-${version}";
+  version = "0.3.3";
 
-  src = fetchurl {
-    url = "https://www.bitbucket.org/mgorny/pshs/downloads/pshs-${version}.tar.bz2";
-    sha256 = "0n8l5sjnwjqjmw0jzg3hb93n6npg2wahmdg1zrpsw8fyh9ggjg4g";
+  src = fetchFromGitHub {
+    owner = "mgorny";
+    repo = "pshs";
+    rev = "v${version}";
+    sha256 = "04l03myh99npl78y8nss053gnc7k8q60vdbdpml19sshmwaw3fgi";
   };
 
-  buildInputs = [ pkgconfig libevent file qrencode ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libevent file qrencode miniupnpc ];
 
-  # TODO: enable ssl once dependencies
-  # (libssl libcrypto libevent >= 2.1 libevent_openssl) can be met
+  # SSL requires libevent at 2.1 with ssl support
   configureFlags = "--disable-ssl";
 
   meta = {
     description = "Pretty small HTTP server - a command-line tool to share files";
-    homepage = "https://bitbucket.org/mgorny/pshs/";
+    homepage = https://github.com/mgorny/pshs;
     license = stdenv.lib.licenses.bsd3;
     maintainers = [ stdenv.lib.maintainers.eduarrrd ];
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/servers/http/redstore/default.nix b/pkgs/servers/http/redstore/default.nix
index c47449ce6bd7..b2c80b3f88fc 100644
--- a/pkgs/servers/http/redstore/default.nix
+++ b/pkgs/servers/http/redstore/default.nix
@@ -2,24 +2,29 @@
   , librdf_rasqal }:
 
 stdenv.mkDerivation rec {
-  name = "redstore-0.5.2";
+  name = "redstore-0.5.4";
 
   src = fetchurl {
     url = "http://www.aelius.com/njh/redstore/${name}.tar.gz";
-    sha256 = "fdbe499a7bbe8c8a756ecb738b83ea375e96af16a1d74245b75600d4d40adb7d";
+    sha256 = "0hc1fjfbfvggl72zqx27v4wy84f5m7bp4dnwd8g41aw8lgynbgaq";
   };
 
-  buildInputs = [ gmp pkgconfig redland zlib librdf_raptor2 librdf_rasqal ];
-     
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gmp redland zlib librdf_raptor2 librdf_rasqal ];
+
   preConfigure = ''
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${librdf_raptor2}/include/raptor2"
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${librdf_rasqal}/include/rasqal"
+    # Define _XOPEN_SOURCE to enable, e.g., getaddrinfo.
+    configureFlagsArray+=(
+      "CFLAGS=-D_XOPEN_SOURCE=600 -I${librdf_raptor2}/include/raptor2 -I${librdf_rasqal}/include/rasqal"
+    )
   '';
 
   meta = {
     description = "An HTTP interface to Redland RDF store";
+    homepage = https://www.aelius.com/njh/redstore/;
     maintainers = [ stdenv.lib.maintainers.raskin ];
     platforms = with stdenv.lib.platforms;
       linux ++ freebsd ++ gnu;
+    license = stdenv.lib.licenses.gpl3Plus;
   };
 }
diff --git a/pkgs/servers/http/spawn-fcgi/default.nix b/pkgs/servers/http/spawn-fcgi/default.nix
index b39e2b8fbf76..b5d5d5f7992d 100644
--- a/pkgs/servers/http/spawn-fcgi/default.nix
+++ b/pkgs/servers/http/spawn-fcgi/default.nix
@@ -20,5 +20,6 @@ stdenv.mkDerivation rec {
     description = "Provides an interface to external programs that support the FastCGI interface";
     license     = licenses.bsd3;
     maintainers = with maintainers; [ cstrahan ];
+    platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/servers/http/thttpd/default.nix b/pkgs/servers/http/thttpd/default.nix
index 53a7f916c9ac..8256bd9c734b 100644
--- a/pkgs/servers/http/thttpd/default.nix
+++ b/pkgs/servers/http/thttpd/default.nix
@@ -2,15 +2,16 @@
 
 stdenv.mkDerivation rec {
   name = "thttpd-${version}";
-  version = "2.26";
+  version = "2.29";
 
   src = fetchurl {
     url = "http://acme.com/software/thttpd/${name}.tar.gz";
-    sha256 = "1dybhpyfrly0m285cdn9jah397bqzylrwzi26gin2h451z3gdcqm";
+    sha256 = "15x3h4b49wgfywn82i3wwbf38mdns94mbi4ma9xiwsrjv93rzh4r";
   };
 
   prePatch = ''
     sed -i -e 's/getline/getlineX/' extras/htpasswd.c
+    sed -i -e 's/chmod 2755/chmod 755/' extras/Makefile.in
   '';
 
   preInstall = ''
@@ -21,7 +22,8 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "Tiny/turbo/throttling HTTP server";
-    homepage = "http://www.acme.com/software/thttpd/";
+    homepage = http://www.acme.com/software/thttpd/;
     license = stdenv.lib.licenses.bsd2;
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/servers/http/tomcat/5.0.nix b/pkgs/servers/http/tomcat/5.0.nix
deleted file mode 100644
index c15604cb0ae0..000000000000
--- a/pkgs/servers/http/tomcat/5.0.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{stdenv, fetchurl, jdk}:
-
-stdenv.mkDerivation {
-
-  name = "jakarta-tomcat-5.0.27";
-
-  builder = ./builder.sh;
-
-  src = fetchurl {
-    url = http://apache.essentkabel.com/jakarta/tomcat-5/v5.0.27/bin/jakarta-tomcat-5.0.27.tar.gz;
-    md5 = "b802ee042677e284bcf65738c7bdc3b6";
-  };
-
-  inherit jdk;
-}
-
-
diff --git a/pkgs/servers/http/tomcat/6.0.nix b/pkgs/servers/http/tomcat/6.0.nix
deleted file mode 100644
index 71f1d62f4d80..000000000000
--- a/pkgs/servers/http/tomcat/6.0.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-import ./recent.nix 
-  {
-    versionMajor = "6";
-    versionMinor = "0.44";
-    sha256 = "0942f0ss6w9k23xg94nir2dbbkqrqp5k628jflk51ikm5qr95dxa";
-  }
diff --git a/pkgs/servers/http/tomcat/7.0.nix b/pkgs/servers/http/tomcat/7.0.nix
deleted file mode 100644
index 221feb9c30eb..000000000000
--- a/pkgs/servers/http/tomcat/7.0.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-import ./recent.nix 
-  {
-    versionMajor = "7";
-    versionMinor = "0.62";
-    sha256 = "0v8zvyd4h85ynnday58x0ppplw4flxyjsrmrpg78rrv3w49fm1x7";
-  }
diff --git a/pkgs/servers/http/tomcat/8.0.nix b/pkgs/servers/http/tomcat/8.0.nix
deleted file mode 100644
index a6da1198c9aa..000000000000
--- a/pkgs/servers/http/tomcat/8.0.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-import ./recent.nix 
-  {
-    versionMajor = "8";
-    versionMinor = "0.23";
-    sha256 = "0f0s35iqs1zpifya0qvdrk55r77jr074sc0zk5cjivxaxnhik2y9";
-  }
diff --git a/pkgs/servers/http/tomcat/axis2/default.nix b/pkgs/servers/http/tomcat/axis2/default.nix
index cf64ba2d3c69..f751fd7846c9 100644
--- a/pkgs/servers/http/tomcat/axis2/default.nix
+++ b/pkgs/servers/http/tomcat/axis2/default.nix
@@ -1,11 +1,12 @@
-{stdenv, fetchurl, apacheAnt, jdk, unzip}:
+{ stdenv, fetchurl, apacheAnt, jdk, unzip }:
 
-stdenv.mkDerivation {
-  name = "axis2-1.6.2";
+stdenv.mkDerivation rec {
+  name = "axis2-${version}";
+  version = "1.6.4";
 
   src = fetchurl {
-    url = http://apache.proserve.nl/axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip;
-    sha256 = "02i6fv11ksd5ql81i501bcb11ib5gyhq3zxwrz5jm4ic80r097fp";
+    url = "http://apache.proserve.nl/axis/axis2/java/core/${version}/${name}-bin.zip";
+    sha256 = "12ir706dn95567j6lkxdwrh28vnp6292h59qwjyqjm7ckglkmgyr";
   };
 
   buildInputs = [ unzip apacheAnt jdk ];
@@ -13,5 +14,6 @@ stdenv.mkDerivation {
 
   meta = {
     description = "Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack";
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/servers/http/tomcat/builder.sh b/pkgs/servers/http/tomcat/builder.sh
deleted file mode 100644
index 5f858d1cff8e..000000000000
--- a/pkgs/servers/http/tomcat/builder.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-source $stdenv/setup || exit 1
-
-tar zxf $src
-cd jakarta-tomcat*/bin
-
-# install jsvc
-
-tar xvfz jsvc.tar.gz
-cd jsvc-src
-sh ./configure --with-java=$jdk
-make
-cp jsvc ..
-cd ..
-
-# done jsvc
-
-cd ../..
-
-mkdir $out
-mv jakarta-tomcat* $out
diff --git a/pkgs/servers/http/tomcat/default.nix b/pkgs/servers/http/tomcat/default.nix
new file mode 100644
index 000000000000..098825d59ce8
--- /dev/null
+++ b/pkgs/servers/http/tomcat/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, lib, fetchurl }:
+
+let
+
+  common = { versionMajor, versionMinor, sha256 } @ args: stdenv.mkDerivation (rec {
+    name = "apache-tomcat-${version}";
+    version = "${versionMajor}.${versionMinor}";
+
+    src = fetchurl {
+      url = "mirror://apache/tomcat/tomcat-${versionMajor}/v${version}/bin/${name}.tar.gz";
+      inherit sha256;
+    };
+
+    outputs = [ "out" "webapps" ];
+    installPhase =
+      ''
+        mkdir $out
+        mv * $out
+        mkdir -p $webapps/webapps
+        mv $out/webapps $webapps/
+      '';
+
+    meta = {
+      homepage = https://tomcat.apache.org/;
+      description = "An implementation of the Java Servlet and JavaServer Pages technologies";
+      platforms = with lib.platforms; all;
+      maintainers = with lib.maintainers; [ danbst ];
+      license = [ lib.licenses.asl20 ];
+    };
+  });
+
+in {
+  tomcat7 = common {
+    versionMajor = "7";
+    versionMinor = "0.82";
+    sha256 = "0vb7c5i50ral4rr39ss95k7cxnzd7fs21zd7f97d1f3qslzwl69g";
+  };
+
+  tomcat8 = common {
+    versionMajor = "8";
+    versionMinor = "0.47";
+    sha256 = "0xv4v3i08rwzfmz7rkhglq5cbjgnfava8dw0i33vsp7dk162a4g4";
+  };
+
+  tomcat85 = common {
+    versionMajor = "8";
+    versionMinor = "5.23";
+    sha256 = "1qnww70x75c0qf2wn8mkpz5lszggjnh78dpb4chyw2fnbm3wxain";
+  };
+
+  tomcat9 = common {
+    versionMajor = "9";
+    versionMinor = "0.2";
+    sha256 = "0aaykzi0b2xsdmjp60ihcjzh1m95p0a79kn5l2v7vgbkyg449638";
+  };
+}
diff --git a/pkgs/servers/http/tomcat/jdbc/mysql/default.nix b/pkgs/servers/http/tomcat/jdbc/mysql/default.nix
index 975d5234aee9..d070a9f17404 100644
--- a/pkgs/servers/http/tomcat/jdbc/mysql/default.nix
+++ b/pkgs/servers/http/tomcat/jdbc/mysql/default.nix
@@ -1,9 +1,13 @@
-{ stdenv, tomcat6, mysql_jdbc }:
+{ stdenv, mysql_jdbc }:
 
 stdenv.mkDerivation {
   name = "tomcat-mysql-jdbc";
   builder = ./builder.sh;
   buildInputs = [ mysql_jdbc ];
-  
+
   inherit mysql_jdbc;
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
 }
diff --git a/pkgs/servers/http/tomcat/recent.nix b/pkgs/servers/http/tomcat/recent.nix
deleted file mode 100644
index 02be47a60221..000000000000
--- a/pkgs/servers/http/tomcat/recent.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{ versionMajor, versionMinor, sha256 }:
-{ stdenv, fetchurl }:
-
-let version = "${versionMajor}.${versionMinor}"; in
-
-stdenv.mkDerivation rec {
-  name = "apache-tomcat-${version}";
-
-  src = fetchurl {
-    url = "mirror://apache/tomcat/tomcat-${versionMajor}/v${version}/bin/${name}.tar.gz";
-    inherit sha256;
-  };
-
-  installPhase =
-    ''
-      mkdir $out
-      mv * $out
-    '';
-
-  meta = {
-    homepage = http://tomcat.apache.org/;
-    description = "An implementation of the Java Servlet and JavaServer Pages technologies";
-    platforms = with stdenv.lib.platforms; all;
-  };
-}
diff --git a/pkgs/servers/http/webfs/default.nix b/pkgs/servers/http/webfs/default.nix
new file mode 100644
index 000000000000..3fb3890f9c4e
--- /dev/null
+++ b/pkgs/servers/http/webfs/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, openssl }:
+let
+  # Let's not pull the whole apache httpd package
+  mime_file = fetchurl {
+    url = https://raw.githubusercontent.com/apache/httpd/906e419c1f703360e2e8ec077b393347f993884f/docs/conf/mime.types;
+    sha256 = "ef972fc545cbff4c0daa2b2e6b440859693b3c10435ee90f10fa6fffad800c16";
+  };
+in
+stdenv.mkDerivation rec {
+  name = "webfs-${version}";
+  version = "1.21";
+
+  src = fetchurl {
+    url = "https://www.kraxel.org/releases/webfs/${name}.tar.gz";
+    sha256 = "98c1cb93473df08e166e848e549f86402e94a2f727366925b1c54ab31064a62a";
+  };
+
+  patches = [ ./ls.c.patch ];
+
+  buildInputs = [ openssl ];
+
+  makeFlags = [
+    "mimefile=${mime_file}"
+    "prefix=$(out)"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "HTTP server for purely static content";
+    homepage    = http://linux.bytesex.org/misc/webfs.html;
+    license     = licenses.gpl2;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ zimbatm ];
+  };
+}
diff --git a/pkgs/servers/http/webfs/ls.c.patch b/pkgs/servers/http/webfs/ls.c.patch
new file mode 100644
index 000000000000..78b83b725887
--- /dev/null
+++ b/pkgs/servers/http/webfs/ls.c.patch
@@ -0,0 +1,13 @@
+# Source: homebrew
+# https://raw.githubusercontent.com/Homebrew/patches/0518a6d1/webfs/patch-ls.c
+--- ./ls.c.orig	Fri Oct 15 14:20:50 2004
++++ ./ls.c	Fri Oct 15 14:21:13 2004
+@@ -160,7 +160,7 @@
+     return buf;
+ }
+ 
+-#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
++#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__APPLE__)
+ static void strmode(mode_t mode, char *dest)
+ {
+     static const char *rwx[] = {
diff --git a/pkgs/servers/http/yaws/default.nix b/pkgs/servers/http/yaws/default.nix
index 871b3524f424..aae4589ebbe8 100644
--- a/pkgs/servers/http/yaws/default.nix
+++ b/pkgs/servers/http/yaws/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "yaws-${version}";
-  version = "2.0";
+  version = "2.0.5";
 
   src = fetchurl {
     url = "http://yaws.hyber.org/download/${name}.tar.gz";
-    sha256 = "1gwk44a07n7yvg900yrlfc6qpvjl64k2h2hddd1jaaay8lgpcch6";
+    sha256 = "00bnvf26xlhm3v3c6jzk5kcdk8jkwr1gbd2f4h329lyrpjsx30my";
   };
 
   # The tarball includes a symlink yaws -> yaws-1.95, which seems to be
@@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "A high performance HTTP 1.1 server in Erlang";
-    homepage = http://http://yaws.hyber.org;
+    homepage = http://yaws.hyber.org;
     license = licenses.bsd2;
     platforms = platforms.linux;
     maintainers = with maintainers; [ goibhniu the-kenny ];
diff --git a/pkgs/servers/icecast/default.nix b/pkgs/servers/icecast/default.nix
index 4a89c5ad83b1..f1bd1a4c9d86 100644
--- a/pkgs/servers/icecast/default.nix
+++ b/pkgs/servers/icecast/default.nix
@@ -3,15 +3,17 @@
 , libvorbis, libtheora, speex, libkate, libopus }:
 
 stdenv.mkDerivation rec {
-  name = "icecast-2.4.1";
+  name = "icecast-2.4.3";
 
   src = fetchurl {
     url = "http://downloads.xiph.org/releases/icecast/${name}.tar.gz";
-    sha256 = "0js5lylrgklhvvaksx46zc8lc975qb1bns8h1ms545nv071rxy23";
+    sha256 = "14n5vm2xnyn8y7kl46lnnlgv6v5fjykhc57ffdsh0qaxfs6a8p68";
   };
 
   buildInputs = [ libxml2 libxslt curl libvorbis libtheora speex libkate libopus ];
 
+  hardeningEnable = [ "pie" ];
+
   meta = {
     description = "Server software for streaming multimedia";
 
@@ -27,6 +29,7 @@ stdenv.mkDerivation rec {
     homepage = http://www.icecast.org;
     license = stdenv.lib.licenses.gpl2;
     maintainers = with stdenv.lib.maintainers; [ jcumming ];
+    platforms = with stdenv.lib.platforms; unix;
   };
 }
 
diff --git a/pkgs/servers/identd/oidentd/default.nix b/pkgs/servers/identd/oidentd/default.nix
index 04ad25b3fd39..1abe9512f589 100644
--- a/pkgs/servers/identd/oidentd/default.nix
+++ b/pkgs/servers/identd/oidentd/default.nix
@@ -1,11 +1,14 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "oidentd-2.0.8";
+  name = "oidentd-${version}";
+  version = "2.2.2";
+
+  CFLAGS = [ "--std=gnu89" ];
 
   src = fetchurl {
-    url = "mirror://sourceforge/ojnk/${name}.tar.gz";
-    sha256 = "0vzv2086rrxcaavrm3js7aqvyc0grgaqy78x61d8s7r8hz8vwk55";
+    url = "https://ftp.janikrabe.com/pub/oidentd/releases/${version}/${name}.tar.gz";
+    sha256 = "1svj7ymljp4s17d7jlx6602n9081714qsj5yymmv1s9wagzjqyn9";
   };
 
   meta = {
diff --git a/pkgs/servers/inginious/default.nix b/pkgs/servers/inginious/default.nix
new file mode 100644
index 000000000000..fbe226d3e3d3
--- /dev/null
+++ b/pkgs/servers/inginious/default.nix
@@ -0,0 +1,74 @@
+{ pkgs, lib, python2Packages }:
+with lib;
+
+let
+  pythonPackages = python2Packages;
+
+  docker_1_7_2 = pythonPackages.docker.overrideAttrs (oldAttrs: rec {
+    name = "docker-py-1.7.2";
+
+    src = pkgs.fetchurl {
+      url = "mirror://pypi/d/docker-py/${name}.tar.gz";
+      sha256 = "0k6hm3vmqh1d3wr9rryyif5n4rzvcffdlb1k4jvzp7g4996d3ccm";
+    };
+  });
+
+  webpy-custom = pythonPackages.web.override {
+    name = "web.py-INGI";
+    src = pkgs.fetchFromGitHub {
+      owner = "UCL-INGI";
+      repo = "webpy-INGI";
+      # tip of branch "ingi"
+      rev = "f487e78d65d6569eb70003e588d5c6ace54c384f";
+      sha256 = "159vwmb8554xk98rw380p3ah170r6gm861r1nqf2l452vvdfxscd";
+    };
+  };
+
+in pythonPackages.buildPythonApplication rec {
+  version = "0.3a2.dev0";
+  name = "inginious-${version}";
+
+  disabled = pythonPackages.isPy3k;
+
+  patchPhase = ''
+    # transient failures
+    substituteInPlace inginious/backend/tests/TestRemoteAgent.py \
+      --replace "test_update_task_directory" "noop"
+  '';
+
+  propagatedBuildInputs = with pythonPackages; [
+    requests
+    cgroup-utils docker_1_7_2 docutils PyLTI mock pygments
+    pymongo pyyaml rpyc sh simpleldap sphinx_rtd_theme tidylib
+    websocket_client watchdog webpy-custom flup
+  ];
+
+  buildInputs = with pythonPackages; [ nose selenium virtual-display ];
+
+  /* Hydra fix exists only on github for now.
+  src = pkgs.fetchurl {
+    url = "mirror://pypi/I/INGInious/INGInious-${version}.tar.gz";
+  };
+  */
+  src = pkgs.fetchFromGitHub {
+    owner = "UCL-INGI";
+    repo = "INGInious";
+    rev = "07d111c0a3045c7cc4e464d4adb8aa28b75a6948";
+    sha256 = "0kldbkc9yw1mgg5w5q5v8k2hz089c5c4rvxb5xhbagkzgm2gn230";
+  };
+
+  # Only patch shebangs in /bin, other scripts are run within docker
+  # containers and will fail if patched.
+  dontPatchShebangs = true;
+  preFixup = ''
+    patchShebangs $prefix/bin
+  '';
+
+  meta = {
+    broken = true;
+    description = "An intelligent grader that allows secured and automated testing of code made by students";
+    homepage = https://github.com/UCL-INGI/INGInious;
+    license = licenses.agpl3;
+    maintainers = with maintainers; [ layus ];
+  };
+}
diff --git a/pkgs/servers/interlock/default.nix b/pkgs/servers/interlock/default.nix
new file mode 100644
index 000000000000..0df055f9690f
--- /dev/null
+++ b/pkgs/servers/interlock/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, lib, sudo, coreutils, systemd, cryptsetup
+, mount, umount
+, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "interlock-${version}";
+  version = "2016.04.13";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/inversepath/interlock";
+
+  subPackages = [ "./cmd/interlock" ];
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "inversepath";
+    repo = "interlock";
+    sha256 = "06aqx3jy744yx29xyg8ips0dw16186hfqbxdv3hfrmwxmaxhl4lz";
+  };
+
+  goDeps = ./deps.nix;
+
+  nativeBuildInputs = [ sudo ];
+  buildFlags = [ "-tags textsecure" ];
+  postPatch = ''
+    grep -lr '/s\?bin/' | xargs sed -i \
+      -e 's|/bin/mount|${mount}/bin/mount|' \
+      -e 's|/bin/umount|${umount}/bin/umount|' \
+      -e 's|/bin/cp|${coreutils}/bin/cp|' \
+      -e 's|/bin/mv|${coreutils}/bin/mv|' \
+      -e 's|/bin/chown|${coreutils}/bin/chown|' \
+      -e 's|/bin/date|${coreutils}/bin/date|' \
+      -e 's|/sbin/poweroff|${systemd}/sbin/poweroff|' \
+      -e 's|/usr/bin/sudo|/run/wrappers/bin/sudo|' \
+      -e 's|/sbin/cryptsetup|${cryptsetup}/bin/cryptsetup|'
+  '';
+}
diff --git a/pkgs/servers/interlock/deps.nix b/pkgs/servers/interlock/deps.nix
new file mode 100644
index 000000000000..be5c05295731
--- /dev/null
+++ b/pkgs/servers/interlock/deps.nix
@@ -0,0 +1,65 @@
+[
+  {
+    goPackagePath = "gopkg.in/yaml.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/yaml.v2";
+      rev = "a83829b6f1293c91addabc89d0571c246397bbf4";
+      sha256 = "1m4dsmk90sbi17571h6pld44zxz7jc4lrnl4f27dpd1l8g5xvjhh";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "575fdbe86e5dd89229707ebec0575ce7d088a4a6";
+      sha256 = "1kgv1mkw9y404pk3lcwbs0vgl133mwyp294i18jg9hp10s5d56xa";
+    };
+  }
+  {
+    goPackagePath = "github.com/Sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Sirupsen/logrus";
+      rev = "be52937128b38f1d99787bb476c789e2af1147f1";
+      sha256 = "1m6vvd4pg4lwglhk54lv5mf6cc8h7bi0d9zb3gar4crz531r66y4";
+    };
+  }
+  {
+    goPackagePath = "github.com/agl/ed25519";
+    fetch = {
+      type = "git";
+      url = "https://github.com/agl/ed25519";
+      rev = "278e1ec8e8a6e017cd07577924d6766039146ced";
+      sha256 = "165d89cc6dl28j4hkn86pny0jz3sa6hamzdvpvwdj4iha3x6lzc9";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "59b73b37c1e45995477aae817e4a653c89a858db";
+      sha256 = "1dx22jvhvj34ivpr7gw01fncg9yyx35mbpal4mpgnqka7ajmgjsa";
+    };
+  }
+  {
+    goPackagePath = "github.com/janimo/textsecure";
+    fetch = {
+      type = "git";
+      url = "https://github.com/janimo/textsecure";
+      rev = "c38f429e48d6b2776d17b4171f216f132185b0f6";
+      sha256 = "191pwgfgphr0x04dwpvniax4wilpv52l25bw7d3igvnw302y7i94";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "62ac18b461605b4be188bbc7300e9aa2bc836cd4";
+      sha256 = "0lwwvbbwbf3yshxkfhn6z20gd45dkvnmw2ms36diiy34krgy402p";
+    };
+  }
+]
diff --git a/pkgs/servers/irc/charybdis/default.nix b/pkgs/servers/irc/charybdis/default.nix
index a38a25c8a5cb..befb4039ea09 100644
--- a/pkgs/servers/irc/charybdis/default.nix
+++ b/pkgs/servers/irc/charybdis/default.nix
@@ -1,12 +1,13 @@
-{ stdenv, fetchgit, bison, flex, openssl }:
+{ stdenv, fetchFromGitHub, bison, flex, openssl }:
 
 stdenv.mkDerivation rec {
-  name = "charybdis-3.5.0-rc1";
+  name = "charybdis-3.5.5";
 
-  src = fetchgit {
-    url = "https://github.com/atheme/charybdis.git";
-    rev = "43a9b61c427cd0f3fa2c192890b8a48d9ea6fb7f";
-    sha256 = "ae2c8a72e6a29c901f9b51759b542ee12c4ec918050a2d9d65e5635077a0fcef";
+  src = fetchFromGitHub {
+    owner = "charybdis-ircd";
+    repo = "charybdis";
+    rev = name;
+    sha256 = "16bl516hcj1chgzkfnpg9bf9s6zr314pqzhlz6641lgyzaw1z3w0";
   };
 
   patches = [
@@ -16,19 +17,19 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--enable-epoll"
     "--enable-ipv6"
-    "--enable-openssl=${openssl}"
+    "--enable-openssl=${openssl.dev}"
     "--with-program-prefix=charybdis-"
+    "--sysconfdir=/etc/charybdis"
   ];
 
   buildInputs = [ bison flex openssl ];
 
-  meta = {
-    description = "An extremely scalable ircd with some cooperation with the ratbox and ircu guys";
-    homepage    = https://github.com/atheme/charybdis;
-    license     = stdenv.lib.licenses.gpl2;
-    maintainers = [ stdenv.lib.maintainers.lassulus ];
-    platforms   = stdenv.lib.platforms.linux;
+  meta = with stdenv.lib; {
+    description = "IRCv3 server designed to be highly scalable";
+    homepage    = http://atheme.org/projects/charybdis.html;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ lassulus fpletz ];
+    platforms   = platforms.unix;
   };
 
-
 }
diff --git a/pkgs/servers/irc/ircd-hybrid/default.nix b/pkgs/servers/irc/ircd-hybrid/default.nix
index 512cee4b016c..c73c69e6ee5a 100644
--- a/pkgs/servers/irc/ircd-hybrid/default.nix
+++ b/pkgs/servers/irc/ircd-hybrid/default.nix
@@ -1,21 +1,23 @@
 { stdenv, fetchurl, openssl, zlib }:
 
-stdenv.mkDerivation {
-  name = "ircd-hybrid-8.2.2";
+stdenv.mkDerivation rec {
+  name = "ircd-hybrid-8.2.24";
 
   src = fetchurl {
-    url = mirror://sourceforge/ircd-hybrid/ircd-hybrid-8.2.2.tgz;
-    sha256 = "0k9w2mxgi03cpnmagshcr5v6qjgnmyidf966b50dd6yn1fgqcibm";
+    url = "mirror://sourceforge/ircd-hybrid/${name}.tgz";
+    sha256 = "03nmzrhqfsxwry316nm80m9p285v65fz75ns7fg623hcy65jv97a";
   };
 
   buildInputs = [ openssl zlib ];
 
   configureFlags =
-    "--with-nicklen=100 --with-topiclen=360 --enable-openssl=${openssl}";
+    "--with-nicklen=100 --with-topiclen=360 --enable-openssl=${openssl.dev}";
 
   postInstall = "echo postinstall; mkdir -p \${out}/ ; rm -rf \${out}/logs ; ln -s /home/ircd \${out}/logs;";
 
   meta = {
     description = "An IPv6-capable IRC server";
+    platforms = stdenv.lib.platforms.unix;
+    homepage = http://www.ircd-hybrid.org/;
   };
 }
diff --git a/pkgs/servers/irc/ngircd/default.nix b/pkgs/servers/irc/ngircd/default.nix
index ebc7e7c3128e..bdd88db09844 100644
--- a/pkgs/servers/irc/ngircd/default.nix
+++ b/pkgs/servers/irc/ngircd/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, zlib, openssl, pam, libiconv }:
 
 stdenv.mkDerivation rec {
-  name = "ngircd-21";
+  name = "ngircd-24";
 
   src = fetchurl {
-    url = "http://ngircd.barton.de/pub/ngircd/${name}.tar.xz";
-    sha256 = "19llx54zy6hc8k7kcs1f234qc20mqpnlnb30c663c42jxq5x6xii";
+    url = "https://ngircd.barton.de/pub/ngircd/${name}.tar.xz";
+    sha256 = "020h9d1awyxqr0l42x1fhs47q7cmm17fdxzjish8p2kq23ma0gqp";
   };
 
   configureFlags = [
diff --git a/pkgs/servers/irker/default.nix b/pkgs/servers/irker/default.nix
new file mode 100644
index 000000000000..002760ff0fd3
--- /dev/null
+++ b/pkgs/servers/irker/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitLab, python, pkgconfig
+, xmlto, docbook2x, docbook_xsl, docbook_xml_dtd_412 }:
+
+stdenv.mkDerivation rec {
+  name = "irker-${version}";
+  version = "2017-02-12";
+
+  src = fetchFromGitLab {
+    owner = "esr";
+    repo = "irker";
+    rev = "dc0f65a7846a3922338e72d8c6140053fe914b54";
+    sha256 = "1hslwqa0gqsnl3l6hd5hxpn0wlachxd51infifhlwhyhd6iwgx8p";
+  };
+
+  nativeBuildInputs = [ pkgconfig xmlto docbook2x docbook_xsl docbook_xml_dtd_412 ];
+
+  buildInputs = [
+    python
+    # Needed for proxy support I believe, which I haven't tested.
+    # Probably needs to be propagated and some wrapPython magic
+    # python.pkgs.pysocks
+  ];
+
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace '-o 0 -g 0' ""
+  '';
+
+  installFlags = [
+    "prefix=/"
+    "DESTDIR=$$out"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "IRC client that runs as a daemon accepting notification requests";
+    homepage = https://gitlab.com/esr/irker;
+    license = licenses.bsd2;
+    maintainers = with maintainers; [ dtzWill ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/isso/default.nix b/pkgs/servers/isso/default.nix
new file mode 100644
index 000000000000..5aafe55512be
--- /dev/null
+++ b/pkgs/servers/isso/default.nix
@@ -0,0 +1,54 @@
+{ stdenv, python2, fetchurl, fetchFromGitHub }:
+
+let python = python2.override {
+  packageOverrides = self: super: {
+    misaka = super.misaka.overridePythonAttrs (old: rec {
+      version = "1.0.2";
+      src = old.src.override {
+        inherit version;
+        sha256 = "05rmjxlfhghj90m1kc55lx3z8igabw5y8wmly66p3hphdy4f95v1";
+      };
+      propagatedBuildInputs = [ ];
+    });
+    html5lib = super.html5lib.overridePythonAttrs (old: rec {
+      version = "0.9999999";
+      src = old.src.override {
+        inherit version;
+        sha256 = "2612a191a8d5842bfa057e41ba50bbb9dcb722419d2408c78cff4758d0754868";
+      };
+      checkInputs = with self; [ nose flake8 ];
+      propagatedBuildInputs = with self; [ six ];
+      checkPhase = ''
+        nosetests
+      '';
+    });
+  };
+};
+
+in with python.pkgs; buildPythonApplication rec {
+  pname = "isso";
+  version = "0.10.6";
+
+  # no tests on PyPI
+  src = fetchFromGitHub {
+    owner = "posativ";
+    repo = pname;
+    rev = version;
+    sha256 = "19x9xbwd15fikhchyl4i1wrqx589hdmh279xhnxdszrq898igywb";
+  };
+
+  propagatedBuildInputs = [ misaka werkzeug ipaddr configparser html5lib ];
+
+  checkInputs = [ nose ];
+
+  checkPhase = ''
+    ${python.interpreter} setup.py nosetests
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A commenting server similar to Disqus";
+    homepage = https://posativ.org/isso/;
+    license = licenses.mit;
+    maintainers = with maintainers; [ fgaz ];
+  };
+}
diff --git a/pkgs/servers/jackett/default.nix b/pkgs/servers/jackett/default.nix
new file mode 100644
index 000000000000..5a87c423f4f7
--- /dev/null
+++ b/pkgs/servers/jackett/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, mono, curl, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "jackett-${version}";
+  version = "0.8.1014";
+
+  src = fetchurl {
+    url = "https://github.com/Jackett/Jackett/releases/download/v${version}/Jackett.Binaries.Mono.tar.gz";
+    sha256 = "0pvm9q8dpavkgsv180mw4y6555iixjv5s7mnmai9xzjspjpf264k";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out/{bin,share/${name}}
+    cp -r * $out/share/${name}
+
+    makeWrapper "${mono}/bin/mono" $out/bin/Jackett \
+      --add-flags "$out/share/${name}/JackettConsole.exe" \
+      --prefix LD_LIBRARY_PATH ':' "${curl.out}/lib"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "API Support for your favorite torrent trackers.";
+    homepage = https://github.com/Jackett/Jackett/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ edwtjo ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/jetbrains/youtrack.nix b/pkgs/servers/jetbrains/youtrack.nix
new file mode 100644
index 000000000000..7e368bf295b6
--- /dev/null
+++ b/pkgs/servers/jetbrains/youtrack.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, makeWrapper, jre }:
+
+stdenv.mkDerivation rec {
+  name = "youtrack-${version}";
+  version = "2018.1.41051";
+
+  jar = fetchurl {
+    url = "https://download.jetbrains.com/charisma/${name}.jar";
+    sha256 = "1sznay3lbyb2i977103hzh61rw1bpkdv0raffbir68apmvv1r0rb";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  unpackPhase = "true";
+
+  installPhase = ''
+    runHook preInstall
+    makeWrapper ${jre}/bin/java $out/bin/youtrack --add-flags "\$YOUTRACK_JVM_OPTS -jar $jar"
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    description = ''
+      Issue Tracking and Project Management Tool for Developers
+    '';
+    maintainers = with maintainers; [ yorickvp ];
+    # https://www.jetbrains.com/youtrack/buy/license.html
+    license = licenses.unfree;
+  };
+}
diff --git a/pkgs/servers/kippo/default.nix b/pkgs/servers/kippo/default.nix
index 30d3fc3ab180..554401438705 100644
--- a/pkgs/servers/kippo/default.nix
+++ b/pkgs/servers/kippo/default.nix
@@ -25,16 +25,48 @@
 #
 # Use this package at your own risk.
 
-{stdenv, pkgs, config, fetchurl, ... }:
+{stdenv, fetchurl, pythonPackages }:
 
-stdenv.mkDerivation rec {
+let
+
+  twisted_13 = pythonPackages.buildPythonPackage rec {
+    # NOTE: When updating please check if new versions still cause issues
+    # to packages like carbon (http://stackoverflow.com/questions/19894708/cant-start-carbon-12-04-python-error-importerror-cannot-import-name-daem)
+    disabled = pythonPackages.isPy3k;
+
+    name = "Twisted-13.2.0";
+    src = fetchurl {
+      url = "mirror://pypi/T/Twisted/${name}.tar.bz2";
+      sha256 = "1wrcqv5lvgwk2aq83qb2s2ng2vx14hbjjk2gc30cg6h1iiipal89";
+    };
+
+    propagatedBuildInputs = with pythonPackages; [ zope_interface ];
+
+    # Generate Twisted's plug-in cache.  Twited users must do it as well.  See
+    # http://twistedmatrix.com/documents/current/core/howto/plugin.html#auto3
+    # and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477103 for
+    # details.
+    postInstall = "$out/bin/twistd --help > /dev/null";
+
+    meta = with stdenv.lib; {
+      homepage = http://twistedmatrix.com/;
+      description = "Twisted, an event-driven networking engine written in Python";
+      longDescription = ''
+        Twisted is an event-driven networking engine written in Python
+        and licensed under the MIT license.
+      '';
+      license = licenses.mit;
+    };
+  };
+
+in stdenv.mkDerivation rec {
     name = "kippo-${version}";
     version = "0.8";
     src = fetchurl {
-      url = "https://kippo.googlecode.com/files/kippo-${version}.tar.gz";
-      sha1 = "f57a5cf88171cb005afe44a4b33cb16f825c33d6";
+      url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/kippo/${name}.tar.gz";
+      sha256 = "0rd2mk36d02qd24z8s4xyy64fy54rzpar4379iq4dcjwg7l7f63d";
     };
-    buildInputs = with pkgs.pythonPackages; [ pycrypto pyasn1 twisted ];
+    buildInputs = with pythonPackages; [ pycrypto pyasn1 twisted_13 ];
     installPhase = ''
         substituteInPlace ./kippo.tac --replace "kippo.cfg" "$out/src/kippo.cfg"
         substituteInPlace ./kippo.cfg --replace "log_path = log" "log_path = /var/log/kippo" \
@@ -44,15 +76,17 @@ stdenv.mkDerivation rec {
             --replace "data_path = data" "data_path = /var/lib/kippo/data" \
             --replace "txtcmds_path = txtcmds" "txtcmds_path = /var/lib/kippo/txtcmds" \
             --replace "public_key = public.key" "public_key = /var/lib/kippo/keys/public.key" \
-            --replace "private_key = private.key" "private_key = /var/lib/kippo/keys/private.key" 
+            --replace "private_key = private.key" "private_key = /var/lib/kippo/keys/private.key"
         mkdir -p $out/bin
         mkdir -p $out/src
-        mv ./* $out/src 
+        mv ./* $out/src
         mv $out/src/utils/* $out/bin
         '';
 
+    passthru.twisted = twisted_13;
+
     meta = with stdenv.lib; {
-      homepage = https://code.google.com/p/kippo;
+      homepage = https://github.com/desaster/kippo;
       description = "SSH Honeypot";
       longDescription = ''
         Default port is 2222. Recommend using something like this for port redirection to default SSH port:
diff --git a/pkgs/servers/kwakd/default.nix b/pkgs/servers/kwakd/default.nix
new file mode 100644
index 000000000000..7c7755dee482
--- /dev/null
+++ b/pkgs/servers/kwakd/default.nix
@@ -0,0 +1,28 @@
+{ lib, fetchFromGitHub, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "kwakd-${version}";
+  version = "0.5";
+
+  src = fetchFromGitHub {
+    owner = "fetchinson";
+    repo = "kwakd";
+    rev = "acdf0e1491204ae30622a60fde0bcae4769f78be";
+    sha256 = "1inf9ngrbxmkkdhqf1xday12nf0hxjxlx1810phkmivyyp6fl3nj";
+  };
+
+  postInstall = ''
+    serviceDir=$out/share/dbus-1/system-services
+    mkdir -p $serviceDir
+    cp kwakd.service $serviceDir/
+    substituteInPlace $serviceDir/kwakd.service \
+      --replace "kwakd -p 80" "$out/bin/kwakd -p 80"
+  '';
+
+  meta = with lib; {
+    description = "A super small webserver that serves blank pages";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.nicknovitski ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/ldap/389/default.nix b/pkgs/servers/ldap/389/default.nix
index 685d365ed185..6826df5f6e86 100644
--- a/pkgs/servers/ldap/389/default.nix
+++ b/pkgs/servers/ldap/389/default.nix
@@ -1,25 +1,27 @@
-{ stdenv, fetchurl, pkgconfig, perl, pam, nspr, nss, openldap, db, cyrus_sasl
-, svrcore, icu, net_snmp, kerberos, pcre, perlPackages
+{ stdenv, fetchurl, fetchpatch, pkgconfig, perl, pam, nspr, nss, openldap
+, db, cyrus_sasl, svrcore, icu, net_snmp, kerberos, pcre, perlPackages
 }:
 let
-  version = "1.3.3.9";
+  version = "1.3.5.19";
 in
 stdenv.mkDerivation rec {
   name = "389-ds-base-${version}";
 
   src = fetchurl {
     url = "http://directory.fedoraproject.org/binaries/${name}.tar.bz2";
-    sha256 = "1qqwv5j60f38hz4xpbzn4pixhkj07yjzbp7kz7cvfkgvdwy9jqxx";
+    sha256 = "1r1n44xfvy51r4r1180dfmjziyj3pqxwmnv6rjvvvjjm87fslmdd";
   };
 
+  nativeBuildInputs = [ pkgconfig ];
   buildInputs = [
-    pkgconfig perl pam nspr nss openldap db cyrus_sasl svrcore icu
+    perl pam nspr nss openldap db cyrus_sasl svrcore icu
     net_snmp kerberos pcre
   ] ++ (with perlPackages; [ MozillaLdap NetAddrIP DBFile ]);
 
   # TODO: Fix bin/ds-logpipe.py, bin/logconv, bin/cl-dump
 
-  patches = [ ./perl-path.patch ];
+  patches = [ ./perl-path.patch
+  ];
 
   preConfigure = ''
     # Create perl paths for library imports in perl scripts
@@ -33,12 +35,14 @@ stdenv.mkDerivation rec {
   configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
-    "--with-openldap=${openldap}"
-    "--with-db=${db}"
-    "--with-sasl=${cyrus_sasl}"
+    "--with-openldap"
+    "--with-db"
+    "--with-db-inc=${db.dev}/include"
+    "--with-db-lib=${db.out}/lib"
+    "--with-sasl=${cyrus_sasl.dev}"
     "--with-netsnmp=${net_snmp}"
   ];
-  
+
   preInstall = ''
     # The makefile doesn't create this directory for whatever reason
     mkdir -p $out/lib/dirsrv
@@ -52,8 +56,8 @@ stdenv.mkDerivation rec {
   passthru.version = version;
 
   meta = with stdenv.lib; {
-    homepage = https://directory.fedoraproject.org/;
-    description = "enterprise-class Open Source LDAP server for Linux";
+    homepage = http://www.port389.org/;
+    description = "Enterprise-class Open Source LDAP server for Linux";
     license = licenses.gpl2;
     platforms = platforms.linux;
     maintainers = with maintainers; [ wkennington ];
diff --git a/pkgs/servers/limesurvey/default.nix b/pkgs/servers/limesurvey/default.nix
index 89ce5a644d80..270844730d88 100644
--- a/pkgs/servers/limesurvey/default.nix
+++ b/pkgs/servers/limesurvey/default.nix
@@ -37,5 +37,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl2;
     homepage = https://www.limesurvey.org;
     maintainers = with maintainers; [offline];
+    platforms = with platforms; unix;
   };
 }
diff --git a/pkgs/servers/mail/archiveopteryx/default.nix b/pkgs/servers/mail/archiveopteryx/default.nix
new file mode 100644
index 000000000000..080cbc897756
--- /dev/null
+++ b/pkgs/servers/mail/archiveopteryx/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, openssl, perl, zlib, jam }:
+stdenv.mkDerivation rec {
+  version = "3.2.0";
+  name = "archiveopteryx-${version}";
+
+  src = fetchurl {
+    url = "http://archiveopteryx.org/download/${name}.tar.bz2";
+    sha256 = "0i0zg8di8nbh96qnyyr156ikwcsq1w9b2291bazm5whb351flmqx";
+  };
+
+  nativeBuildInputs = [ jam ];
+  buildInputs = [ openssl perl zlib ];
+
+  preConfigure = ''
+    export INSTALLROOT=installroot
+    sed -i 's:BINDIR = $(PREFIX)/bin:BINDIR = '$out'/bin:' ./Jamsettings
+    sed -i 's:SBINDIR = $(PREFIX)/sbin:SBINDIR = '$out'/bin:' ./Jamsettings
+    sed -i 's:LIBDIR = $(PREFIX)/lib:LIBDIR = '$out'/lib:' ./Jamsettings
+    sed -i 's:MANDIR = $(PREFIX)/man:MANDIR = '$out'/share/man:' ./Jamsettings
+    sed -i 's:READMEDIR = $(PREFIX):READMEDIR = '$out'/share/doc/archiveopteryx:' ./Jamsettings
+  '';
+
+  # fix build on gcc7
+  NIX_CFLAGS_COMPILE = [
+    "-Wno-error=builtin-declaration-mismatch"
+    "-Wno-error=implicit-fallthrough"
+  ];
+
+  buildPhase = ''jam "-j$NIX_BUILD_CORES" '';
+  installPhase = ''
+    jam install
+    mv installroot/$out $out
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://archiveopteryx.org/;
+    description = "An advanced PostgreSQL-based IMAP/POP server";
+    license = licenses.postgresql;
+    maintainers = [ maintainers.phunehehe ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/mail/clamsmtp/default.nix b/pkgs/servers/mail/clamsmtp/default.nix
new file mode 100644
index 000000000000..7214c08d2427
--- /dev/null
+++ b/pkgs/servers/mail/clamsmtp/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "clamsmtp-" + version;
+  version = "1.10";
+
+  src = fetchurl {
+    url = "http://thewalter.net/stef/software/clamsmtp/${name}.tar.gz";
+    sha256 = "0apr1pxifw6f1rbbsdrrwzs1dnhybg4hda3qqhqcw7p14r5xnbx5";
+  };
+
+  patches = [ ./header-order.patch ];
+
+  meta = with stdenv.lib; {
+    description = "SMTP filter that allows to check for viruses using the ClamAV
+                   anti-virus software";
+    homepage = http://thewalter.net/stef/software/clamsmtp/;
+    license = licenses.bsd3;
+    maintainers = [ maintainers.ekleog ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/mail/clamsmtp/header-order.patch b/pkgs/servers/mail/clamsmtp/header-order.patch
new file mode 100644
index 000000000000..102ae0a471dd
--- /dev/null
+++ b/pkgs/servers/mail/clamsmtp/header-order.patch
@@ -0,0 +1,25 @@
+diff --git a/common/smtppass.c b/common/smtppass.c
+index d9be1ba..4a366f4 100644
+--- a/common/smtppass.c
++++ b/common/smtppass.c
+@@ -60,15 +60,15 @@
+ 
+ #include "usuals.h"
+ 
+-#ifdef LINUX_TRANSPARENT_PROXY
+-#include <linux/netfilter_ipv4.h>
+-#endif
+-
+ #include "compat.h"
+ #include "sock_any.h"
+ #include "stringx.h"
+ #include "sppriv.h"
+ 
++#ifdef LINUX_TRANSPARENT_PROXY
++#include <linux/netfilter_ipv4.h>
++#endif
++
+ /* -----------------------------------------------------------------------
+  *  STRUCTURES
+  */
+
diff --git a/pkgs/servers/mail/dkimproxy/default.nix b/pkgs/servers/mail/dkimproxy/default.nix
new file mode 100644
index 000000000000..9abf95fb6d60
--- /dev/null
+++ b/pkgs/servers/mail/dkimproxy/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, perl, fetchurl, Error, MailDKIM, MIMEtools, NetServer }:
+
+let
+  pkg = "dkimproxy";
+  version = "1.4.1";
+in
+stdenv.mkDerivation rec {
+  name = "${pkg}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/dkimproxy/${name}.tar.gz";
+    sha256 = "1gc5c7lg2qrlck7b0lvjfqr824ch6jkrzkpsn0gjvlzg7hfmld75";
+  };
+
+  # Idea taken from pkgs/development/perl-modules/generic/builder.sh
+  preFixup = ''
+    perlFlags=
+    for i in $(IFS=:; echo $PERL5LIB); do
+      perlFlags="$perlFlags -I$i"
+    done
+    for f in $(ls $out/bin); do
+      sed -i $out/bin/$f -e "s|#\!\(.*/perl.*\)$|#\! \1 $perlFlags|"
+    done
+  '';
+
+  buildInputs = [ perl ];
+  propagatedBuildInputs = [ Error MailDKIM MIMEtools NetServer ];
+
+  meta = with stdenv.lib; {
+    description = "SMTP-proxy that signs and/or verifies emails";
+    homepage = http://dkimproxy.sourceforge.net/;
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.ekleog ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/mail/dovecot/2.2.x-module_dir.patch b/pkgs/servers/mail/dovecot/2.2.x-module_dir.patch
index 3ba11d41b1bd..1914933c558c 100644
--- a/pkgs/servers/mail/dovecot/2.2.x-module_dir.patch
+++ b/pkgs/servers/mail/dovecot/2.2.x-module_dir.patch
@@ -1,119 +1,122 @@
-diff -ur dovecot-2.2.12-orig/src/auth/main.c dovecot-2.2.12/src/auth/main.c
---- dovecot-2.2.12-orig/src/auth/main.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/auth/main.c	2014-03-14 09:28:17.642334838 +0100
-@@ -193,7 +193,7 @@
+diff --git a/src/auth/main.c b/src/auth/main.c
+index 5a87c57..74bff52 100644
+--- a/src/auth/main.c
++++ b/src/auth/main.c
+@@ -194,7 +194,7 @@ static void main_preinit(void)
  	mod_set.debug = global_auth_settings->debug;
  	mod_set.filter_callback = auth_module_filter;
  
 -	modules = module_dir_load(AUTH_MODULE_DIR, NULL, &mod_set);
-+	modules = module_dir_load("/var/lib/dovecot/modules/auth", NULL, &mod_set);
++	modules = module_dir_load("/etc/dovecot/modules/auth", NULL, &mod_set);
  	module_dir_init(modules);
  
  	if (!worker)
-@@ -223,7 +223,7 @@
+@@ -225,7 +225,7 @@ void auth_module_load(const char *names)
  	mod_set.debug = global_auth_settings->debug;
  	mod_set.ignore_missing = TRUE;
  
 -	modules = module_dir_load_missing(modules, AUTH_MODULE_DIR, names,
-+	modules = module_dir_load_missing(modules, "/var/lib/dovecot/modules/auth", names,
++	modules = module_dir_load_missing(modules, "/etc/dovecot/modules/auth", names,
  					  &mod_set);
  	module_dir_init(modules);
  }
-diff -ur dovecot-2.2.12-orig/src/config/all-settings.c dovecot-2.2.12/src/config/all-settings.c
---- dovecot-2.2.12-orig/src/config/all-settings.c	2014-02-11 23:31:37.000000000 +0100
-+++ dovecot-2.2.12/src/config/all-settings.c	2014-03-14 09:32:08.907608311 +0100
-@@ -773,7 +773,7 @@
+diff --git a/src/config/all-settings.c b/src/config/all-settings.c
+index de223a5..2df2d21 100644
+--- a/src/config/all-settings.c
++++ b/src/config/all-settings.c
+@@ -836,7 +836,7 @@ static const struct mail_user_settings mail_user_default_settings = {
  	.last_valid_gid = 0,
  
  	.mail_plugins = "",
 -	.mail_plugin_dir = MODULEDIR,
-+	.mail_plugin_dir = "/var/lib/dovecot/modules",
++	.mail_plugin_dir = "/etc/dovecot/modules",
  
  	.mail_log_prefix = "%s(%u): ",
  
-@@ -3304,7 +3304,7 @@
+@@ -3545,7 +3545,7 @@ const struct doveadm_settings doveadm_default_settings = {
  	.base_dir = PKG_RUNDIR,
  	.libexec_dir = PKG_LIBEXECDIR,
  	.mail_plugins = "",
 -	.mail_plugin_dir = MODULEDIR,
-+	.mail_plugin_dir = "/var/lib/dovecot/modules",
++	.mail_plugin_dir = "/etc/dovecot/modules",
+ 	.auth_debug = FALSE,
  	.auth_socket_path = "auth-userdb",
  	.doveadm_socket_path = "doveadm-server",
- 	.doveadm_worker_count = 0,
-Only in dovecot-2.2.12/src/config: all-settings.c.orig
-diff -ur dovecot-2.2.12-orig/src/config/config-parser.c dovecot-2.2.12/src/config/config-parser.c
---- dovecot-2.2.12-orig/src/config/config-parser.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/config/config-parser.c	2014-03-14 09:28:17.645334840 +0100
-@@ -990,7 +990,7 @@
+diff --git a/src/config/config-parser.c b/src/config/config-parser.c
+index 2a5009a..134f92b 100644
+--- a/src/config/config-parser.c
++++ b/src/config/config-parser.c
+@@ -1047,7 +1047,7 @@ void config_parse_load_modules(void)
  
  	memset(&mod_set, 0, sizeof(mod_set));
  	mod_set.abi_version = DOVECOT_ABI_VERSION;
 -	modules = module_dir_load(CONFIG_MODULE_DIR, NULL, &mod_set);
-+	modules = module_dir_load("/var/lib/dovecot/modules/settings", NULL, &mod_set);
++	modules = module_dir_load("/etc/dovecot/modules/settings", NULL, &mod_set);
  	module_dir_init(modules);
  
  	i_array_init(&new_roots, 64);
-diff -ur dovecot-2.2.12-orig/src/dict/main.c dovecot-2.2.12/src/dict/main.c
---- dovecot-2.2.12-orig/src/dict/main.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/dict/main.c	2014-03-14 09:28:17.645334840 +0100
-@@ -61,7 +61,7 @@
+diff --git a/src/dict/main.c b/src/dict/main.c
+index e6c945e..06ad6c5 100644
+--- a/src/dict/main.c
++++ b/src/dict/main.c
+@@ -62,7 +62,7 @@ static void main_init(void)
  	mod_set.abi_version = DOVECOT_ABI_VERSION;
  	mod_set.require_init_funcs = TRUE;
  
 -	modules = module_dir_load(DICT_MODULE_DIR, NULL, &mod_set);
-+	modules = module_dir_load("/var/lib/dovecot/modules/dict", NULL, &mod_set);
++	modules = module_dir_load("/etc/dovecot/modules/dict", NULL, &mod_set);
  	module_dir_init(modules);
  
  	/* Register only after loading modules. They may contain SQL drivers,
-diff -ur dovecot-2.2.12-orig/src/doveadm/doveadm-settings.c dovecot-2.2.12/src/doveadm/doveadm-settings.c
---- dovecot-2.2.12-orig/src/doveadm/doveadm-settings.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/doveadm/doveadm-settings.c	2014-03-14 09:32:56.540087069 +0100
-@@ -77,7 +77,7 @@
+diff --git a/src/doveadm/doveadm-settings.c b/src/doveadm/doveadm-settings.c
+index df12284..19c18da 100644
+--- a/src/doveadm/doveadm-settings.c
++++ b/src/doveadm/doveadm-settings.c
+@@ -81,7 +81,7 @@ const struct doveadm_settings doveadm_default_settings = {
  	.base_dir = PKG_RUNDIR,
  	.libexec_dir = PKG_LIBEXECDIR,
  	.mail_plugins = "",
 -	.mail_plugin_dir = MODULEDIR,
-+	.mail_plugin_dir = "/var/lib/dovecot/modules",
++	.mail_plugin_dir = "/etc/dovecot/modules",
+ 	.auth_debug = FALSE,
  	.auth_socket_path = "auth-userdb",
  	.doveadm_socket_path = "doveadm-server",
- 	.doveadm_worker_count = 0,
-Only in dovecot-2.2.12/src/doveadm: doveadm-settings.c.orig
-diff -ur dovecot-2.2.12-orig/src/lib-fs/fs-api.c dovecot-2.2.12/src/lib-fs/fs-api.c
---- dovecot-2.2.12-orig/src/lib-fs/fs-api.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/lib-fs/fs-api.c	2014-03-14 09:28:17.646334843 +0100
-@@ -89,7 +89,7 @@
+diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c
+index b50fbe0..ace3aff 100644
+--- a/src/lib-fs/fs-api.c
++++ b/src/lib-fs/fs-api.c
+@@ -114,7 +114,7 @@ static void fs_class_try_load_plugin(const char *driver)
  	mod_set.abi_version = DOVECOT_ABI_VERSION;
  	mod_set.ignore_missing = TRUE;
  
 -	fs_modules = module_dir_load_missing(fs_modules, MODULE_DIR,
-+	fs_modules = module_dir_load_missing(fs_modules, "/var/lib/dovecot/modules",
++	fs_modules = module_dir_load_missing(fs_modules, "/etc/dovecot/modules",
  					     module_name, &mod_set);
  	module_dir_init(fs_modules);
  
-Only in dovecot-2.2.12/src/lib-fs: fs-api.c.orig
-diff -ur dovecot-2.2.12-orig/src/lib-ssl-iostream/iostream-ssl.c dovecot-2.2.12/src/lib-ssl-iostream/iostream-ssl.c
---- dovecot-2.2.12-orig/src/lib-ssl-iostream/iostream-ssl.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/lib-ssl-iostream/iostream-ssl.c	2014-03-14 09:28:17.646334843 +0100
-@@ -30,7 +30,7 @@
- 	memset(&mod_set, 0, sizeof(mod_set));
+diff --git a/src/lib-ssl-iostream/iostream-ssl.c b/src/lib-ssl-iostream/iostream-ssl.c
+index a0659ab..dba3729 100644
+--- a/src/lib-ssl-iostream/iostream-ssl.c
++++ b/src/lib-ssl-iostream/iostream-ssl.c
+@@ -34,7 +34,7 @@ static int ssl_module_load(const char **error_r)
  	mod_set.abi_version = DOVECOT_ABI_VERSION;
  	mod_set.setting_name = "<built-in lib-ssl-iostream lookup>";
+ 	mod_set.require_init_funcs = TRUE;
 -	ssl_module = module_dir_load(MODULE_DIR, plugin_name, &mod_set);
-+	ssl_module = module_dir_load("/var/lib/dovecot/modules", plugin_name, &mod_set);
- 
- 	ssl_vfuncs = module_get_symbol(ssl_module, "ssl_vfuncs");
- 	if (ssl_vfuncs == NULL) {
-Only in dovecot-2.2.12/src/lib-ssl-iostream: iostream-ssl.c.orig
-diff -ur dovecot-2.2.12-orig/src/lib-storage/mail-storage-settings.c dovecot-2.2.12/src/lib-storage/mail-storage-settings.c
---- dovecot-2.2.12-orig/src/lib-storage/mail-storage-settings.c	2014-02-11 23:23:37.000000000 +0100
-+++ dovecot-2.2.12/src/lib-storage/mail-storage-settings.c	2014-03-14 09:28:17.646334843 +0100
-@@ -262,7 +262,7 @@
++	ssl_module = module_dir_load("/etc/dovecot/modules", plugin_name, &mod_set);
+ 	if (module_dir_try_load_missing(&ssl_module, MODULE_DIR, plugin_name,
+ 					&mod_set, error_r) < 0)
+ 		return -1;
+diff --git a/src/lib-storage/mail-storage-settings.c b/src/lib-storage/mail-storage-settings.c
+index e2233bf..bbf981e 100644
+--- a/src/lib-storage/mail-storage-settings.c
++++ b/src/lib-storage/mail-storage-settings.c
+@@ -274,7 +274,7 @@ static const struct mail_user_settings mail_user_default_settings = {
  	.last_valid_gid = 0,
  
  	.mail_plugins = "",
 -	.mail_plugin_dir = MODULEDIR,
-+	.mail_plugin_dir = "/var/lib/dovecot/modules",
++	.mail_plugin_dir = "/etc/dovecot/modules",
  
  	.mail_log_prefix = "%s(%u): ",
  
-Only in dovecot-2.2.12/src/lib-storage: mail-storage-settings.c.orig
diff --git a/pkgs/servers/mail/dovecot/2.2.x.nix b/pkgs/servers/mail/dovecot/2.2.x.nix
deleted file mode 100644
index be671b7f0e7b..000000000000
--- a/pkgs/servers/mail/dovecot/2.2.x.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-{ stdenv, fetchurl, perl, systemd, openssl, pam, bzip2, zlib, openldap
-, inotify-tools, clucene_core_2, sqlite }:
-
-stdenv.mkDerivation rec {
-  name = "dovecot-2.2.16";
-
-  buildInputs = [perl openssl bzip2 zlib openldap clucene_core_2 sqlite]
-    ++ stdenv.lib.optionals (stdenv.isLinux) [ systemd pam inotify-tools ];
-
-  src = fetchurl {
-    url = "http://dovecot.org/releases/2.2/${name}.tar.gz";
-    sha256 = "1w6gg4h9mxg3i8faqpmgj19imzyy001b0v8ihch8ma3zl63i5kjn";
-  };
-
-  preConfigure = ''
-    substituteInPlace src/config/settings-get.pl --replace \
-      "/usr/bin/env perl" "${perl}/bin/perl"
-  '';
-
-  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
-    install_name_tool -change libclucene-shared.1.dylib \
-        ${clucene_core_2}/lib/libclucene-shared.1.dylib \
-        $out/lib/dovecot/lib21_fts_lucene_plugin.so
-    install_name_tool -change libclucene-core.1.dylib \
-        ${clucene_core_2}/lib/libclucene-core.1.dylib \
-        $out/lib/dovecot/lib21_fts_lucene_plugin.so
-  '';
-
-  patches = [
-    # Make dovecot look for plugins in /var/lib/dovecot/modules
-    # so we can symlink plugins from several packages there
-    # The symlinking needs to be done in NixOS, as part of the
-    # dovecot service start-up
-    ./2.2.x-module_dir.patch
-  ];
-
-  configureFlags = [
-    # It will hardcode this for /var/lib/dovecot.
-    # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626211
-    "--localstatedir=/var"
-    "--with-ldap"
-    "--with-lucene"
-    "--with-ssl=openssl"
-    "--with-sqlite"
-    "--with-zlib"
-    "--with-bzlib"
-  ] ++ stdenv.lib.optionals (stdenv.isLinux) [
-    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
-  ];
-
-  meta = {
-    homepage = "http://dovecot.org/";
-    description = "Open source IMAP and POP3 email server written with security primarily in mind";
-    maintainers = with stdenv.lib.maintainers; [viric simons rickynils];
-    hydraPlatforms = stdenv.lib.platforms.linux;
-  };
-}
diff --git a/pkgs/servers/mail/dovecot/default.nix b/pkgs/servers/mail/dovecot/default.nix
index 3997370154e4..c9065d041618 100644
--- a/pkgs/servers/mail/dovecot/default.nix
+++ b/pkgs/servers/mail/dovecot/default.nix
@@ -1,27 +1,78 @@
-{stdenv, fetchurl, openssl, pam, bzip2, zlib, inotify-tools, openldap}:
+{ stdenv, lib, fetchurl, fetchpatch, perl, pkgconfig, systemd, openssl
+, bzip2, zlib, lz4, inotify-tools, pam, libcap
+, clucene_core_2, icu, openldap, libsodium, libstemmer
+# Auth modules
+, withMySQL ? false, mysql
+, withPgSQL ? false, postgresql
+, withSQLite ? true, sqlite
+}:
 
 stdenv.mkDerivation rec {
-  name = "dovecot-2.1.17";
+  name = "dovecot-2.3.1";
 
-  buildInputs = [openssl bzip2 zlib openldap] ++ stdenv.lib.optionals stdenv.isLinux [pam inotify-tools];
+  nativeBuildInputs = [ perl pkgconfig ];
+  buildInputs =
+    [ openssl bzip2 zlib lz4 clucene_core_2 icu openldap libsodium libstemmer ]
+    ++ lib.optionals (stdenv.isLinux) [ systemd pam libcap inotify-tools ]
+    ++ lib.optional withMySQL mysql.connector-c
+    ++ lib.optional withPgSQL postgresql
+    ++ lib.optional withSQLite sqlite;
 
   src = fetchurl {
-    url = "http://dovecot.org/releases/2.1/${name}.tar.gz";
-    sha256 = "06j2s5bcrmc0dhjsyavqiss3k65p6xn00a7sffpsv6w3yngv777m";
+    url = "http://dovecot.org/releases/2.3/${name}.tar.gz";
+    sha256 = "14zva4f8k64x86sm9n21cp2yvrpph6k6k52bm22a00pxjwdq50q8";
   };
 
-  # It will hardcode this for /var/lib/dovecot.
-  # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626211
+  preConfigure = ''
+    patchShebangs src/config/settings-get.pl
+  '';
+
+  # We need this for sysconfdir, see remark below.
+  installFlags = [ "DESTDIR=$(out)" ];
+
+  postInstall = ''
+    cp -r $out/$out/* $out
+    rm -rf $out/$(echo "$out" | cut -d "/" -f2)
+  '' + lib.optionalString stdenv.isDarwin ''
+    install_name_tool -change libclucene-shared.1.dylib \
+        ${clucene_core_2}/lib/libclucene-shared.1.dylib \
+        $out/lib/dovecot/lib21_fts_lucene_plugin.so
+    install_name_tool -change libclucene-core.1.dylib \
+        ${clucene_core_2}/lib/libclucene-core.1.dylib \
+        $out/lib/dovecot/lib21_fts_lucene_plugin.so
+  '';
+
+  patches = [
+    # Make dovecot look for plugins in /etc/dovecot/modules
+    # so we can symlink plugins from several packages there.
+    # The symlinking needs to be done in NixOS.
+    ./2.2.x-module_dir.patch
+  ];
+
   configureFlags = [
+    # It will hardcode this for /var/lib/dovecot.
+    # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626211
     "--localstatedir=/var"
+    # We need this so utilities default to reading /etc/dovecot/dovecot.conf file.
+    "--sysconfdir=/etc"
     "--with-ldap"
-  ];
+    "--with-ssl=openssl"
+    "--with-zlib"
+    "--with-bzlib"
+    "--with-lz4"
+    "--with-ldap"
+    "--with-lucene"
+    "--with-icu"
+  ] ++ lib.optional (stdenv.isLinux) "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
+    ++ lib.optional (stdenv.isDarwin) "--enable-static"
+    ++ lib.optional withMySQL "--with-mysql"
+    ++ lib.optional withPgSQL "--with-pgsql"
+    ++ lib.optional withSQLite "--with-sqlite";
 
   meta = {
-    homepage = "http://dovecot.org/";
+    homepage = https://dovecot.org/;
     description = "Open source IMAP and POP3 email server written with security primarily in mind";
-    maintainers = with stdenv.lib.maintainers; [viric simons];
-    hydraPlatforms = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ viric peti rickynils fpletz ];
+    platforms = stdenv.lib.platforms.unix;
   };
-
 }
diff --git a/pkgs/servers/mail/dovecot-pigeonhole/default.nix b/pkgs/servers/mail/dovecot/plugins/pigeonhole/default.nix
index 3ee73520d7ad..e98c58c891a1 100644
--- a/pkgs/servers/mail/dovecot-pigeonhole/default.nix
+++ b/pkgs/servers/mail/dovecot/plugins/pigeonhole/default.nix
@@ -1,15 +1,15 @@
-{stdenv, fetchurl, dovecot22, openssl}:
+{ stdenv, fetchurl, dovecot, openssl }:
 
 stdenv.mkDerivation rec {
   name = "dovecot-pigeonhole-${version}";
-  version = "0.4.3";
+  version = "0.5.1";
 
   src = fetchurl {
-    url = "http://pigeonhole.dovecot.org/releases/2.2/dovecot-2.2-pigeonhole-${version}.tar.gz";
-    sha256 = "0mypnkc980s3kd1bmy4f93dliwg6n8jfsac8r51jrpvv0ymz94nn";
-  };  
+    url = "http://pigeonhole.dovecot.org/releases/2.3/dovecot-2.3-pigeonhole-${version}.tar.gz";
+    sha256 = "0ivmaxic6cygfphvlrvy0xgggydm7j7kjv1ssfqbr08q4rcsmc73";
+  };
 
-  buildInputs = [ dovecot22 openssl ];
+  buildInputs = [ dovecot openssl ];
 
   preConfigure = ''
     substituteInPlace src/managesieve/managesieve-settings.c --replace \
@@ -18,18 +18,21 @@ stdenv.mkDerivation rec {
     substituteInPlace src/managesieve-login/managesieve-login-settings.c --replace \
       ".executable = \"managesieve-login\"" \
       ".executable = \"$out/libexec/dovecot/managesieve-login\""
-  ''; 
+  '';
 
-  configureFlags = [ 
-    "--with-dovecot=${dovecot22}/lib/dovecot"
+  configureFlags = [
+    "--with-dovecot=${dovecot}/lib/dovecot"
     "--without-dovecot-install-dirs"
     "--with-moduledir=$(out)/lib/dovecot"
-  ];  
+  ];
+
+  enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
     homepage = http://pigeonhole.dovecot.org/;
     description = "A sieve plugin for the Dovecot IMAP server";
     license = licenses.lgpl21;
     maintainers = [ maintainers.rickynils ];
-  };  
+    platforms = platforms.unix;
+  };
 }
diff --git a/pkgs/servers/mail/dspam/default.nix b/pkgs/servers/mail/dspam/default.nix
new file mode 100644
index 000000000000..b63390bb2474
--- /dev/null
+++ b/pkgs/servers/mail/dspam/default.nix
@@ -0,0 +1,108 @@
+{ stdenv, lib, fetchurl, makeWrapper
+, gawk, gnused, gnugrep, coreutils, which
+, perl, NetSMTP
+, withMySQL ? false, zlib, mysql57
+, withPgSQL ? false, postgresql
+, withSQLite ? false, sqlite
+, withDB ? false, db
+}:
+
+let
+  drivers = lib.concatStringsSep ","
+            ([ "hash_drv" ]
+             ++ lib.optional withMySQL "mysql_drv"
+             ++ lib.optional withPgSQL "pgsql_drv"
+             ++ lib.optional withSQLite "sqlite3_drv"
+             ++ lib.optional withDB "libdb4_drv"
+            );
+  maintenancePath = lib.makeBinPath [ gawk gnused gnugrep coreutils which ];
+
+in stdenv.mkDerivation rec {
+  name = "dspam-3.10.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/dspam/dspam/${name}/${name}.tar.gz";
+    sha256 = "1acklnxn1wvc7abn31l3qdj8q6k13s51k5gv86vka7q20jb5cxmf";
+  };
+
+  buildInputs = [ perl ]
+                ++ lib.optionals withMySQL [ zlib mysql57.connector-c ]
+                ++ lib.optional withPgSQL postgresql
+                ++ lib.optional withSQLite sqlite
+                ++ lib.optional withDB db;
+  nativeBuildInputs = [ makeWrapper ];
+
+  configureFlags = [
+    "--with-storage-driver=${drivers}"
+    "--sysconfdir=/etc/dspam"
+    "--localstatedir=/var"
+    "--with-dspam-home=/var/lib/dspam"
+    "--with-logdir=/var/log/dspam"
+    "--with-logfile=/var/log/dspam/dspam.log"
+
+    "--enable-daemon"
+    "--enable-clamav"
+    "--enable-syslog"
+    "--enable-large-scale"
+    "--enable-virtual-users"
+    "--enable-split-configuration"
+    "--enable-preferences-extension"
+    "--enable-long-usernames"
+    "--enable-external-lookup"
+  ] ++ lib.optional withMySQL "--with-mysql-includes=${mysql57.connector-c}/include/mysql"
+    ++ lib.optional withPgSQL "--with-pgsql-libraries=${postgresql.lib}/lib";
+
+  # Lots of things are hardwired to paths like sysconfdir. That's why we install with both "prefix" and "DESTDIR"
+  # and fix directory structure manually after that.
+  installFlags = [ "DESTDIR=$(out)" ];
+
+  postInstall = ''
+    cp -r $out/$out/* $out
+    rm -rf $out/$(echo "$out" | cut -d "/" -f2)
+    rm -rf $out/var
+
+    wrapProgram $out/bin/dspam_notify \
+      --set PERL5LIB "${lib.makePerlPath [ NetSMTP ]}"
+
+    # Install SQL scripts
+    mkdir -p $out/share/dspam/sql
+    # MySQL
+    cp src/tools.mysql_drv/mysql_*.sql $out/share/dspam/sql
+    for i in src/tools.mysql_drv/{purge*.sql,virtual*.sql}; do
+      cp "$i" $out/share/dspam/sql/mysql_$(basename "$i")
+    done
+    # PostgreSQL
+    cp src/tools.pgsql_drv/pgsql_*.sql $out/share/dspam/sql
+    for i in src/tools.pgsql_drv/{purge*.sql,virtual*.sql}; do
+      cp "$i" $out/share/dspam/sql/pgsql_$(basename "$i")
+    done
+    # SQLite
+    for i in src/tools.sqlite_drv/purge*.sql; do
+      cp "$i" $out/share/dspam/sql/sqlite_$(basename "$i")
+    done
+
+    # Install maintenance script
+    install -Dm755 contrib/dspam_maintenance/dspam_maintenance.sh $out/bin/dspam_maintenance
+    sed -i \
+      -e "2iexport PATH=$out/bin:${maintenancePath}:\$PATH" \
+      -e 's,/usr/[a-z0-9/]*,,g' \
+      -e 's,^DSPAM_CONFIGDIR=.*,DSPAM_CONFIGDIR=/etc/dspam,' \
+      -e "s,^DSPAM_HOMEDIR=.*,DSPAM_HOMEDIR=/var/lib/dspam," \
+      -e "s,^DSPAM_PURGE_SCRIPT_DIR=.*,DSPAM_PURGE_SCRIPT_DIR=$out/share/dspam/sql," \
+      -e "s,^DSPAM_BIN_DIR=.*,DSPAM_BIN_DIR=$out/bin," \
+      -e "s,^MYSQL_BIN_DIR=.*,MYSQL_BIN_DIR=/run/current-system/sw/bin," \
+      -e "s,^PGSQL_BIN_DIR=.*,PGSQL_BIN_DIR=/run/current-system/sw/bin," \
+      -e "s,^SQLITE_BIN_DIR=.*,SQLITE_BIN_DIR=/run/current-system/sw/bin," \
+      -e "s,^SQLITE3_BIN_DIR=.*,SQLITE3_BIN_DIR=/run/current-system/sw/bin," \
+      -e 's,^DSPAM_CRON_LOCKFILE=.*,DSPAM_CRON_LOCKFILE=/run/dspam/dspam_maintenance.pid,' \
+      $out/bin/dspam_maintenance
+  '';
+
+  meta = with lib; {
+    homepage = http://nuclearelephant.com/;
+    description = "Community Driven Antispam Filter";
+    license = licenses.agpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/pkgs/servers/mail/exim/default.nix b/pkgs/servers/mail/exim/default.nix
index 6f2b65fd9b7d..393ce2c5cda9 100644
--- a/pkgs/servers/mail/exim/default.nix
+++ b/pkgs/servers/mail/exim/default.nix
@@ -1,14 +1,18 @@
-{ coreutils, fetchurl, db, openssl, pcre, perl, pkgconfig, stdenv }:
+{ coreutils, db, fetchurl, openldap, openssl, pcre, perl, pkgconfig, stdenv
+, enableLDAP ? false
+}:
 
 stdenv.mkDerivation rec {
-  name = "exim-4.86";
+  name = "exim-4.91";
 
   src = fetchurl {
-    url = "http://mirror.switch.ch/ftp/mirror/exim/exim/exim4/${name}.tar.bz2";
-    sha256 = "0mn4bxih9slrmll5262ayhf41ji43pjf1rv0y6xpy6x55v7g5k7i";
+    url = "http://ftp.exim.org/pub/exim/exim4/${name}.tar.xz";
+    sha256 = "066ip7a5lqfn9rcr14j4nm0kqysw6mzvbbb0ip50lmfm0fqsqmzc";
   };
 
-  buildInputs = [ coreutils db openssl pcre perl pkgconfig ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ coreutils db openssl pcre perl ]
+    ++ stdenv.lib.optional enableLDAP openldap;
 
   preBuild = ''
     sed '
@@ -32,6 +36,11 @@ stdenv.mkDerivation rec {
       s:^# \(RM_COMMAND\)=.*:\1=${coreutils}/bin/rm:
       s:^# \(TOUCH_COMMAND\)=.*:\1=${coreutils}/bin/touch:
       s:^# \(PERL_COMMAND\)=.*:\1=${perl}/bin/perl:
+      ${stdenv.lib.optionalString enableLDAP ''
+        s:^# \(LDAP_LIB_TYPE=OPENLDAP2\)$:\1:
+        s:^# \(LOOKUP_LDAP=yes\)$:\1:
+        s:^# \(LOOKUP_LIBS\)=.*:\1=-lldap:
+      ''}
       #/^\s*#.*/d
       #/^\s*$/d
     ' < src/EDITME > Local/Makefile
diff --git a/pkgs/servers/mail/freepops/default.nix b/pkgs/servers/mail/freepops/default.nix
index a96e4cb37c01..b4f671862f88 100644
--- a/pkgs/servers/mail/freepops/default.nix
+++ b/pkgs/servers/mail/freepops/default.nix
@@ -6,7 +6,8 @@ stdenv.mkDerivation {
     url = mirror://sourceforge/freepops/0.2.9/freepops-0.2.9.tar.gz;
     sha256 = "3a065e30cafed03d9b6fdb28251ae5bf0d8aeb62181746154beecd25dc0c9cae";
   };
-  buildInputs = [pkgconfig openssl lua5 curl readline bison expat];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ openssl lua5 curl readline bison expat];
   configurePhase =
   ''
     export WHERE=$prefix/
diff --git a/pkgs/servers/mail/mailhog/default.nix b/pkgs/servers/mail/mailhog/default.nix
new file mode 100644
index 000000000000..019c84d2898b
--- /dev/null
+++ b/pkgs/servers/mail/mailhog/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "MailHog-${version}";
+  version = "1.0.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/mailhog/MailHog";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "mailhog";
+    repo = "MailHog";
+    sha256 = "0r6zidkffb8q12zyxd063jy0ig2x93llna4zb5i2qjh9gb971i83";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Web and API based SMTP testing";
+    homepage = https://github.com/mailhog/MailHog;
+    maintainers = with maintainers; [ disassembler ];
+    license = licenses.mit;
+  };
+}
diff --git a/pkgs/servers/mail/mailhog/deps.nix b/pkgs/servers/mail/mailhog/deps.nix
new file mode 100644
index 000000000000..9967c3a549a5
--- /dev/null
+++ b/pkgs/servers/mail/mailhog/deps.nix
@@ -0,0 +1,191 @@
+[
+  {
+    goPackagePath = "github.com/gorilla/pat";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/pat";
+      rev = "cf955c3d1f2c27ee96f93e9738085c762ff5f49d";
+      sha256 = "1jnhdhba3cwgsgv6qf7shvmk2nbbp8z30n9cimz9w6vd940ipisf";
+    };
+  }
+  {
+    goPackagePath = "github.com/gorilla/context";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/context";
+      rev = "1ea25387ff6f684839d82767c1733ff4d4d15d0a";
+      sha256 = "1nh1nzxcsgd215x4xn59wc4cbqfa8zvhvnnx5p8fkrn4bj1cgak4";
+    };
+  }
+  {
+    goPackagePath = "github.com/gorilla/mux";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/mux";
+      rev = "bcd8bc72b08df0f70df986b97f95590779502d31";
+      sha256 = "0majd18zn8v1b1agn015vnk3xk2v8j5nyckczlf72gm3kaq3icga";
+    };
+  }
+  {
+    goPackagePath = "github.com/gorilla/websocket";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/websocket";
+      rev = "3ab3a8b8831546bd18fd182c20687ca853b2bb13";
+      sha256 = "17y94ngp1yrswq5pxxy97naiw6jgxz2yvm8zydi83gfixdgs99fc";
+    };
+  }
+  {
+    goPackagePath = "github.com/ian-kent/go-log";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ian-kent/go-log";
+      rev = "5731446c36ab9f716106ce0731f484c50fdf1ad1";
+      sha256 = "1qr0myg68r9zq43fnx0rbnxcny2jpyg3gc269pc2riskqk0a731d";
+    };
+  }
+  {
+    goPackagePath = "github.com/ian-kent/envconf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ian-kent/envconf";
+      rev = "c19809918c02ab33dc8635d68c77649313185275";
+      sha256 = "1085863rnx4h0q9xvg4zlsc7xf7jngfmjrq83cpcv1ayi664mzdx";
+    };
+  }
+  {
+    goPackagePath = "github.com/ian-kent/goose";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ian-kent/goose";
+      rev = "c3541ea826ad9e0f8a4a8c15ca831e8b0adde58c";
+      sha256 = "0v98d2554vlrm8mzk2zx8wj3daq076273w0zs8ww1aa57a1l74qv";
+    };
+  }
+  {
+    goPackagePath = "github.com/ian-kent/linkio";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ian-kent/linkio";
+      rev = "77fb4b01842cb4b019137c0227df9a8f9779d0bd";
+      sha256 = "0fixidplxzmw7aakw19d64nvrykwm5xk55fj1q74n70s8j5d8hiq";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/MailHog-Server";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/MailHog-Server";
+      rev = "50f74a1aa2991b96313144d1ac718ce4d6739dfd";
+      sha256 = "1h0qs66bvgygpq0sz3w6y445vm3pvlrljr5x7xr13y0087mrpjla";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/MailHog-UI";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/MailHog-UI";
+      rev = "24b31a47cc5b65d23576bb9884c941d2b88381f7";
+      sha256 = "0309jmryhx3n0yksssk2j4xkh1xb01468i5f2sy3a83xkz9p3d54";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/http";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/http";
+      rev = "2e653938bf190d0e2fbe4825ce74e5bc149a62f2";
+      sha256 = "18j03lvyis7z0mv3fym3j9a7pi2qvnhggmhpxnjbwvwb86dhxjm8";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/mhsendmail";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/mhsendmail";
+      rev = "002527025ef50364446d7560600aedc5daaa1997";
+      sha256 = "11l2y0xb7hwk0zs7pwif3xkclhz32sc0jff3jkaxi3jdf3q3kz91";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/data";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/data";
+      rev = "024d554958b5bea5db220bfd84922a584d878ded";
+      sha256 = "0dgh0pcsn0xrxsn1qlxgdssaimch57kxj5vyvhqjnsdnh814g9vf";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/smtp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/smtp";
+      rev = "0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54";
+      sha256 = "1w46w3asdxsgzyall16hi2s4jvkka1k3a1l52ryfhrzg187krir6";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailhog/storage";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailhog/storage";
+      rev = "6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa";
+      sha256 = "1ya0xigm2xysin59zlp2sbqncnmw9h77r9dn9k7vxhf0z8vvbibk";
+    };
+  }
+  {
+    goPackagePath = "github.com/ogier/pflag";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ogier/pflag";
+      rev = "32a05c62658bd1d7c7e75cbc8195de5d585fde0f";
+      sha256 = "1lyrr9wx0j087mnpsxcbspjcgh9a5c6bqwrasd8s237jlyc50qmj";
+    };
+  }
+  {
+    goPackagePath = "github.com/tinylib/msgp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/tinylib/msgp";
+      rev = "02d047e07459c5a7b02b1244161d0f2f6d8f660d";
+      sha256 = "12y7qz1x266m0a0w3zwd49achxbh036yhkmx93xfs2283xh70q1r";
+    };
+  }
+  {
+    goPackagePath = "github.com/philhofer/fwd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/philhofer/fwd";
+      rev = "1612a298117663d7bc9a760ae20d383413859798";
+      sha256 = "155l0nvvblpx0fy683q6bzins7csh8fw7yf64hbia8hc7wh0gjdl";
+    };
+  }
+  {
+    goPackagePath = "github.com/t-k/fluent-logger-golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/t-k/fluent-logger-golang";
+      rev = "0f8ec08f2057a61574b6943e75045fffbeae894e";
+      sha256 = "0ic5bj87wpq1kncixd5mklwqn1jjwqfqfvkyl0mrnwp3p5p24v5c";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "c197bcf24cde29d3f73c7b4ac6fd41f4384e8af6";
+      sha256 = "1y2bbghi594m8p4pcm9pwrzql06179xj6zvhaghwcc6y0l48rbgp";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/mgo.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/mgo.v2";
+      rev = "d90005c5262a3463800497ea5a89aed5fe22c886";
+      sha256 = "1z81k6mnfk07hkrkw31l16qycyiwa6wzyhysmywgkh58sm5dc9m7";
+    };
+  }
+]
diff --git a/pkgs/servers/mail/mailman/default.nix b/pkgs/servers/mail/mailman/default.nix
index e4fffecb9597..8ff20869b94e 100644
--- a/pkgs/servers/mail/mailman/default.nix
+++ b/pkgs/servers/mail/mailman/default.nix
@@ -1,14 +1,15 @@
-{ stdenv, fetchurl, python, dnspython }:
+{ stdenv, fetchurl, python, pythonPackages }:
 
 stdenv.mkDerivation rec {
-  name = "mailman-2.1.18";
+  name = "mailman-${version}";
+  version = "2.1.24";
 
   src = fetchurl {
     url = "mirror://gnu/mailman/${name}.tgz";
-    sha256 = "0jc360crakvpz71msl0h11zv3849fqzlj9jfh1g7x3j4459n07fw";
+    sha256 = "1r6sjapjmbav45xibjzc2a8y1xf4ikz09470ma1kw7iz174wn8z7";
   };
 
-  buildInputs = [ python dnspython ];
+  buildInputs = [ python pythonPackages.dnspython ];
 
   patches = [ ./fix-var-prefix.patch ];
 
@@ -16,11 +17,13 @@ stdenv.mkDerivation rec {
 
   installTargets = "doinstall";         # Leave out the 'update' target that's implied by 'install'.
 
+  makeFlags = [ "DIRSETGID=:" ];
+
   meta = {
-    homepage = "http://www.gnu.org/software/mailman/";
+    homepage = http://www.gnu.org/software/mailman/;
     description = "Free software for managing electronic mail discussion and e-newsletter lists";
     license = stdenv.lib.licenses.gpl2Plus;
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    maintainers = [ stdenv.lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/servers/mail/mlmmj/default.nix b/pkgs/servers/mail/mlmmj/default.nix
index 2ad6dedbf697..f11400c190af 100644
--- a/pkgs/servers/mail/mlmmj/default.nix
+++ b/pkgs/servers/mail/mlmmj/default.nix
@@ -3,13 +3,19 @@
 stdenv.mkDerivation rec {
 
   name = "mlmmj-${version}";
-  version = "1.2.18.1";
+  version = "1.3.0";
 
   src = fetchurl {
     url = "http://mlmmj.org/releases/${name}.tar.gz";
-    sha256 = "336b6b20a6d7f0dcdc7445ecea0fe4bdacee241f624fcc710b4341780f35e383";
+    sha256 = "1sghqvwizvm1a9w56r34qy5njaq1c26bagj85r60h32gh3fx02bn";
   };
 
+  postInstall = ''
+    # grab all documentation files
+    docfiles=$(find -maxdepth 1 -name "[[:upper:]][[:upper:]]*")
+    install -vDm 644 -t $out/share/doc/mlmmj/ $docfiles
+  '';
+
   meta = with stdenv.lib; {
     homepage = http://mlmmj.org;
     description = "Mailing List Management Made Joyful";
@@ -18,4 +24,4 @@ stdenv.mkDerivation rec {
     license = licenses.mit;
   };
 
-}
\ No newline at end of file
+}
diff --git a/pkgs/servers/mail/nullmailer/default.nix b/pkgs/servers/mail/nullmailer/default.nix
new file mode 100644
index 000000000000..f17f3ed2de7e
--- /dev/null
+++ b/pkgs/servers/mail/nullmailer/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchurl, lib, tls ? true, gnutls ? null }:
+
+assert tls -> gnutls != null;
+
+stdenv.mkDerivation rec {
+
+  version = "2.1";
+  name = "nullmailer-${version}";
+
+  src = fetchurl {
+    url = "http://untroubled.org/nullmailer/nullmailer-${version}.tar.gz";
+    sha256 = "0gykh0qc86rk0knfvp8ndqkryal3pvqdfdya94wvb6n1cc8p3ild";
+  };
+
+  buildInputs = stdenv.lib.optional tls gnutls;
+
+  configureFlags = [
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+  ] ++ stdenv.lib.optional tls "--enable-tls";
+
+  installFlags = [ "DESTDIR=$(out)" ];
+
+  # We have to remove the ''var'' directory, since nix can't handle named pipes
+  # and we can't use it in the store anyway. Same for ''etc''.
+  # The second line is need, because the installer of nullmailer will copy its
+  # own prepared version of ''etc'' and ''var'' and also uses the prefix path (configure phase)
+  # for hardcoded absolute references to its own binary farm, e.g. sendmail binary is
+  # calling nullmailer-inject binary. Since we can't configure inside the store of
+  # the derivation we need both directories in the root, but don't want to put them there
+  # during install, hence we have to fix mumbling inside the install directory.
+  # This is kind of a hack, but the only way I know of, yet.
+  postInstall = ''
+    rm -rf $out/var/ $out/etc/
+    mv $out/$out/* $out/
+    rmdir $out/$out
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = http://untroubled.org/nullmailer/;
+    description = ''
+      A sendmail/qmail/etc replacement MTA for hosts which relay to a fixed set of smart relays.
+      It is designed to be simple to configure, secure, and easily extendable.
+    '';
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.all;
+    maintainers = with lib.maintainers ; [ sargon ];
+  };
+}
diff --git a/pkgs/servers/mail/opensmtpd/default.nix b/pkgs/servers/mail/opensmtpd/default.nix
index 2fd3f0421b97..e562fdc88a6c 100644
--- a/pkgs/servers/mail/opensmtpd/default.nix
+++ b/pkgs/servers/mail/opensmtpd/default.nix
@@ -1,32 +1,51 @@
-{ stdenv, fetchurl, autoconf, automake, libtool, bison
-, libasr, libevent, zlib, openssl, db, pam, cacert
+{ stdenv, lib, fetchurl, autoconf, automake, libtool, bison
+, libasr, libevent, zlib, openssl, db, pam
+
+# opensmtpd requires root for no reason to encrypt passwords, this patch fixes it
+# see also https://github.com/OpenSMTPD/OpenSMTPD/issues/678
+, unpriviledged_smtpctl_encrypt ? true
+
+# Deprecated: use the subaddressing-delimiter in the config file going forward
+, tag_char ? null
 }:
 
-stdenv.mkDerivation rec {
+if (tag_char != null)
+then throw "opensmtpd: the tag_char argument is deprecated as it can now be specified at runtime via the 'subaddressing-delimiter' option of the configuration file"
+else stdenv.mkDerivation rec {
   name = "opensmtpd-${version}";
-  version = "5.7.1p1";
+  version = "6.0.3p1";
 
   nativeBuildInputs = [ autoconf automake libtool bison ];
   buildInputs = [ libasr libevent zlib openssl db pam ];
 
   src = fetchurl {
-    url = "http://www.opensmtpd.org/archives/${name}.tar.gz";
-    sha256 = "67e9dd9682ca8c181e84e66c76245a4a8f6205834f915a2c021cdfeb22049e3a";
+    url = "https://www.opensmtpd.org/archives/${name}.tar.gz";
+    sha256 = "291881862888655565e8bbe3cfb743310f5dc0edb6fd28a889a9a547ad767a81";
   };
 
   patches = [ ./proc_path.diff ];
 
+  postPatch = with builtins; with lib;
+    optionalString unpriviledged_smtpctl_encrypt ''
+      substituteInPlace smtpd/smtpctl.c --replace \
+        'if (geteuid())' \
+        'if (geteuid() != 0 && !(argc > 1 && !strcmp(argv[1], "encrypt")))'
+      substituteInPlace mk/smtpctl/Makefile.in --replace "chmod 2555" "chmod 0555"
+    '';
+
   configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
     "--with-mantype=doc"
-    "--with-pam"
-    "--without-bsd-auth"
-    "--with-sock-dir=/run"
-    "--with-privsep-user=smtpd"
-    "--with-queue-user=smtpq"
-    "--with-ca-file=/etc/ssl/certs/ca-certificates.crt"
-    "--with-libevent-dir=${libevent}"
+    "--with-auth-pam"
+    "--without-auth-bsdauth"
+    "--with-path-socket=/run"
+    "--with-user-smtpd=smtpd"
+    "--with-user-queue=smtpq"
+    "--with-group-queue=smtpq"
+    "--with-path-CAfile=/etc/ssl/certs/ca-certificates.crt"
+    "--with-libevent=${libevent.dev}"
+    "--with-table-db"
   ];
 
   installFlags = [
@@ -34,14 +53,14 @@ stdenv.mkDerivation rec {
     "localstatedir=\${TMPDIR}"
   ];
 
-  meta = {
+  meta = with stdenv.lib; {
     homepage = https://www.opensmtpd.org/;
     description = ''
       A free implementation of the server-side SMTP protocol as defined by
       RFC 5321, with some additional standard extensions
     '';
-    license = stdenv.lib.licenses.isc;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.rickynils ];
+    license = licenses.isc;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ rickynils obadz ];
   };
 }
diff --git a/pkgs/servers/mail/opensmtpd/extras.nix b/pkgs/servers/mail/opensmtpd/extras.nix
index 0123d19bf3fa..6b63c317d78f 100644
--- a/pkgs/servers/mail/opensmtpd/extras.nix
+++ b/pkgs/servers/mail/opensmtpd/extras.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl, openssl, libevent, libasr,
-  python2, pkgconfig, lua5, perl, mariadb, postgresql, sqlite, hiredis }:
+  python2, pkgconfig, lua5, perl, mysql, postgresql, sqlite, hiredis }:
+
 stdenv.mkDerivation rec {
   name = "opensmtpd-extras-${version}";
   version = "5.7.1";
@@ -11,13 +12,13 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ openssl libevent
-    libasr python2 lua5 perl mariadb postgresql sqlite hiredis ];
+    libasr python2 lua5 perl mysql.connector-c postgresql sqlite hiredis ];
 
   configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
     "--with-privsep-user=smtpd"
-    "--with-libevent-dir=${libevent}"
+    "--with-libevent-dir=${libevent.dev}"
 
     "--with-filter-clamav"
     "--with-filter-dkim-signer"
@@ -54,7 +55,7 @@ stdenv.mkDerivation rec {
     "--with-perl=${perl}"
     "--with-filter-perl"
 
-  ] ++ stdenv.lib.optional (mariadb != null) [
+  ] ++ stdenv.lib.optional (mysql != null) [
     "--with-table-mysql"
 
   ] ++ stdenv.lib.optional (postgresql != null) [
@@ -67,13 +68,14 @@ stdenv.mkDerivation rec {
     "--with-table-redis"
   ];
 
-  NIX_CFLAGS_COMPILE = stdenv.lib.optional (hiredis != null) [ "-I${hiredis}/include/hiredis" ];
+  NIX_CFLAGS_COMPILE = stdenv.lib.optional (hiredis != null) "-I${hiredis}/include/hiredis" ++
+    stdenv.lib.optional (mysql != null) "-L${mysql.connector-c}/lib/mysql";
 
   meta = with stdenv.lib; {
     homepage = https://www.opensmtpd.org/;
     description = "Extra plugins for the OpenSMTPD mail server";
     license = licenses.isc;
-    platforms = platforms.unix;
+    platforms = platforms.linux;
     maintainers = with maintainers; [ gebner ];
   };
 }
diff --git a/pkgs/servers/mail/opensmtpd/proc_path.diff b/pkgs/servers/mail/opensmtpd/proc_path.diff
index 0e8eac0bb83b..5e1cfd004299 100644
--- a/pkgs/servers/mail/opensmtpd/proc_path.diff
+++ b/pkgs/servers/mail/opensmtpd/proc_path.diff
@@ -1,76 +1,59 @@
-diff -Naur opensmtpd-5.7.1p1/smtpd/parse.y opensmtpd-5.7.1p1.patched/smtpd/parse.y
---- opensmtpd-5.7.1p1/smtpd/parse.y	2015-06-30 10:13:34.000000000 +0200
-+++ opensmtpd-5.7.1p1.patched/smtpd/parse.y	2015-09-26 08:41:17.012472516 +0200
-@@ -2519,13 +2519,19 @@
- {
- 	struct filter_conf	*f;
- 	char			*path;
-+        const char              *proc_path;
- 
- 	if (dict_get(&conf->sc_filters, name)) {
- 		yyerror("filter \"%s\" already defined", name);
- 		return (NULL);
- 	}
- 
--	if (asprintf(&path, "%s/filter-%s", PATH_LIBEXEC, prog) == -1) {
-+        proc_path = getenv("OPENSMTPD_PROC_PATH");
-+        if (proc_path == NULL) {
-+                proc_path = PATH_LIBEXEC;
-+        }
-+
-+	if (asprintf(&path, "%s/filter-%s", proc_path, prog) == -1) {
- 		yyerror("filter \"%s\" asprintf failed", name);
- 		return (0);
- 	}
-diff -Naur opensmtpd-5.7.1p1/smtpd/smtpd.c opensmtpd-5.7.1p1.patched/smtpd/smtpd.c
---- opensmtpd-5.7.1p1/smtpd/smtpd.c	2015-06-30 10:13:34.000000000 +0200
-+++ opensmtpd-5.7.1p1.patched/smtpd/smtpd.c	2015-09-26 08:41:16.998472557 +0200
-@@ -854,6 +854,7 @@
+diff --git a/smtpd/smtpd.c b/smtpd/smtpd.c
+index e049f07c..a1bd03a0 100644
+--- a/smtpd/smtpd.c
++++ b/smtpd/smtpd.c
+@@ -1157,6 +1157,7 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
  	char		path[PATH_MAX];
  	char		name[PATH_MAX];
  	char		*arg;
-+        char            *proc_path;
++	char		*proc_path;
  
  	if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) {
  		log_warnx("warn: %s-proc: conf too long", key);
-@@ -864,7 +865,12 @@
+@@ -1167,7 +1168,12 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
  	if (arg)
  		*arg++ = '\0';
  
 -	if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >=
-+        proc_path = getenv("OPENSMTPD_PROC_PATH");
-+        if (proc_path == NULL) {
-+                proc_path = PATH_LIBEXEC;
-+        }
++	proc_path = getenv("OPENSMTPD_PROC_PATH");
++	if (proc_path == NULL) {
++		proc_path = PATH_LIBEXEC;
++	}
 +
 +	if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >=
  	    (ssize_t)sizeof(path)) {
  		log_warn("warn: %s-proc: exec path too long", key);
  		return (-1);
-diff -Naur opensmtpd-5.7.1p1/smtpd/table.c opensmtpd-5.7.1p1.patched/smtpd/table.c
---- opensmtpd-5.7.1p1/smtpd/table.c	2015-06-30 10:13:34.000000000 +0200
-+++ opensmtpd-5.7.1p1.patched/smtpd/table.c	2015-09-26 08:41:17.005472536 +0200
-@@ -201,6 +201,7 @@
+diff --git a/smtpd/table.c b/smtpd/table.c
+index 9cfdfb99..24dfcca4 100644
+--- a/smtpd/table.c
++++ b/smtpd/table.c
+@@ -201,6 +201,7 @@ table_create(const char *backend, const char *name, const char *tag,
  	struct table_backend	*tb;
  	char			 buf[LINE_MAX];
  	char			 path[LINE_MAX];
-+        const char              *proc_path;
++	const char		*proc_path;
  	size_t			 n;
  	struct stat		 sb;
  
-@@ -215,8 +216,14 @@
+@@ -215,11 +216,16 @@ table_create(const char *backend, const char *name, const char *tag,
  	if (name && table_find(name, NULL))
  		fatalx("table_create: table \"%s\" already defined", name);
  
-+        proc_path = getenv("OPENSMTPD_PROC_PATH");
-+        if (proc_path == NULL) {
-+                proc_path = PATH_LIBEXEC;
-+        }
++	proc_path = getenv("OPENSMTPD_PROC_PATH");
++	if (proc_path == NULL) {
++		proc_path = PATH_LIBEXEC;
++	}
 +
  	if ((tb = table_backend_lookup(backend)) == NULL) {
--		if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC "/table-%s",
+-		if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC"/table-%s",
+-			backend) >= sizeof(path)) {
+-			fatalx("table_create: path too long \""
+-			    PATH_LIBEXEC"/table-%s\"", backend);
 +		if ((size_t)snprintf(path, sizeof(path), "%s/table-%s",
-+                    proc_path,
- 		    backend) >= sizeof(path)) {
- 			fatalx("table_create: path too long \""
- 			    PATH_LIBEXEC "/table-%s\"", backend);
++			proc_path, backend) >= sizeof(path)) {
++			fatalx("table_create: path too long \"%s/table-%s\"",
++				proc_path, backend);
+ 		}
+ 		if (stat(path, &sb) == 0) {
+ 			tb = table_backend_lookup("proc");
diff --git a/pkgs/servers/mail/petidomo/default.nix b/pkgs/servers/mail/petidomo/default.nix
index 6c6cde8a46a6..8ccd783b6ad8 100644
--- a/pkgs/servers/mail/petidomo/default.nix
+++ b/pkgs/servers/mail/petidomo/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, flex, bison, sendmailPath ? "/var/setuid-wrappers/sendmail" }:
+{ stdenv, fetchurl, flex, bison, sendmailPath ? "/run/wrappers/bin/sendmail" }:
 
 stdenv.mkDerivation rec {
   name = "petidomo-4.3";
@@ -17,11 +17,11 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   meta = {
-    homepage = "http://petidomo.sourceforge.net/";
-    description = "a simple and easy to administer mailing list server";
+    homepage = http://petidomo.sourceforge.net/;
+    description = "A simple and easy to administer mailing list server";
     license = stdenv.lib.licenses.gpl3Plus;
 
     platforms = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    maintainers = [ stdenv.lib.maintainers.peti ];
   };
 }
diff --git a/pkgs/servers/mail/popa3d/default.nix b/pkgs/servers/mail/popa3d/default.nix
index 3dcfa3a22db2..e14b62a85971 100644
--- a/pkgs/servers/mail/popa3d/default.nix
+++ b/pkgs/servers/mail/popa3d/default.nix
@@ -21,7 +21,8 @@ stdenv.mkDerivation rec {
   configurePhase = ''makeFlags="PREFIX=$out MANDIR=$out/share/man"'';
 
   meta = {
-    homepage = "http://www.openwall.com/popa3d/";
+    homepage = http://www.openwall.com/popa3d/;
     description = "Tiny POP3 daemon with security as the primary goal";
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch b/pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch
new file mode 100644
index 000000000000..5de22573ea33
--- /dev/null
+++ b/pkgs/servers/mail/postfix/0001-Fix-build-with-unbound-1.6.1.patch
@@ -0,0 +1,54 @@
+From bf269dda3c81bb9eaa244b3015d426de38c85ccf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Carles=20Pag=C3=A8s?= <page@ruiec.cat>
+Date: Fri, 3 Mar 2017 09:59:09 +0100
+Subject: [PATCH] Fix build with unbound 1.6.1
+
+From their changelog: Fix to rename ub_callback_t to ub_callback_type, because POSIX reserves _t typedefs
+---
+ postlicyd/dns.c       | 2 +-
+ postlicyd/dns.h       | 2 +-
+ postlicyd/spf-proto.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/postlicyd/dns.c b/postlicyd/dns.c
+index d8409c2..97f1c4d 100644
+--- a/postlicyd/dns.c
++++ b/postlicyd/dns.c
+@@ -123,7 +123,7 @@ static int dns_handler(client_t *event, void *config)
+ }
+ 
+ bool dns_resolve(const char *hostname, dns_rrtype_t type,
+-                 ub_callback_t callback, void *data)
++                 ub_callback_type callback, void *data)
+ {
+     if (_G.ctx == NULL) {
+         _G.ctx = ub_ctx_create();
+diff --git a/postlicyd/dns.h b/postlicyd/dns.h
+index d84de3b..905b924 100644
+--- a/postlicyd/dns.h
++++ b/postlicyd/dns.h
+@@ -89,7 +89,7 @@ typedef void (*dns_result_callback_f)(dns_result_t *result, void *data);
+  */
+ __attribute__((nonnull(1,3,4)))
+ bool dns_resolve(const char *hostname, dns_rrtype_t type,
+-                 ub_callback_t callback, void *data);
++                 ub_callback_type callback, void *data);
+ 
+ /** Fetch the DNS record of the given type.
+  */
+diff --git a/postlicyd/spf-proto.c b/postlicyd/spf-proto.c
+index 31cb0a5..79a2d83 100644
+--- a/postlicyd/spf-proto.c
++++ b/postlicyd/spf-proto.c
+@@ -279,7 +279,7 @@ static bool spf_validate_domain(const char* restrict domain)
+ }
+ 
+ static bool spf_query(spf_t *spf, const char* query, dns_rrtype_t rtype,
+-                      ub_callback_t cb)
++                      ub_callback_type cb)
+ {
+     buffer_reset(&_G.query_buffer);
+     buffer_addstr(&_G.query_buffer, query);
+-- 
+2.12.0
+
diff --git a/pkgs/servers/mail/postfix/2.11.nix b/pkgs/servers/mail/postfix/2.11.nix
deleted file mode 100644
index bfd10fb591b2..000000000000
--- a/pkgs/servers/mail/postfix/2.11.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{ stdenv, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl, coreutils
-, findutils, gnugrep, gawk
-}:
-
-stdenv.mkDerivation rec {
-
-  name = "postfix-${version}";
-
-  version = "2.11.5";
-
-  src = fetchurl {
-    url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz";
-    sha256 = "11riz8ggaa09pi8d6xv2807qp7yjn918mrylfvkfwmvcdlgwck0a";
-  };
-
-  patches = [ ./postfix-2.11.0.patch ];
-
-  buildInputs = [ makeWrapper gnused db openssl cyrus_sasl ];
-
-  preBuild = ''
-    sed -e '/^PATH=/d' -i postfix-install
-
-    export command_directory=$out/sbin
-    export config_directory=$out/etc/postfix
-    export daemon_directory=$out/libexec/postfix
-    export data_directory=/var/lib/postfix
-    export html_directory=$out/share/postfix/doc/html
-    export mailq_path=$out/bin/mailq
-    export manpage_directory=$out/share/man
-    export newaliases_path=$out/bin/newaliases
-    export queue_directory=/var/spool/postfix
-    export readme_directory=$out/share/postfix/doc
-    export sendmail_path=$out/bin/sendmail
-
-    make makefiles \
-      CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl \
-              -fPIE -fstack-protector-all --param ssp-buffer-size=4 -O2 -D_FORTIFY_SOURCE=2' \
-      AUXLIBS='-ldb -lnsl -lresolv -lsasl2 -lcrypto -lssl -pie -Wl,-z,relro,-z,now'
-  '';
-
-  installTargets = [ "non-interactive-package" ];
-
-  installFlags = [ " install_root=$out " ];
-
-  postInstall = ''
-    mkdir -p $out
-    mv -v ut/$out/* $out/
-    sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install
-    wrapProgram $out/libexec/postfix/post-install \
-      --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin
-    wrapProgram $out/libexec/postfix/postfix-script \
-      --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin
-  '';
-
-  meta = {
-    homepage = "http://www.postfix.org/";
-    description = "A fast, easy to administer, and secure mail server";
-    license = stdenv.lib.licenses.bsdOriginal;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.rickynils ];
-  };
-
-}
diff --git a/pkgs/servers/mail/postfix/db-linux3.patch b/pkgs/servers/mail/postfix/db-linux3.patch
deleted file mode 100644
index c9dd4646798a..000000000000
--- a/pkgs/servers/mail/postfix/db-linux3.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/makedefs b/makedefs
-index b8b98c8..94443c0 100644
---- a/makedefs
-+++ b/makedefs
-@@ -341,20 +341,20 @@ EOF
- 		esac
- 		;;
-     Linux.3*)	SYSTYPE=LINUX3
--		if [ -f /usr/include/db.h ]
--		then
--		    : we are all set
--		elif [ -f /usr/include/db/db.h ]
--		then
--		    CCARGS="$CCARGS -I/usr/include/db"
--		else
--		    # On a properly installed system, Postfix builds
--		    # by including <db.h> and by linking with -ldb
--		    echo "No <db.h> include file found." 1>&2
--		    echo "Install the appropriate db*-devel package first." 1>&2
--		    echo "See the RELEASE_NOTES file for more information." 1>&2
--		    exit 1
--		fi
-+		#if [ -f /usr/include/db.h ]
-+		#then
-+		    #: we are all set
-+		#elif [ -f /usr/include/db/db.h ]
-+		#then
-+		    #CCARGS="$CCARGS -I/usr/include/db"
-+		#else
-+		    ## On a properly installed system, Postfix builds
-+		    ## by including <db.h> and by linking with -ldb
-+		    #echo "No <db.h> include file found." 1>&2
-+		    #echo "Install the appropriate db*-devel package first." 1>&2
-+		    #echo "See the RELEASE_NOTES file for more information." 1>&2
-+		    #exit 1
-+		#fi
- 		SYSLIBS="-ldb"
- 		for name in nsl resolv
- 		do
diff --git a/pkgs/servers/mail/postfix/default.nix b/pkgs/servers/mail/postfix/default.nix
index 7bd2d6209108..41dfebab7907 100644
--- a/pkgs/servers/mail/postfix/default.nix
+++ b/pkgs/servers/mail/postfix/default.nix
@@ -1,65 +1,98 @@
-{ stdenv, fetchurl, db, glibc, openssl, cyrus_sasl
-, coreutils, findutils, gnused, gnugrep, bison, perl
+{ stdenv, lib, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl, libnsl
+, coreutils, findutils, gnugrep, gawk, icu, pcre
+, withPgSQL ? false, postgresql
+, withMySQL ? false, mysql
+, withSQLite ? false, sqlite
+, withLDAP ? false, openldap
 }:
 
-assert stdenv.isLinux;
+let
+  ccargs = lib.concatStringsSep " " ([
+    "-DUSE_TLS" "-DUSE_SASL_AUTH" "-DUSE_CYRUS_SASL" "-I${cyrus_sasl.dev}/include/sasl"
+    "-DHAS_DB_BYPASS_MAKEDEFS_CHECK"
+   ] ++ lib.optional withPgSQL "-DHAS_PGSQL"
+     ++ lib.optionals withMySQL [ "-DHAS_MYSQL" "-I${mysql.connector-c}/include/mysql" "-L${mysql.connector-c}/lib/mysql" ]
+     ++ lib.optional withSQLite "-DHAS_SQLITE"
+     ++ lib.optional withLDAP "-DHAS_LDAP");
+   auxlibs = lib.concatStringsSep " " ([
+     "-ldb" "-lnsl" "-lresolv" "-lsasl2" "-lcrypto" "-lssl"
+   ] ++ lib.optional withPgSQL "-lpq"
+     ++ lib.optional withMySQL "-lmysqlclient"
+     ++ lib.optional withSQLite "-lsqlite3"
+     ++ lib.optional withLDAP "-lldap");
 
-stdenv.mkDerivation rec {
-  name = "postfix-2.8.12";
+in stdenv.mkDerivation rec {
+
+  name = "postfix-${version}";
+
+  version = "3.3.1";
 
   src = fetchurl {
     url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz";
-    sha256 = "11z07mjy53l1fnl7k4101yk4ilibgqr1164628mqcbmmr8bh2szl";
+    sha256 = "0fvymsklp32njsv0ngc1f45j01kcy61r5in99g5palibwkd19xal";
   };
 
-  buildInputs = [db openssl cyrus_sasl bison perl];
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ db openssl cyrus_sasl icu libnsl pcre ]
+                ++ lib.optional withPgSQL postgresql
+                ++ lib.optional withMySQL mysql.connector-c
+                ++ lib.optional withSQLite sqlite
+                ++ lib.optional withLDAP openldap;
 
-  patches = [ ./postfix-2.2.9-db.patch  ./postfix-2.2.9-lib.patch ./db-linux3.patch ];
+  hardeningDisable = [ "format" ];
+  hardeningEnable = [ "pie" ];
 
-  postPatch = ''
-    sed -i -e s,/usr/bin,/var/run/current-system/sw/bin, \
-      -e s,/usr/sbin,/var/run/current-system/sw/bin, \
-      -e s,:/sbin,, src/util/sys_defs.h
-  '';
+  patches = [
+    ./postfix-script-shell.patch
+    ./postfix-3.0-no-warnings.patch
+    ./post-install-script.patch
+    ./relative-symlinks.patch
+  ];
 
   preBuild = ''
-    export daemon_directory=$out/libexec/postfix
+    sed -e '/^PATH=/d' -i postfix-install
+    sed -e "s|@PACKAGE@|$out|" -i conf/post-install
+
+    # post-install need skip permissions check/set on all symlinks following to /nix/store
+    sed -e "s|@NIX_STORE@|$NIX_STORE|" -i conf/post-install
+
     export command_directory=$out/sbin
-    export queue_directory=/var/spool/postfix
-    export sendmail_path=$out/bin/sendmail
-    export mailq_path=$out/bin/mailq
-    export newaliases_path=$out/bin/newaliases
+    export config_directory=/etc/postfix
+    export meta_directory=$out/etc/postfix
+    export daemon_directory=$out/libexec/postfix
+    export data_directory=/var/lib/postfix/data
     export html_directory=$out/share/postfix/doc/html
+    export mailq_path=$out/bin/mailq
     export manpage_directory=$out/share/man
-    export sample_directory=$out/share/postfix/doc/samples
+    export newaliases_path=$out/bin/newaliases
+    export queue_directory=/var/lib/postfix/queue
     export readme_directory=$out/share/postfix/doc
+    export sendmail_path=$out/bin/sendmail
 
-    make makefiles CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl -fPIE -fstack-protector-all --param ssp-buffer-size=4 -O2 -D_FORTIFY_SOURCE=2' AUXLIBS='-lssl -lcrypto -lsasl2 -ldb -lnsl -pie -Wl,-z,relro,-z,now'
+    make makefiles CCARGS='${ccargs}' AUXLIBS='${auxlibs}'
   '';
 
-  installPhase = ''
-    sed -e '/^PATH=/d' -i postfix-install
-    $SHELL postfix-install install_root=out -non-interactive -package
-
-    mkdir -p $out
-    mv -v "out$out/"* $out/
+  installTargets = [ "non-interactive-package" ];
 
-    mkdir -p $out/share/postfix
-    mv conf $out/share/postfix/
-    mv LICENSE TLS_LICENSE $out/share/postfix/
+  installFlags = [ "install_root=installdir" ];
 
-    sed -e 's@^PATH=.*@PATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:'$out'/sbin@' -i $out/share/postfix/conf/post-install $out/libexec/postfix/post-install
-    sed -e '2aPATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:'$out'/sbin' -i $out/share/postfix/conf/postfix-script $out/libexec/postfix/postfix-script
-    chmod a+x $out/share/postfix/conf/{postfix-script,post-install}
+  postInstall = ''
+    mkdir -p $out
+    mv -v installdir/$out/* $out/
+    cp -rv installdir/etc $out
+    sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install
+    wrapProgram $out/libexec/postfix/post-install \
+      --prefix PATH ":" ${lib.makeBinPath [ coreutils findutils gnugrep ]}
+    wrapProgram $out/libexec/postfix/postfix-script \
+      --prefix PATH ":" ${lib.makeBinPath [ coreutils findutils gnugrep gawk gnused ]}
   '';
 
-  inherit glibc;
-
   meta = {
-    homepage = "http://www.postfix.org/";
-    description = "a fast, easy to administer, and secure mail server";
-    license = stdenv.lib.licenses.bsdOriginal;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    homepage = http://www.postfix.org/;
+    description = "A fast, easy to administer, and secure mail server";
+    license = with lib.licenses; [ ipl10 epl20 ];
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.rickynils ];
   };
+
 }
diff --git a/pkgs/servers/mail/postfix/pfixtools.nix b/pkgs/servers/mail/postfix/pfixtools.nix
new file mode 100644
index 000000000000..8c00bcdbee25
--- /dev/null
+++ b/pkgs/servers/mail/postfix/pfixtools.nix
@@ -0,0 +1,55 @@
+{ stdenv, lib, fetchFromGitHub, git, gperf, pcre, unbound, libev, tokyocabinet, pkgconfig, bash, libsrs2 }:
+
+let
+  version = "0.9";
+
+  pfixtoolsSrc = fetchFromGitHub {
+    owner = "Fruneau";
+    repo = "pfixtools";
+    rev = "pfixtools-${version}";
+    sha256 = "1vmbrw686f41n6xfjphfshn96vl07ynvnsyjdw9yfn9bfnldcjcq";
+  };
+
+  srcRoot = pfixtoolsSrc.name;
+
+  libCommonSrc = fetchFromGitHub {
+    owner = "Fruneau";
+    repo = "libcommon";
+    rev = "b07e6bdea3d24748e0d39783d7d817096d10cc67";
+    sha256 = "14fxldp29j4vmfmhfgwwi37pj8cz0flm1aykkxlbgakz92d4pm35";
+  };
+
+in
+
+stdenv.mkDerivation {
+  name = "pfixtools-${version}";
+
+  src = pfixtoolsSrc;
+
+  patches = [ ./0001-Fix-build-with-unbound-1.6.1.patch ];
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [git gperf pcre unbound libev tokyocabinet bash libsrs2];
+
+  postUnpack = ''
+    cp -Rp ${libCommonSrc}/* ${srcRoot}/common;
+    chmod -R +w ${srcRoot}/common;
+  '';
+
+  postPatch = ''
+    substituteInPlace postlicyd/policy_tokens.sh \
+                      --replace /bin/bash ${bash}/bin/bash;
+  '';
+
+  NIX_CFLAGS_COMPILE = "-Wno-error=unused-result -Wno-error=nonnull-compare";
+
+  makeFlags = "DESTDIR=$(out) prefix=";
+
+  meta = {
+    description = "A collection of postfix-related tools";
+    license = with lib.licenses; [ bsd3 ];
+    homepage = https://github.com/Fruneau/pfixtools;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with lib.maintainers; [ jerith666 ];
+  };
+}
diff --git a/pkgs/servers/mail/postfix/pflogsumm.nix b/pkgs/servers/mail/postfix/pflogsumm.nix
new file mode 100644
index 000000000000..a9ec36f59ca9
--- /dev/null
+++ b/pkgs/servers/mail/postfix/pflogsumm.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, buildPerlPackage, perlPackages
+}:
+
+buildPerlPackage rec {
+  name = "pflogsumm-${version}";
+  version = "1.1.3";
+
+  src = fetchurl {
+    url = "http://jimsun.linxnet.com/downloads/${name}.tar.gz";
+    sha256 = "0hkim9s5f1yg5sfs5048jydhy3sbxafls496wcjk0cggxb113py4";
+  };
+
+  outputs = [ "out" "man" ];
+  buildInputs = [ perlPackages.DateCalc ];
+
+  preConfigure = ''
+    touch Makefile.PL
+  '';
+  doCheck = false;
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    mv "pflogsumm.pl" "$out/bin/pflogsumm"
+
+    mkdir -p "$out/share/man/man1"
+    mv "pflogsumm.1" "$out/share/man/man1"
+  '';
+
+  meta = {
+    homepage = http://jimsun.linxnet.com/postfix_contrib.html;
+    maintainers = with stdenv.lib.maintainers; [ schneefux ];
+    description = "Postfix activity overview";
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/pkgs/servers/mail/postfix/post-install-script.patch b/pkgs/servers/mail/postfix/post-install-script.patch
new file mode 100644
index 000000000000..350fbf929b74
--- /dev/null
+++ b/pkgs/servers/mail/postfix/post-install-script.patch
@@ -0,0 +1,28 @@
+--- a/conf/post-install	1970-01-01 03:00:01.000000000 +0300
++++ b/conf/post-install	2016-01-20 13:25:18.382233172 +0200
+@@ -254,6 +254,8 @@
+ }
+ 
+ # Bootstrapping problem.
++meta_directory="@PACKAGE@/etc/postfix"
++command_directory="@PACKAGE@/bin"
+ 
+ if [ -n "$command_directory" ]
+ then
+@@ -528,7 +530,16 @@
+ 	    # Skip uninstalled files.
+ 	    case $path in
+ 	    no|no/*) continue;;
++        # Skip immutable files from package, correct permissions provided by Nix.
++        @PACKAGE@/*) continue;
+ 	    esac
++        # Also skip symlinks following to /nix/store
++        if test -L $path; then
++            case "$(readlink $path)" in
++                @NIX_STORE@/*) continue;
++            esac
++        fi
++
+ 	    # Pick up the flags.
+ 	    case $flags in *u*) upgrade_flag=1;; *) upgrade_flag=;; esac
+ 	    case $flags in *c*) create_flag=1;; *) create_flag=;; esac
diff --git a/pkgs/servers/mail/postfix/postfix-2.11.0.patch b/pkgs/servers/mail/postfix/postfix-2.11.0.patch
deleted file mode 100644
index cdc4521c428a..000000000000
--- a/pkgs/servers/mail/postfix/postfix-2.11.0.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-diff -ruN postfix-2.11.0-orig/makedefs postfix-2.11.0/makedefs
---- postfix-2.11.0-orig/makedefs	2014-01-05 18:18:56.000000000 +0100
-+++ postfix-2.11.0/makedefs	2014-04-24 09:27:58.193869491 +0200
-@@ -290,36 +290,6 @@
- 		esac
- 		;;
-     Linux.2*)	SYSTYPE=LINUX2
--		case "$CCARGS" in
--		 *-DNO_DB*) ;;
--		 *-DHAS_DB*) ;;
--		 *) if [ -f /usr/include/db.h ]
--		    then
--			: we are all set
--		    elif [ -f /usr/include/db/db.h ]
--		    then
--			CCARGS="$CCARGS -I/usr/include/db"
--		    else
--			# No, we're not going to try db1 db2 db3 etc.
--			# On a properly installed system, Postfix builds
--			# by including <db.h> and by linking with -ldb
--			echo "No <db.h> include file found." 1>&2
--			echo "Install the appropriate db*-devel package first." 1>&2
--			exit 1
--		    fi
--		    SYSLIBS="-ldb"
--		    ;;
--		esac
--		for name in nsl resolv $GDBM_LIBS
--		do
--		    for lib in /usr/lib64 /lib64 /usr/lib /lib
--		    do
--			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
--			    SYSLIBS="$SYSLIBS -l$name"
--			    break
--			}
--		    done
--		done
- 		# Kernel 2.4 added IPv6
- 		case "$RELEASE" in
- 		2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
-@@ -363,35 +333,6 @@
- 		esac
- 		;;
-     Linux.3*)	SYSTYPE=LINUX3
--		case "$CCARGS" in
--		 *-DNO_DB*) ;;
--		 *-DHAS_DB*) ;;
--		 *) if [ -f /usr/include/db.h ]
--		    then
--			: we are all set
--		    elif [ -f /usr/include/db/db.h ]
--		    then
--			CCARGS="$CCARGS -I/usr/include/db"
--		    else
--			# On a properly installed system, Postfix builds
--			# by including <db.h> and by linking with -ldb
--			echo "No <db.h> include file found." 1>&2
--			echo "Install the appropriate db*-devel package first." 1>&2
--			exit 1
--		    fi
--		    SYSLIBS="-ldb"
--		    ;;
--		esac
--		for name in nsl resolv
--		do
--		    for lib in /usr/lib64 /lib64 /usr/lib /usr/lib/* /lib /lib/*
--		    do
--			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
--			    SYSLIBS="$SYSLIBS -l$name"
--			    break
--			}
--		    done
--		done
- 		;;
-      GNU.0*|GNU/kFreeBSD.[567]*)
- 		SYSTYPE=GNU0
diff --git a/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch b/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch
deleted file mode 100644
index 65f55ffd8f05..000000000000
--- a/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff -ruN postfix-2.2.9/makedefs postfix-2.2.9.new/makedefs
---- postfix-2.2.9/makedefs	2006-01-03 21:50:25.000000000 +0000
-+++ postfix-2.2.9.new/makedefs	2006-03-11 00:38:30.000000000 +0000
-@@ -219,21 +219,21 @@
- 		;;
-     Linux.2*)	SYSTYPE=LINUX2
- 		# Postfix no longer needs DB 1.85 compatibility
--		if [ -f /usr/include/db.h ]
--		then
--		    : we are all set
--		elif [ -f /usr/include/db/db.h ]
--		then
--		    CCARGS="$CCARGS -I/usr/include/db"
--		else
--		    # No, we're not going to try db1 db2 db3 etc.
--		    # On a properly installed system, Postfix builds
--		    # by including <db.h> and by linking with -ldb
--		    echo "No <db.h> include file found." 1>&2
--		    echo "Install the appropriate db*-devel package first." 1>&2
--		    echo "See the RELEASE_NOTES file for more information." 1>&2
--		    exit 1
--		fi
-+		#if [ -f /usr/include/db.h ]
-+		#then
-+		    #: we are all set
-+		#elif [ -f /usr/include/db/db.h ]
-+		#then
-+		    #CCARGS="$CCARGS -I/usr/include/db"
-+		#else
-+		    ## No, we're not going to try db1 db2 db3 etc.
-+		    ## On a properly installed system, Postfix builds
-+		    ## by including <db.h> and by linking with -ldb
-+		    #echo "No <db.h> include file found." 1>&2
-+		    #echo "Install the appropriate db*-devel package first." 1>&2
-+		    #echo "See the RELEASE_NOTES file for more information." 1>&2
-+		    #exit 1
-+		#fi
- 		# GDBM locks the DBM .pag file after open. This breaks postmap.
- 		# if [ -f /usr/include/gdbm-ndbm.h ]
- 		# then
diff --git a/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch b/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch
deleted file mode 100644
index 03dcaa87f238..000000000000
--- a/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ruN postfix-2.2.9/makedefs postfix-2.2.9.new/makedefs
---- postfix-2.2.9/makedefs	2006-01-03 21:50:25.000000000 +0000
-+++ postfix-2.2.9.new/makedefs	2006-03-11 01:40:30.000000000 +0000
-@@ -247,7 +247,7 @@
- 		SYSLIBS="-ldb"
- 		for name in nsl resolv $GDBM_LIBS
- 		do
--		    for lib in /usr/lib64 /lib64 /usr/lib /lib
-+		    for lib in $glibc/usr/lib64 $glibc/lib64 $glibc/usr/lib $glibc/lib
- 		    do
- 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
- 			    SYSLIBS="$SYSLIBS -l$name"
diff --git a/pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch b/pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch
new file mode 100644
index 000000000000..d93eaf0aaa0d
--- /dev/null
+++ b/pkgs/servers/mail/postfix/postfix-3.0-no-warnings.patch
@@ -0,0 +1,86 @@
+diff -ru3 postfix-3.0.3/conf/postfix-script postfix-3.0.3-new/conf/postfix-script
+--- postfix-3.0.3/conf/postfix-script	2014-06-27 18:05:15.000000000 +0400
++++ postfix-3.0.3-new/conf/postfix-script	2016-01-09 17:51:38.545733631 +0300
+@@ -84,24 +84,6 @@
+ 	exit 1
+ }
+ 
+-# If this is a secondary instance, don't touch shared files.
+-
+-instances=`test ! -f $def_config_directory/main.cf ||
+-    $command_directory/postconf -c $def_config_directory \
+-    -h multi_instance_directories | sed 's/,/ /'` || {
+-	$FATAL cannot execute $command_directory/postconf!
+-	exit 1
+-}
+-
+-check_shared_files=1
+-for name in $instances
+-do
+-    case "$name" in
+-    "$def_config_directory") ;;
+-    "$config_directory") check_shared_files=; break;;
+-    esac
+-done
+-
+ #
+ # Parse JCL
+ #
+@@ -262,22 +244,6 @@
+ 	    -prune \( -perm -020 -o -perm -002 \) \
+ 	    -exec $WARN group or other writable: {} \;
+ 
+-	# Check Postfix root-owned directory tree owner/permissions.
+-
+-	todo="$config_directory/."
+-	test -n "$check_shared_files" && {
+-		todo="$daemon_directory/. $meta_directory/. $todo"
+-		test "$shlib_directory" = "no" || 
+-		    todo="$shlib_directory/. $todo"
+-	}
+-	todo=`echo "$todo" | tr ' ' '\12' | sort -u`
+-
+-	find $todo ! -user root \
+-	    -exec $WARN not owned by root: {} \;
+-
+-	find $todo \( -perm -020 -o -perm -002 \) \
+-	    -exec $WARN group or other writable: {} \;
+-
+ 	# Check Postfix mail_owner-owned directory tree owner/permissions.
+ 
+ 	find $data_directory/. ! -user $mail_owner \
+@@ -302,18 +268,11 @@
+ 	# Check Postfix setgid_group-owned directory and file group/permissions.
+ 
+ 	todo="$queue_directory/public $queue_directory/maildrop"
+-	test -n "$check_shared_files" && 
+-	   todo="$command_directory/postqueue $command_directory/postdrop $todo"
+ 
+ 	find $todo \
+ 	    -prune ! -group $setgid_group \
+ 	    -exec $WARN not owned by group $setgid_group: {} \;
+ 
+-	test -n "$check_shared_files" &&
+-	find $command_directory/postqueue $command_directory/postdrop \
+-	    -prune ! -perm -02111 \
+-	    -exec $WARN not set-gid or not owner+group+world executable: {} \;
+-
+ 	# Check non-Postfix root-owned directory tree owner/content.
+ 
+ 	for dir in bin etc lib sbin usr
+@@ -334,15 +293,6 @@
+ 
+ 	find corrupt -type f -exec $WARN damaged message: {} \;
+ 
+-	# Check for non-Postfix MTA remnants.
+-
+-	test -n "$check_shared_files" -a -f /usr/sbin/sendmail -a \
+-		-f /usr/lib/sendmail && {
+-	    cmp -s /usr/sbin/sendmail /usr/lib/sendmail || {
+-		$WARN /usr/lib/sendmail and /usr/sbin/sendmail differ
+-		$WARN Replace one by a symbolic link to the other
+-	    }
+-	}
+ 	exit 0
+ 	;;
+ 
diff --git a/pkgs/servers/mail/postfix/postfix-script-shell.patch b/pkgs/servers/mail/postfix/postfix-script-shell.patch
new file mode 100644
index 000000000000..4f5d2f611110
--- /dev/null
+++ b/pkgs/servers/mail/postfix/postfix-script-shell.patch
@@ -0,0 +1,21 @@
+diff --git a/conf/postfix-script b/conf/postfix-script
+index 19088a6..04fae23 100755
+--- a/conf/postfix-script
++++ b/conf/postfix-script
+@@ -43,7 +43,6 @@ FATAL="$LOGGER -p fatal"
+ PANIC="$LOGGER -p panic"
+ 
+ umask 022
+-SHELL=/bin/sh
+ 
+ #
+ # Can't do much without these in place.
+@@ -229,7 +228,7 @@ status)
+ check-fatal)
+ 	# This command is NOT part of the public interface.
+ 
+-	$SHELL $daemon_directory/post-install create-missing || {
++	$daemon_directory/post-install create-missing || {
+ 		$FATAL unable to create missing queue directories
+ 		exit 1
+ 	}
diff --git a/pkgs/servers/mail/postfix/relative-symlinks.patch b/pkgs/servers/mail/postfix/relative-symlinks.patch
new file mode 100644
index 000000000000..f7a2078c0343
--- /dev/null
+++ b/pkgs/servers/mail/postfix/relative-symlinks.patch
@@ -0,0 +1,13 @@
+diff --git a/postfix-install b/postfix/postfix-install
+index 1662c3d..0f20ec0 100644
+--- a/postfix-install
++++ b/postfix-install
+@@ -336,7 +336,7 @@ compare_or_symlink() {
+ 	# 2) we cannot use mv to replace a symlink-to-directory;
+ 	# 3) "ln -n" is not in POSIX, therefore it's not portable.
+ 	# rm+ln is less atomic but this affects compatibility symlinks only.
+-	rm -f $2 && ln -sf $link $2 || exit 1
++	rm -f $2 && ln -rsf $link $2 || exit 1
+     }
+ }
+ 
diff --git a/pkgs/servers/mail/postgrey/default.nix b/pkgs/servers/mail/postgrey/default.nix
new file mode 100644
index 000000000000..1836d0e5cf36
--- /dev/null
+++ b/pkgs/servers/mail/postgrey/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, perl, perlPackages, lib, runCommand, postfix }:
+
+let
+    mk-perl-flags = inputs: lib.concatStringsSep " " (map (dep: "-I ${dep}/lib/perl5/site_perl") inputs);
+    postgrey-flags = mk-perl-flags (with perlPackages; [
+      NetServer BerkeleyDB DigestSHA1 NetAddrIP IOMultiplex
+    ]);
+    policy-test-flags = mk-perl-flags (with perlPackages; [
+      ParseSyslog
+    ]);
+    version = "1.37";
+    name = "postgrey-${version}";
+in runCommand name {
+  src = fetchurl {
+    url = "http://postgrey.schweikert.ch/pub/${name}.tar.gz";
+    sha256 = "1xx51xih4711vrvc6d57il9ccallbljj5zhgqdb07jzmz11rakgz";
+  };
+  meta = with stdenv.lib; {
+    description = "A postfix policy server to provide greylisting";
+    homepage = https://postgrey.schweikert.ch/;
+    platforms = postfix.meta.platforms;
+    license = licenses.gpl2;
+  };
+} ''
+    mkdir -p $out/bin
+    cd $out
+    tar -xzf $src --strip-components=1
+    mv postgrey policy-test bin
+    sed -i -e "s,#!/usr/bin/perl -T,#!${perl}/bin/perl -T ${postgrey-flags}," \
+           -e "s#/etc/postfix#$out#" \
+        bin/postgrey
+    sed -i -e "s,#!/usr/bin/perl,#!${perl}/bin/perl ${policy-test-flags}," \
+        bin/policy-test
+''
diff --git a/pkgs/servers/mail/postsrsd/default.nix b/pkgs/servers/mail/postsrsd/default.nix
new file mode 100644
index 000000000000..01eeeb15efaf
--- /dev/null
+++ b/pkgs/servers/mail/postsrsd/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, cmake, help2man }:
+
+stdenv.mkDerivation rec {
+  name = "postsrsd-${version}";
+  version = "1.4";
+
+  src = fetchFromGitHub {
+    owner = "roehling";
+    repo = "postsrsd";
+    rev = version;
+    sha256 = "09yzb0fvnbfy534maqlqk79c41p1yz8r9f73n7bahm5lwd0livk9";
+  };
+
+  cmakeFlags = [ "-DGENERATE_SRS_SECRET=OFF" "-DINIT_FLAVOR=systemd" ];
+
+  preConfigure = ''
+    sed -i "s,\"/etc\",\"$out/etc\",g" CMakeLists.txt
+  '';
+
+  nativeBuildInputs = [ cmake help2man ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/roehling/postsrsd;
+    description = "Postfix Sender Rewriting Scheme daemon";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/pkgs/servers/mail/pypolicyd-spf/default.nix b/pkgs/servers/mail/pypolicyd-spf/default.nix
new file mode 100644
index 000000000000..d5e410a86c1f
--- /dev/null
+++ b/pkgs/servers/mail/pypolicyd-spf/default.nix
@@ -0,0 +1,26 @@
+{ lib, buildPythonApplication, fetchurl, pyspf }:
+
+buildPythonApplication rec {
+  name = "pypolicyd-spf-${version}";
+  majorVersion = "2.0";
+  version = "${majorVersion}.2";
+
+  src = fetchurl {
+    url = "https://launchpad.net/pypolicyd-spf/${majorVersion}/${version}/+download/${name}.tar.gz";
+    sha256 = "1nm8y1jjgx6mxrbcxrbdnmkf8vglwp0wiw6jipzh641wb24gi76z";
+  };
+
+  propagatedBuildInputs = [ pyspf ];
+
+  preBuild = ''
+    substituteInPlace setup.py --replace "'/etc'" "'$out/etc'"
+  '';
+
+  meta = with lib; {
+    homepage = https://launchpad.net/pypolicyd-spf/;
+    description = "Postfix policy engine for Sender Policy Framework (SPF) checking";
+    maintainers = with maintainers; [ abbradar ];
+    license = licenses.asl20;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/mail/rmilter/default.nix b/pkgs/servers/mail/rmilter/default.nix
new file mode 100644
index 000000000000..739270326e5b
--- /dev/null
+++ b/pkgs/servers/mail/rmilter/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, cmake, bison, flex, pkgconfig, openssl, pcre
+, libmilter, opendkim, libmemcached, glib }:
+
+let patchedLibmilter = stdenv.lib.overrideDerivation  libmilter (_ : {
+    patches = libmilter.patches ++ [ ./fd-passing-libmilter.patch ];
+});
+in
+
+stdenv.mkDerivation rec {
+  name = "rmilter-${version}";
+  version = "1.10.0";
+
+  src = fetchFromGitHub {
+    owner = "vstakhov";
+    repo = "rmilter";
+    rev = version;
+    sha256 = "1gbp6jah88l6xqgflim01ycyp63l733bgir65fxnnrmifj1qzymh";
+  };
+
+  nativeBuildInputs = [ bison cmake flex pkgconfig ];
+  buildInputs = [ libmemcached patchedLibmilter openssl pcre opendkim glib ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/vstakhov/rmilter;
+    license = licenses.asl20;
+    description = ''
+      Daemon to integrate rspamd and milter compatible MTA, for example
+      postfix or sendmail
+    '';
+    maintainers = with maintainers; [ avnik fpletz ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/pkgs/servers/mail/rmilter/fd-passing-libmilter.patch b/pkgs/servers/mail/rmilter/fd-passing-libmilter.patch
new file mode 100644
index 000000000000..3ab61a6fab00
--- /dev/null
+++ b/pkgs/servers/mail/rmilter/fd-passing-libmilter.patch
@@ -0,0 +1,80 @@
+Description: systemd-like socket activation support for libmilter
+Author: Mikhail Gusarov <dottedmag@debian.org
+diff --git a/libmilter/docs/smfi_setconn.html b/libmilter/docs/smfi_setconn.html
+index 70a510e..013f04e 100644
+--- a/libmilter/docs/smfi_setconn.html
++++ b/libmilter/docs/smfi_setconn.html
+@@ -43,6 +43,7 @@ Set the socket through which this filter should communicate with sendmail.
+ 	<LI><CODE>{unix|local}:/path/to/file</CODE> -- A named pipe.
+ 	<LI><CODE>inet:port@{hostname|ip-address}</CODE> -- An IPV4 socket.
+ 	<LI><CODE>inet6:port@{hostname|ip-address}</CODE> -- An IPV6 socket.
++	<LI><CODE>fd:number</CODE> -- Pre-opened file descriptor.
+ 	</UL>
+ 	</TD></TR>
+     </TABLE>
+diff --git a/libmilter/listener.c b/libmilter/listener.c
+index 48c552f..2249a1f 100644
+--- a/libmilter/listener.c
++++ b/libmilter/listener.c
+@@ -197,6 +197,11 @@ mi_milteropen(conn, backlog, rmsocket, name)
+ 			L_socksize = sizeof addr.sin6;
+ 		}
+ #endif /* NETINET6 */
++		else if (strcasecmp(p, "fd") == 0)
++		{
++			addr.sa.sa_family = AF_UNSPEC;
++			L_socksize = sizeof (_SOCK_ADDR);
++		}
+ 		else
+ 		{
+ 			smi_log(SMI_LOG_ERR, "%s: unknown socket type %s",
+@@ -443,7 +448,21 @@ mi_milteropen(conn, backlog, rmsocket, name)
+ 	}
+ #endif /* NETINET || NETINET6 */
+ 
+-	sock = socket(addr.sa.sa_family, SOCK_STREAM, 0);
++	if (addr.sa.sa_family == AF_UNSPEC)
++	{
++		char *end;
++		sock = strtol(colon, &end, 10);
++		if (*end != '\0' || sock < 0)
++		{
++			smi_log(SMI_LOG_ERR, "%s: expected positive integer as fd, got %s", name, colon);
++			return INVALID_SOCKET;
++		}
++	}
++	else
++	{
++		sock = socket(addr.sa.sa_family, SOCK_STREAM, 0);
++	}
++
+ 	if (!ValidSocket(sock))
+ 	{
+ 		smi_log(SMI_LOG_ERR,
+@@ -466,6 +485,7 @@ mi_milteropen(conn, backlog, rmsocket, name)
+ #if NETUNIX
+ 	    addr.sa.sa_family != AF_UNIX &&
+ #endif /* NETUNIX */
++	    addr.sa.sa_family != AF_UNSPEC &&
+ 	    setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sockopt,
+ 		       sizeof(sockopt)) == -1)
+ 	{
+@@ -511,7 +531,8 @@ mi_milteropen(conn, backlog, rmsocket, name)
+ 	}
+ #endif /* NETUNIX */
+ 
+-	if (bind(sock, &addr.sa, L_socksize) < 0)
++	if (addr.sa.sa_family != AF_UNSPEC &&
++	    bind(sock, &addr.sa, L_socksize) < 0)
+ 	{
+ 		smi_log(SMI_LOG_ERR,
+ 			"%s: Unable to bind to port %s: %s",
+@@ -817,7 +838,7 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
+ # ifdef BSD4_4_SOCKADDR
+ 		     cliaddr.sa.sa_len == 0 ||
+ # endif /* BSD4_4_SOCKADDR */
+-		     cliaddr.sa.sa_family != L_family))
++		     (L_family != AF_UNSPEC && cliaddr.sa.sa_family != L_family)))
+ 		{
+ 			(void) closesocket(connfd);
+ 			connfd = INVALID_SOCKET;
diff --git a/pkgs/servers/mail/rspamd/default.nix b/pkgs/servers/mail/rspamd/default.nix
new file mode 100644
index 000000000000..3e3132798068
--- /dev/null
+++ b/pkgs/servers/mail/rspamd/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, cmake, perl
+, file, glib, gmime, libevent, luajit, openssl, pcre, pkgconfig, sqlite, ragel, icu, libfann }:
+
+let libmagic = file;  # libmagic provided by file package ATM
+in
+
+stdenv.mkDerivation rec {
+  name = "rspamd-${version}";
+  version = "1.6.6";
+
+  src = fetchFromGitHub {
+    owner = "vstakhov";
+    repo = "rspamd";
+    rev = version;
+    sha256 = "04jqrki7rlxywdig264kavy1h5882rspi2drkbdzrk35jjq8rh3h";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig perl ];
+  buildInputs = [ glib gmime libevent libmagic luajit openssl pcre sqlite ragel icu libfann];
+
+  postPatch = ''
+    substituteInPlace conf/common.conf --replace "\$CONFDIR/rspamd.conf.local" "/etc/rspamd/rspamd.conf.local"
+    substituteInPlace conf/common.conf --replace "\$CONFDIR/rspamd.conf.local.override" "/etc/rspamd/rspamd.conf.local.override"
+  '';
+
+  cmakeFlags = ''
+    -DDEBIAN_BUILD=ON
+    -DRUNDIR=/var/run/rspamd
+    -DDBDIR=/var/lib/rspamd
+    -DLOGDIR=/var/log/rspamd
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/vstakhov/rspamd;
+    license = licenses.asl20;
+    description = "Advanced spam filtering system";
+    maintainers = with maintainers; [ avnik fpletz ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/pkgs/servers/mail/spamassassin/default.nix b/pkgs/servers/mail/spamassassin/default.nix
index 8590f80c8aea..acbc50fd42bf 100644
--- a/pkgs/servers/mail/spamassassin/default.nix
+++ b/pkgs/servers/mail/spamassassin/default.nix
@@ -1,17 +1,7 @@
-{ stdenv, fetchurl, buildPerlPackage, perl, HTMLParser, NetDNS, NetAddrIP, DBFile
+{ stdenv, fetchurl, buildPerlPackage, perl, perlPackages, HTMLParser, NetDNS, NetAddrIP, DBFile
 , HTTPDate, MailDKIM, LWP, IOSocketSSL, makeWrapper, gnupg1
 }:
 
-# TODO: Add the Perl modules ...
-#
-#   DBI
-#   Encode::Detect
-#   IP::Country::Fast
-#   Mail::SPF
-#   Net::Ident
-#   Razor2::Client::Agent
-#
-
 buildPerlPackage rec {
   name = "SpamAssassin-3.4.1";
 
@@ -20,14 +10,17 @@ buildPerlPackage rec {
     sha256 = "0la6s5ilamf9129kyjckcma8cr6fpb6b5f2fb64v7106iy0ckhd0";
   };
 
-  buildInputs = [ makeWrapper HTMLParser NetDNS NetAddrIP DBFile HTTPDate MailDKIM
-    LWP IOSocketSSL ];
+  # https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7434
+  patches = [ ./sa-update_add--siteconfigpath.patch ];
+
+  buildInputs = with perlPackages; [ makeWrapper HTMLParser NetDNS NetAddrIP DBFile HTTPDate MailDKIM
+    LWP IOSocketSSL DBI EncodeDetect IPCountry NetIdent Razor2ClientAgent MailSPF NetDNSResolverProgrammable ];
 
   # Enabling 'taint' mode is desirable, but that flag disables support
   # for the PERL5LIB environment variable. Needs further investigation.
   makeFlags = "PERL_BIN=${perl}/bin/perl PERL_TAINT=no";
 
-  makeMakerFlags = "CONFDIR=/etc/spamassassin LOCALSTATEDIR=/var/lib/spamassassin";
+  makeMakerFlags = "CONFDIR=/homeless/shelter LOCALSTATEDIR=/var/lib/spamassassin";
 
   doCheck = false;
 
@@ -41,10 +34,10 @@ buildPerlPackage rec {
   '';
 
   meta = {
-    homepage = "http://spamassassin.apache.org/";
+    homepage = http://spamassassin.apache.org/;
     description = "Open-Source Spam Filter";
     license = stdenv.lib.licenses.asl20;
     platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    maintainers = with stdenv.lib.maintainers; [ peti qknight ];
   };
 }
diff --git a/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch b/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch
new file mode 100644
index 000000000000..3264aefc0722
--- /dev/null
+++ b/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch
@@ -0,0 +1,59 @@
+From 60abf3ee8864980a95b32e2d6cf60e26b49654c0 Mon Sep 17 00:00:00 2001
+From: joachim schiele <js@lastlog.de>
+Date: Wed, 7 Jun 2017 22:15:39 +0200
+Subject: [PATCH 2/2] Adding --siteconfigpath to not be forced to use global /etc/spamasassin configuration directory but to provide an alternative location.
+
+---
+ sa-update.raw | 5 +++++
+ lib/Mail/SpamAssassin/PerMsgStatus.pm | 2 +
+ 2 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/sa-update.raw b/sa-update.raw
+index bb7396d..39f681f 100755
+--- a/sa-update.raw
++++ b/sa-update.raw
+@@ -196,6 +196,7 @@ GetOptions(
+   'gpgkeyfile=s'			=> \$opt{'gpgkeyfile'},
+   'channelfile=s'			=> \$opt{'channelfile'},
+   'updatedir=s'				=> \$opt{'updatedir'},
++  'siteconfigpath=s'                           => \$opt{'siteconfigpath'},
+   'gpg!'				=> \$GPG_ENABLED,
+ 
+   '4'                                   => sub { $opt{'force_pf'} = 'inet' },
+@@ -267,6 +268,9 @@ else {
+   $opt{'updatedir'} = $SA->sed_path('__local_state_dir__/__version__');
+ }
+ 
++if (defined $opt{'siteconfigpath'}) {
++  $LOCAL_RULES_DIR = untaint_file_path($opt{'siteconfigpath'});
++}
+ 
+ # check only disabled gpg
+ # https://issues.apache.org/SpamAssassin/show_bug.cgi?id=5854
+@@ -1808,6 +1812,7 @@ Options:
+   --updatedir path        Directory to place updates, defaults to the
+                           SpamAssassin site rules directory
+                           (default: @@LOCAL_STATE_DIR@@/@@VERSION@@)
++  --siteconfigpath=path   Path for site configs
+   --refreshmirrors        Force the MIRRORED.BY file to be updated
+   -D, --debug [area=n,...]  Print debugging messages
+   -v, --verbose           Be verbose, like print updated channel names;
+-- 
+diff --git a/lib/Mail/SpamAssassin/PerMsgStatus.pm b/lib/Mail/SpamAssassin/PerMsgStatus.pm
+index 6d8beaa..6ad87dc 100644
+--- a/lib/Mail/SpamAssassin/PerMsgStatus.pm
++++ b/lib/Mail/SpamAssassin/PerMsgStatus.pm
+@@ -389,7 +389,8 @@ sub check_timed {
+     if (!$self->{main}->have_plugin("check_main")) {
+       die "check: no loaded plugin implements 'check_main': cannot scan!\n".
+             "Check that the necessary '.pre' files are in the config directory.\n".
+-              "At a minimum, v320.pre loads the Check plugin which is required.\n";
++              "At a minimum, v320.pre loads the Check plugin which is required.\n".
++              "NixOS: Since there is no '/etc/spamassassin' simply restart 'spamd.service' which on its behalf will run 'sa-learn --siteconfigpath=/nix/store/l4hr4yxk8mb4wbkha6vm6rh92pj19rj6-spamd-env ...' to update the /var/lib/spamassassin configs.\n";
+     }
+   }
+ 
+-- 
+
+2.12.2
+
diff --git a/pkgs/servers/matrix-synapse/default.nix b/pkgs/servers/matrix-synapse/default.nix
new file mode 100644
index 000000000000..302aa8d55932
--- /dev/null
+++ b/pkgs/servers/matrix-synapse/default.nix
@@ -0,0 +1,64 @@
+{ lib, pkgs, stdenv, pythonPackages, fetchurl, fetchFromGitHub, fetchpatch }:
+let
+  matrix-angular-sdk = pythonPackages.buildPythonPackage rec {
+    name = "matrix-angular-sdk-${version}";
+    version = "0.6.8";
+
+    src = fetchurl {
+      url = "mirror://pypi/m/matrix-angular-sdk/matrix-angular-sdk-${version}.tar.gz";
+      sha256 = "0gmx4y5kqqphnq3m7xk2vpzb0w2a4palicw7wfdr1q2schl9fhz2";
+    };
+  };
+  matrix-synapse-ldap3 = pythonPackages.buildPythonPackage rec {
+    pname = "matrix-synapse-ldap3";
+    version = "0.1.3";
+
+    src = fetchFromGitHub {
+      owner = "matrix-org";
+      repo = "matrix-synapse-ldap3";
+      rev = "v${version}";
+      sha256 = "0ss7ld3bpmqm8wcs64q1kb7vxlpmwk9lsgq0mh21a9izyfc7jb2l";
+    };
+
+    propagatedBuildInputs = with pythonPackages; [ service-identity ldap3 twisted ];
+
+    checkInputs = with pythonPackages; [ ldaptor mock ];
+  };
+in pythonPackages.buildPythonApplication rec {
+  name = "matrix-synapse-${version}";
+  version = "0.31.2";
+
+  src = fetchFromGitHub {
+    owner = "matrix-org";
+    repo = "synapse";
+    rev = "v${version}";
+    sha256 = "15nfdq5s0d4bv1in6vymhq70hpz48p0nlzx25wxpibbrix630h8q";
+  };
+
+  patches = [
+    ./matrix-synapse.patch
+  ];
+
+  propagatedBuildInputs = with pythonPackages; [
+    blist canonicaljson daemonize dateutil frozendict pillow pyasn1
+    pydenticon pymacaroons-pynacl pynacl pyopenssl pysaml2 pytz requests
+    signedjson systemd twisted ujson unpaddedbase64 pyyaml prometheus_client
+    matrix-angular-sdk bleach netaddr jinja2 psycopg2
+    psutil msgpack-python lxml matrix-synapse-ldap3
+    phonenumbers jsonschema affinity bcrypt
+  ];
+
+  # Checks fail because of Tox.
+  doCheck = false;
+
+  buildInputs = with pythonPackages; [
+    mock setuptoolsTrial
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://matrix.org;
+    description = "Matrix reference homeserver";
+    license = licenses.asl20;
+    maintainers = [ maintainers.ralith maintainers.roblabla ];
+  };
+}
diff --git a/pkgs/servers/matrix-synapse/matrix-synapse.patch b/pkgs/servers/matrix-synapse/matrix-synapse.patch
new file mode 100644
index 000000000000..288e6ff16245
--- /dev/null
+++ b/pkgs/servers/matrix-synapse/matrix-synapse.patch
@@ -0,0 +1,20 @@
+diff --git a/homeserver b/homeserver
+new file mode 120000
+index 0000000..2f1d413
+--- /dev/null
++++ b/homeserver
+@@ -0,0 +1,1 @@
++synapse/app/homeserver.py
+\ No newline at end of file
+diff --git a/setup.py b/setup.py
+index b00c2af..c7f6e0a 100755
+--- a/setup.py
++++ b/setup.py
+@@ -92,6 +92,6 @@ setup(
+     include_package_data=True,
+     zip_safe=False,
+     long_description=long_description,
+-    scripts=["synctl"] + glob.glob("scripts/*"),
++    scripts=["synctl", "homeserver"] + glob.glob("scripts/*"),
+     cmdclass={'test': TestCommand},
+ )
diff --git a/pkgs/servers/matterbridge/default.nix b/pkgs/servers/matterbridge/default.nix
new file mode 100644
index 000000000000..14662ff6cc25
--- /dev/null
+++ b/pkgs/servers/matterbridge/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, buildGoPackage, fetchurl }:
+
+buildGoPackage rec {
+  name = "matterbridge-${version}";
+  version = "1.7.1";
+
+  goPackagePath = "github.com/42wim/matterbridge";
+
+  src = fetchurl {
+    url = "https://github.com/42wim/matterbridge/archive/v${version}.tar.gz";
+    sha256 = "0ajc7xswmwhc2xn937sv3b76s8hblfn9x9rj5825hi3d3s8zqq88";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Simple bridge between Mattermost, IRC, XMPP, Gitter, Slack, Discord, Telegram, Rocket.Chat, Hipchat(via xmpp), Matrix and Steam";
+    homepage = https://github.com/42wim/matterbridge;
+    license = with licenses; [ asl20 ];
+    maintainers = with maintainers; [ ryantm ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/mattermost/default.nix b/pkgs/servers/mattermost/default.nix
new file mode 100644
index 000000000000..9943c0b9ab03
--- /dev/null
+++ b/pkgs/servers/mattermost/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchurl, fetchFromGitHub, buildGoPackage, buildEnv }:
+
+let
+  version = "4.10.0";
+
+  mattermost-server = buildGoPackage rec {
+    name = "mattermost-server-${version}";
+
+    src = fetchFromGitHub {
+      owner = "mattermost";
+      repo = "mattermost-server";
+      rev = "v${version}";
+      sha256 = "02isw8qapp35pgriy4w1ar1ppvgc5a10j550hjbc1mylnhzkg1jf";
+    };
+
+    goPackagePath = "github.com/mattermost/mattermost-server";
+
+    buildFlagsArray = ''
+      -ldflags=
+        -X ${goPackagePath}/model.BuildNumber=nixpkgs-${version}
+    '';
+
+    postInstall = ''
+      ln -s $bin/bin/mattermost-server $bin/bin/platform
+      ln -s $bin/bin/mattermost-server $bin/bin/mattermost-platform
+    '';
+
+  };
+
+  mattermost-webapp = stdenv.mkDerivation {
+    name = "mattermost-webapp-${version}";
+
+    src = fetchurl {
+      url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz";
+      sha256 = "0pfj2dxl4qrv4w6yj0385nw0fa4flcg95kkahs0arwhan5bgifl5";
+    };
+
+    installPhase = ''
+      mkdir -p $out
+      tar --strip 1 --directory $out -xf $src \
+        mattermost/client \
+        mattermost/i18n \
+        mattermost/fonts \
+        mattermost/templates \
+        mattermost/config
+    '';
+  };
+
+in
+  buildEnv {
+    name = "mattermost-${version}";
+    paths = [ mattermost-server mattermost-webapp ];
+
+    meta = with stdenv.lib; {
+      description = "Open-source, self-hosted Slack-alternative";
+      homepage = https://www.mattermost.org;
+      license = with licenses; [ agpl3 asl20 ];
+      maintainers = with maintainers; [ fpletz ryantm ];
+      platforms = platforms.unix;
+    };
+  }
diff --git a/pkgs/servers/mattermost/matterircd.nix b/pkgs/servers/mattermost/matterircd.nix
new file mode 100644
index 000000000000..d489deb5944f
--- /dev/null
+++ b/pkgs/servers/mattermost/matterircd.nix
@@ -0,0 +1,23 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "matterircd-${version}";
+  version = "0.16.5";
+
+  src = fetchFromGitHub {
+    owner = "42wim";
+    repo = "matterircd";
+    rev = "v${version}";
+    sha256 = "1rsmc2dpf25rkl8c085xwssbry3hv1gv318m7rdj616agx4m7yr2";
+  };
+
+  goPackagePath = "github.com/42wim/matterircd";
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Minimal IRC server bridge to Mattermost";
+    license = licenses.mit;
+    maintainers = with maintainers; [ fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/mediatomb/default.nix b/pkgs/servers/mediatomb/default.nix
index 4d3ef231af3f..75d12a5f66fe 100644
--- a/pkgs/servers/mediatomb/default.nix
+++ b/pkgs/servers/mediatomb/default.nix
@@ -1,19 +1,18 @@
 { stdenv, fetchgit
-, sqlite, expat, mp4v2, flac, spidermonkey, taglib, libexif, curl, ffmpeg, file
+, sqlite, expat, mp4v2, flac, spidermonkey_1_8_5, taglib, libexif, curl, ffmpeg, file
 , pkgconfig, autoreconfHook }:
 
 stdenv.mkDerivation rec {
-
   name = "mediatomb-${version}";
   version = "0.12.1";
 
   src = fetchgit {
     url = meta.repositories.git;
     rev = "7ab761696354868bd5d67ff4f2d849994e4c98e2";
-    sha256 = "7b51d488ac0b93c7720f8f8373970884a55b0879b1f6941873e916f41177d062";
+    sha256 = "1mimslr4q6mky865y6561rr64cbn4gf0qc2dhgb31hxp4rc1kmzd";
   };
 
-  buildInputs = [ sqlite expat spidermonkey taglib libexif curl ffmpeg file mp4v2 flac
+  buildInputs = [ sqlite expat spidermonkey_1_8_5 taglib libexif curl ffmpeg file mp4v2 flac
                   pkgconfig autoreconfHook ];
 
   meta = with stdenv.lib; {
diff --git a/pkgs/servers/meguca/default.nix b/pkgs/servers/meguca/default.nix
new file mode 100644
index 000000000000..bfe21543555d
--- /dev/null
+++ b/pkgs/servers/meguca/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, buildGoPackage, fetchgit, pkgconfig, ffmpeg-full, graphicsmagick, ghostscript, quicktemplate,
+  go-bindata, easyjson, nodePackages, cmake, emscripten }:
+
+buildGoPackage rec {
+  name = "meguca-unstable-${version}";
+  version = "2018-05-26";
+  rev = "9f3d902fb899dbc874c1a91298d86fda7da59b1e";
+  goPackagePath = "github.com/bakape/meguca";
+  goDeps = ./server_deps.nix;
+  enableParallelBuilding = true;
+  nativeBuildInputs = [ pkgconfig cmake ];
+  buildInputs = [ ffmpeg-full graphicsmagick ghostscript quicktemplate go-bindata easyjson emscripten ];
+
+  src = fetchgit {
+    inherit rev;
+    url = "https://github.com/bakape/meguca";
+    sha256 = "0qblllf23pxcwi5fhaq8xc77iawll7v7xpk2mf9ngks3h8p7gddq";
+    fetchSubmodules = true;
+  };
+
+  configurePhase = ''
+    export HOME=$PWD
+    export GOPATH=$GOPATH:$HOME/go
+    ln -sf ${nodePackages.meguca}/lib/node_modules/meguca/node_modules
+    sed -i "/npm install --progress false --depth 0/d" Makefile
+    make generate_clean
+    go generate meguca/...
+  '';
+
+  buildPhase = ''
+    go build -p $NIX_BUILD_CORES meguca
+    make -j $NIX_BUILD_CORES client wasm
+  '';
+
+  installPhase = ''
+    mkdir -p $bin/bin $bin/share/meguca
+    cp meguca $bin/bin
+    cp -r www $bin/share/meguca
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/bakape/meguca";
+    description = "Anonymous realtime imageboard focused on high performance, free speech and transparent moderation";
+    license = licenses.agpl3Plus;
+    maintainers = with maintainers; [ chiiruno ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/meguca/server_deps.nix b/pkgs/servers/meguca/server_deps.nix
new file mode 100644
index 000000000000..493297b9757f
--- /dev/null
+++ b/pkgs/servers/meguca/server_deps.nix
@@ -0,0 +1,255 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/Masterminds/squirrel";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Masterminds/squirrel";
+      rev = "40ef4f86bf59a996c348a9f56ddb4c4d3d49a6df";
+      sha256 = "1zdv8hds2skqz9xrybf1pw5hfxzd27c35fsrfq11ryif1wxwbkyp";
+    };
+  }
+  {
+    goPackagePath = "github.com/Soreil/apngdetector";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Soreil/apngdetector";
+      rev = "e412c29dbc998dfcffe266b12587b29096ac4d46";
+      sha256 = "0ci71nk6jijspzbgcfrgi4in9lmd2c39f6xzcf9k3z9ixwv8c79j";
+    };
+  }
+  {
+    goPackagePath = "github.com/aquilax/tripcode";
+    fetch = {
+      type = "git";
+      url = "https://github.com/aquilax/tripcode";
+      rev = "db58da84bb12e26032493b73eb3b58ba884590ef";
+      sha256 = "0maqk0rwp39kcc64w4mfkgcvn2q76hqwziwc3g7ckc1qpwxql5z3";
+    };
+  }
+  {
+    goPackagePath = "github.com/bakape/mnemonics";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bakape/mnemonics";
+      rev = "056d8d3259923b93bb0449a45b0c56ac20c77f1b";
+      sha256 = "137dl4bkpszj7pm4dyj222xdvy9lmwsgmm0l6bxni0msc3jdrqkl";
+    };
+  }
+  {
+    goPackagePath = "github.com/bakape/thumbnailer";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bakape/thumbnailer";
+      rev = "5b92eb4c4500fd8e004e4cc9eeb2038961e2004f";
+      sha256 = "0z9myzp6rjyylh91ibd1nfpz7za1gxg4n3pnn7sw54i9zyws1l4x";
+    };
+  }
+  {
+    goPackagePath = "github.com/boltdb/bolt";
+    fetch = {
+      type = "git";
+      url = "https://github.com/boltdb/bolt";
+      rev = "fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5";
+      sha256 = "12f5swiwzcamk87r9j73nn7rmyyday7jkgzfh7x5wdg9blzhrir2";
+    };
+  }
+  {
+    goPackagePath = "github.com/dchest/captcha";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dchest/captcha";
+      rev = "6a29415a8364ec2971fdc62d9e415ed53fc20410";
+      sha256 = "0j0yspx5rlyx7fdfcx74viqc8jlq3nwyd62bdx4gvbd56cppldcm";
+    };
+  }
+  {
+    goPackagePath = "github.com/dimfeld/httptreemux";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dimfeld/httptreemux";
+      rev = "7f532489e7739b3d49df5c602bf63549881fe753";
+      sha256 = "0hkw04rsvljvx8ynqjgz9cb743x09fd2xiiycrgz5vbsa8q9iyyk";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-playground/ansi";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-playground/ansi";
+      rev = "777788a9be1a7296979a999c86b251fc777077a9";
+      sha256 = "1y2pqx04lc7cqg50scfivzw0n8f0dliflnih14f5jf4svff8s561";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-playground/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-playground/errors";
+      rev = "14d2d30656a95a5fa5a17d2e33540269eda5f158";
+      sha256 = "0w13vgxwc1x780x716kqzzwp9ld3w3jpkclabh2qwpcwx821nhpy";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-playground/log";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-playground/log";
+      rev = "91a5908e654f9fc444a71ea3c51c72cb5c6c2442";
+      sha256 = "0p67j453pi7ffv3axl5g97qadx8lj22vsi5xrzqrr3v6mj8b0lbm";
+    };
+  }
+  {
+    goPackagePath = "github.com/gorilla/handlers";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/handlers";
+      rev = "13a38d26174b16d5b4bf6f1094c1389ec9879572";
+      sha256 = "0zg43blpyyy667y0kpiifk5a2w35jh8qkk4zwlabb365c0lzrv6v";
+    };
+  }
+  {
+    goPackagePath = "github.com/gorilla/websocket";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/websocket";
+      rev = "21ab95fa12b9bdd8fecf5fa3586aad941cc98785";
+      sha256 = "1ygg6cr84461d6k3nzbja0dxhcgf5zvry2w10f6i7291ghrcwhyy";
+    };
+  }
+  {
+    goPackagePath = "github.com/kardianos/osext";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kardianos/osext";
+      rev = "ae77be60afb1dcacde03767a8c37337fad28ac14";
+      sha256 = "056dkgxrqjj5r18bnc3knlpgdz5p3yvp12y4y978hnsfhwaqvbjz";
+    };
+  }
+  {
+    goPackagePath = "github.com/lann/builder";
+    fetch = {
+      type = "git";
+      url = "https://github.com/lann/builder";
+      rev = "1b87b36280d04fe7882d1512bf038ea2967ad534";
+      sha256 = "015q46awbyp47vld07yi7d27i0lkd82r7qn5230bb9qxl4mcfiqc";
+    };
+  }
+  {
+    goPackagePath = "github.com/lann/ps";
+    fetch = {
+      type = "git";
+      url = "https://github.com/lann/ps";
+      rev = "62de8c46ede02a7675c4c79c84883eb164cb71e3";
+      sha256 = "10yhcyymypvdiiipchsp80jbglk8c4r7lq7h54v9f4mxmvz6xgf7";
+    };
+  }
+  {
+    goPackagePath = "github.com/lib/pq";
+    fetch = {
+      type = "git";
+      url = "https://github.com/lib/pq";
+      rev = "90697d60dd844d5ef6ff15135d0203f65d2f53b8";
+      sha256 = "0hb4bfsk8g5473yzbf3lzrb373xicakjznkf0v085xgimz991i9r";
+    };
+  }
+  {
+    goPackagePath = "github.com/mailru/easyjson";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mailru/easyjson";
+      rev = "8b799c424f57fa123fc63a99d6383bc6e4c02578";
+      sha256 = "15ba6drfmw98lzw5qjh3ijcxh9iz9rcp3hid169yfd08l06z05w0";
+    };
+  }
+  {
+    goPackagePath = "github.com/nyarlabo/go-crypt";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nyarlabo/go-crypt";
+      rev = "d9a5dc2b789bc330075d4b805d9b7c971f2865a1";
+      sha256 = "0249hbwvhy0xywi9b5k8964km27pvfkr3jvliy3azri6vnyvkkx1";
+    };
+  }
+  {
+    goPackagePath = "github.com/oschwald/maxminddb-golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/oschwald/maxminddb-golang";
+      rev = "c5bec84d1963260297932a1b7a1753c8420717a7";
+      sha256 = "0n8vhinm2x0prbn0vhxw38c24iiaizwk1b76s4srg30gk3dfdd39";
+    };
+  }
+  {
+    goPackagePath = "github.com/sevlyar/go-daemon";
+    fetch = {
+      type = "git";
+      url = "https://github.com/sevlyar/go-daemon";
+      rev = "45a2ba1b7c6710a044163fa109bf08d060bc3afa";
+      sha256 = "1fd8cwljgbxsm3w38pii0n02zg8s53x7j08w784csj3sfzq7rbv4";
+    };
+  }
+  {
+    goPackagePath = "github.com/ulikunitz/xz";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ulikunitz/xz";
+      rev = "0c6b41e72360850ca4f98dc341fd999726ea007f";
+      sha256 = "0a6l7sp67ipxim093qh6fvw8knbxj24l7bj5lykcddi5gwfi78n3";
+    };
+  }
+  {
+    goPackagePath = "github.com/valyala/bytebufferpool";
+    fetch = {
+      type = "git";
+      url = "https://github.com/valyala/bytebufferpool";
+      rev = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7";
+      sha256 = "01lqzjddq6kz9v41nkky7wbgk7f1cw036sa7ldz10d82g5klzl93";
+    };
+  }
+  {
+    goPackagePath = "github.com/valyala/quicktemplate";
+    fetch = {
+      type = "git";
+      url = "https://github.com/valyala/quicktemplate";
+      rev = "a91e0946457b6583004fbfc159339b8171423aed";
+      sha256 = "1z89ang5pkq5qs5b2nwhzyrw0zjlsas539l9kix374fhka49n8yc";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "a3beeb748656e13e54256fd2cde19e058f41f60f";
+      sha256 = "0h0a1v2g3hf0dlfjfiv76vfvvy7r9sdhjyqc2snvh9dczm2k5zki";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "c11f84a56e43e20a78cee75a7c034031ecf57d1f";
+      sha256 = "1fn1wwr94v6ca1zcbsrs5v79s95pajdjqzz9rm9lxkgcvv1rl189";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "5c1cf69b5978e5a34c5f9ba09a83e56acc4b7877";
+      sha256 = "03br8p1sb1ffr02l8hyrgcyib7ms0z06wy3v4r1dj2l6q4ghwzfs";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/gomail.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/gomail.v2";
+      rev = "81ebce5c23dfd25c6c67194b37d3dd3f338c98b1";
+      sha256 = "0zdykrv5s19lnq0g49p6njldy4cpk4g161vyjafiw7f84h8r28mc";
+    };
+  }
+]
diff --git a/pkgs/servers/memcached/default.nix b/pkgs/servers/memcached/default.nix
index 9d110d9c1461..8a4159a55213 100644
--- a/pkgs/servers/memcached/default.nix
+++ b/pkgs/servers/memcached/default.nix
@@ -1,15 +1,20 @@
 {stdenv, fetchurl, cyrus_sasl, libevent}:
 
 stdenv.mkDerivation rec {
-  name = "memcached-1.4.20";
+  version = "1.5.8";
+  name = "memcached-${version}";
 
   src = fetchurl {
     url = "http://memcached.org/files/${name}.tar.gz";
-    sha256 = "0620llasj8xgffk6hk2ml15z0c5i34455wwg60i1a2zdir023l95";
+    sha256 = "1ppnhsqv9047vm0rrmqla56y972f8qqjdb780iz6v922jjcc723k";
   };
 
   buildInputs = [cyrus_sasl libevent];
 
+  hardeningEnable = [ "pie" ];
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-Wno-error";
+
   meta = with stdenv.lib; {
     description = "A distributed memory object caching system";
     repositories.git = https://github.com/memcached/memcached.git;
diff --git a/pkgs/servers/mesos-dns/default.nix b/pkgs/servers/mesos-dns/default.nix
new file mode 100644
index 000000000000..53c87745e67a
--- /dev/null
+++ b/pkgs/servers/mesos-dns/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "mesos-dns-${version}";
+  version = "0.1.2";
+  rev = "v${version}";
+  
+  goPackagePath = "github.com/mesosphere/mesos-dns";
+
+  # Avoid including the benchmarking test helper in the output:
+  subPackages = [ "." ];
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "mesosphere";
+    repo = "mesos-dns";
+    sha256 = "0zs6lcgk43j7jp370qnii7n55cd9pa8gl56r8hy4nagfvlvrcm02";
+  };
+
+  goDeps = ./deps.nix;
+}
diff --git a/pkgs/servers/mesos-dns/deps.nix b/pkgs/servers/mesos-dns/deps.nix
new file mode 100644
index 000000000000..00f0f245f6b3
--- /dev/null
+++ b/pkgs/servers/mesos-dns/deps.nix
@@ -0,0 +1,101 @@
+[
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "62ac18b461605b4be188bbc7300e9aa2bc836cd4";
+      sha256 = "0lwwvbbwbf3yshxkfhn6z20gd45dkvnmw2ms36diiy34krgy402p";
+    };
+  }
+  {
+    goPackagePath = "github.com/miekg/dns";
+    fetch = {
+      type = "git";
+      url = "https://github.com/miekg/dns";
+      rev = "7e024ce8ce18b21b475ac6baf8fa3c42536bf2fa";
+      sha256 = "0hlwb52lnnj3c6papjk9i5w5cjdw6r7c891v4xksnfvk1f9cy9kl";
+    };
+  }
+  {
+    goPackagePath = "github.com/gogo/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gogo/protobuf";
+      rev = "7883e1468d48d969e1c3ce4bcde89b6a7dd4adc4";
+      sha256 = "16ja7lqq96q0pnzgnbwnh0j8qzvqgns1nfk8ndxgkg4sg93bg372";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/glog";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/glog";
+      rev = "fca8c8854093a154ff1eb580aae10276ad6b1b5f";
+      sha256 = "1nr2q0vas0a2f395f4shjxqpas18mjsf8yhgndsav7svngpbbpg8";
+    };
+  }
+  {
+    goPackagePath = "github.com/mesos/mesos-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mesos/mesos-go";
+      rev = "aaa5b2fecf0e2db463f4f996c89617d6766b2969";
+      sha256 = "1pk1fpxksjln6kqvgm1igw3582jgrn14fwa8bdj5cwbpy6skjdvk";
+    };
+  }
+  {
+    goPackagePath = "github.com/pmezard/go-difflib";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pmezard/go-difflib";
+      rev = "d8ed2627bdf02c080bf22230dbb337003b7aba2d";
+      sha256 = "0w1jp4k4zbnrxh3jvh8fgbjgqpf2hg31pbj8fb32kh26px9ldpbs";
+    };
+  }
+  {
+    goPackagePath = "github.com/samuel/go-zookeeper";
+    fetch = {
+      type = "git";
+      url = "https://github.com/samuel/go-zookeeper";
+      rev = "5bb5cfc093ad18a28148c578f8632cfdb4d802e4";
+      sha256 = "1kpx1ymh7rds0b2km291idnyqi0zck74nd8hnk72crgz7wmpqv6z";
+    };
+  }
+  {
+    goPackagePath = "github.com/stretchr/objx";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stretchr/objx";
+      rev = "cbeaeb16a013161a98496fad62933b1d21786672";
+      sha256 = "1xn7iibjik77h6h0jilfvcjkkzaqz45baf44p3rb2i03hbmkqkp1";
+    };
+  }
+  {
+    goPackagePath = "github.com/davecgh/go-spew";
+    fetch = {
+      type = "git";
+      url = "https://github.com/davecgh/go-spew";
+      rev = "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d";
+      sha256 = "15h9kl73rdbzlfmsdxp13jja5gs7sknvqkpq2qizq3qv3nr1x8dk";
+    };
+  }
+  {
+    goPackagePath = "github.com/emicklei/go-restful";
+    fetch = {
+      type = "git";
+      url = "https://github.com/emicklei/go-restful";
+      rev = "892402ba11a2e2fd5e1295dd633481f27365f14d";
+      sha256 = "0gr9f53vayc6501a1kaw4p3h9pgf376cgxsfnr3f2dvp0xacvw8x";
+    };
+  }
+  {
+    goPackagePath = "github.com/stretchr/testify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stretchr/testify";
+      rev = "089c7181b8c728499929ff09b62d3fdd8df8adff";
+      sha256 = "03dzxkxbs298pvfsjz4kdadfaf9jkzsdhshqmg4p12wbyaj09s4p";
+    };
+  }
+]
diff --git a/pkgs/servers/metabase/default.nix b/pkgs/servers/metabase/default.nix
new file mode 100644
index 000000000000..588f1dda50cc
--- /dev/null
+++ b/pkgs/servers/metabase/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, makeWrapper, jre }:
+
+stdenv.mkDerivation rec {
+  name = "metabase-${version}";
+  version = "0.29.3";
+
+  src = fetchurl {
+    url = "http://downloads.metabase.com/v${version}/metabase.jar";
+    sha256 = "18yvjxlgdbg7h7ipj1wlic5m0gv5s2943c72shs44jvic6g42pzv";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  unpackPhase = "true";
+
+  installPhase = ''
+    makeWrapper ${jre}/bin/java $out/bin/metabase --add-flags "-jar $src"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "The easy, open source way for everyone in your company to ask questions and learn from data.";
+    homepage    = https://metabase.com;
+    license     = licenses.agpl3;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ schneefux thoughtpolice ];
+  };
+}
diff --git a/pkgs/servers/meteor/default.nix b/pkgs/servers/meteor/default.nix
index 5e13b4520c9b..132f812bf464 100644
--- a/pkgs/servers/meteor/default.nix
+++ b/pkgs/servers/meteor/default.nix
@@ -2,14 +2,14 @@
 
 let
   bootstrap = fetchurl {
-    url = "https://d3sqy0vbqsdhku.cloudfront.net/packages-bootstrap/1.2.0.1/meteor-bootstrap-os.linux.x86_64.tar.gz";
-    sha256 = "0jc516qyig7f5a8ns4y6d9031f0ww2sd90n837kz6x97nin7655s";
+    url = "https://meteorinstall-4168.kxcdn.com/packages-bootstrap/1.5/meteor-bootstrap-os.linux.x86_64.tar.gz";
+    sha256 = "0cwwqv88h1ji7g4zmfz34xsrxkn640wr11ddjq5c6b9ygcljci3p";
   };
 in
 
 stdenv.mkDerivation rec {
   name = "meteor-${version}";
-  version = "1.2.0.1";
+  version = "1.5";
 
   dontStrip = true;
 
@@ -40,29 +40,29 @@ stdenv.mkDerivation rec {
     popd
     substituteInPlace $out/tools/cli/main.js \
       --replace "@INTERPRETER@" "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --replace "@RPATH@" "${stdenv.cc.cc}/lib:${zlib}/lib" \
+      --replace "@RPATH@" "${lib.makeLibraryPath [ stdenv.cc.cc zlib ]}" \
       --replace "@PATCHELF@" "${patchelf}/bin/patchelf"
 
     # Patch node.
     node=$devBundle/bin/node
     patchelf \
       --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-      --set-rpath "$(patchelf --print-rpath $node):${stdenv.cc.cc}/lib" \
+      --set-rpath "$(patchelf --print-rpath $node):${stdenv.cc.cc.lib}/lib" \
       $node
 
     # Patch mongo.
     for p in $devBundle/mongodb/bin/mongo{,d}; do
       patchelf \
         --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
-        --set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc}/lib:${zlib}/lib" \
+        --set-rpath "$(patchelf --print-rpath $p):${lib.makeLibraryPath [ stdenv.cc.cc zlib ]}" \
         $p
     done
 
     # Patch node dlls.
     for p in $(find $out/packages -name '*.node'); do
       patchelf \
-        --set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc}/lib" \
-        $p
+        --set-rpath "$(patchelf --print-rpath $p):${stdenv.cc.cc.lib}/lib" \
+        $p || true
     done
 
     # Meteor needs an initial package-metadata in $HOME/.meteor,
@@ -85,7 +85,7 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Complete open source platform for building web and mobile apps in pure JavaScript";
-    homepage = "http://www.meteor.com";
+    homepage = http://www.meteor.com;
     license = licenses.mit;
     platforms = [ "x86_64-linux" ];
     maintainers = with maintainers; [ cstrahan ];
diff --git a/pkgs/servers/meteor/main.patch b/pkgs/servers/meteor/main.patch
index b5834bf62922..3282c91abac8 100644
--- a/pkgs/servers/meteor/main.patch
+++ b/pkgs/servers/meteor/main.patch
@@ -2,14 +2,15 @@ diff --git a/tools/cli/main.js b/tools/cli/main.js
 index 84f94bc..4fbda17 100644
 --- a/tools/cli/main.js
 +++ b/tools/cli/main.js
-@@ -484,6 +484,44 @@ var springboard = function (rel, options) {
-     process.exit(ret.wait());
-   }
+@@ -554,6 +554,44 @@
+     }).await());
+   } // Now exec; we're not coming back.
  
 +  // BEGIN HACK
 +  // patch shebang:
 +  var fs = require('fs');
 +  var path = require("path")
++  var Future = require("fibers/future")
 +  var srcOld = fs.readFileSync(executable, 'utf8');
 +  srcNew = srcOld.replace(/^#!\/bin\/bash/, '#!/bin/sh');
 +  if (srcOld !== srcNew) {
@@ -43,7 +44,13 @@ index 84f94bc..4fbda17 100644
 +  patchelf("mongodb", "bin", "mongo");
 +  patchelf("mongodb", "bin", "mongod");
 +  // END HACK
-+
-   // Now exec; we're not coming back.
+
    require('kexec')(executable, newArgv);
-   throw Error('exec failed?');
+
+@@ -1485,4 +1523,4 @@
+
+   process.exit(ret);
+ }).run();
+-//# sourceMappingURL=main.js.map
+\ No newline at end of file
++//# sourceMappingURL=main.js.map
diff --git a/pkgs/servers/minio/default.nix b/pkgs/servers/minio/default.nix
new file mode 100644
index 000000000000..7f590461d9de
--- /dev/null
+++ b/pkgs/servers/minio/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "minio-${version}";
+
+  version = "2018-05-11T00-29-24Z";
+
+  src = fetchFromGitHub {
+    owner = "minio";
+    repo = "minio";
+    rev = "RELEASE.${version}";
+    sha256 = "01jw1djfs0jbhsx9pmx3kj31mfhrw45lr1i4lwkmh8k7fxn8w13x";
+  };
+
+  goPackagePath = "github.com/minio/minio";
+
+  buildFlagsArray = [''-ldflags=
+    -X github.com/minio/minio/cmd.Version=${version}
+  ''];
+
+  meta = with stdenv.lib; {
+    homepage = https://www.minio.io/;
+    description = "An S3-compatible object storage server";
+    maintainers = with maintainers; [ eelco bachp ];
+    platforms = platforms.unix;
+    license = licenses.asl20;
+  };
+}
diff --git a/pkgs/servers/mirrorbits/default.nix b/pkgs/servers/mirrorbits/default.nix
new file mode 100644
index 000000000000..98ac1534cf8a
--- /dev/null
+++ b/pkgs/servers/mirrorbits/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub, fetchpatch
+, pkgconfig, zlib, geoip }:
+
+buildGoPackage rec {
+  name = "mirrorbits-${version}";
+  version = "0.4";
+  rev = "v${version}";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "etix";
+    repo = "mirrorbits";
+    sha256 = "11f9wczajba147qk5j73pxjrvlxkgr598sjvgjn2b8nxm49g2pan";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/etix/mirrorbits/commit/03a4e02214bdb7bb60240ddf25b887ccac5fb118.patch";
+      sha256 = "08332cfxmp2nsfdj2ymg3lxkav8h44f6cf2h6g9jkn03mkliblm5";
+    })
+  ];
+
+  postPatch = ''
+    rm -rf testing
+  '';
+
+  goPackagePath = "github.com/etix/mirrorbits";
+  goDeps = ./deps.nix;
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ zlib geoip ];
+
+  meta = {
+    description = "geographical download redirector for distributing files efficiently across a set of mirrors";
+    homepage = "https://github.com/etix/mirrorbits";
+    longDescription = ''
+      Mirrorbits is a geographical download redirector written in Go for
+      distributing files efficiently across a set of mirrors. It offers
+      a simple and economic way to create a Content Delivery Network
+      layer using a pure software stack. It is primarily designed for
+      the distribution of large-scale Open-Source projects with a lot
+      of traffic.
+    '';
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ fpletz ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/pkgs/servers/mirrorbits/deps.nix b/pkgs/servers/mirrorbits/deps.nix
new file mode 100644
index 000000000000..373654126614
--- /dev/null
+++ b/pkgs/servers/mirrorbits/deps.nix
@@ -0,0 +1,66 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/etix/geoip";
+    fetch = {
+      type = "git";
+      url = "https://github.com/etix/geoip";
+      rev = "db8457352061099b2a1840c712b3223900216588";
+      sha256 = "1768237bngcjgw0s8wba0f4nw1xahg28cq2nd6vrbmhavd1ppim9";
+    };
+  }
+  {
+    goPackagePath = "github.com/etix/goftp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/etix/goftp";
+      rev = "0c13163a1028e83f0f1cce113dddd3900e935bc7";
+      sha256 = "15kwk57yk63j28d1lwrykc9nr7ickqgk2fpw4g0b0404b95l101k";
+    };
+  }
+  {
+    goPackagePath = "github.com/garyburd/redigo";
+    fetch = {
+      type = "git";
+      url = "https://github.com/garyburd/redigo";
+      rev = "70e1b1943d4fc9c56791abaa6f4d1e727b9ab925";
+      sha256 = "1nw22r0vagmayjg51rz55yi9ppkd60ya0nzmp113mcz25vhxa0d0";
+    };
+  }
+  {
+    goPackagePath = "github.com/op/go-logging";
+    fetch = {
+      type = "git";
+      url = "https://github.com/op/go-logging";
+      rev = "970db520ece77730c7e4724c61121037378659d9";
+      sha256 = "1cpna2x5l071z1vrnk7zipdkka8dzwsjyx7m79xk0lr08rip0kcj";
+    };
+  }
+  {
+    goPackagePath = "github.com/youtube/vitess";
+    fetch = {
+      type = "git";
+      url = "https://github.com/youtube/vitess";
+      rev = "6cf14dbf97f28eebd37dc2bc36374852946336a8";
+      sha256 = "1g76q84wipyprn05brpjxf8xri87293r7nyf647crjy5d9k950lz";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/tylerb/graceful.v1";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/tylerb/graceful.v1";
+      rev = "4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb";
+      sha256 = "1qspbrzr3h6c89v75c99avn7iizkfnjh901wp650vyy0j3p6ydnd";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/yaml.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/yaml.v2";
+      rev = "eb3733d160e74a9c7e442f435eb3bea458e1d19f";
+      sha256 = "1srhvcaa9db3a6xj29mkjr5kg33y71pclrlx4vcwz5m1lgb5c7q6";
+    };
+  }
+]
diff --git a/pkgs/servers/misc/airsonic/default.nix b/pkgs/servers/misc/airsonic/default.nix
new file mode 100644
index 000000000000..7fc041d81984
--- /dev/null
+++ b/pkgs/servers/misc/airsonic/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "airsonic-${version}";
+  version = "10.1.1";
+
+  src = fetchurl {
+    url = "https://github.com/airsonic/airsonic/releases/download/v${version}/airsonic.war";
+    sha256 = "0acj6la88lnbfdp0nilvsll48zfig7sgibgwfjjckialppyg4ir6";
+  };
+
+  buildCommand = ''
+    mkdir -p "$out/webapps"
+    cp "$src" "$out/webapps/airsonic.war"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Personal media streamer";
+    homepage = https://airsonic.github.io;
+    license = stdenv.lib.licenses.gpl3;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ disassembler ];
+  };
+}
diff --git a/pkgs/servers/misc/client-ip-echo/client-ip-echo.nix b/pkgs/servers/misc/client-ip-echo/client-ip-echo.nix
new file mode 100644
index 000000000000..92bbc309ed3d
--- /dev/null
+++ b/pkgs/servers/misc/client-ip-echo/client-ip-echo.nix
@@ -0,0 +1,17 @@
+{ mkDerivation, fetchFromGitHub, base, bytestring, network, stdenv }:
+mkDerivation {
+  pname = "client-ip-echo";
+  version = "0.1.0.1";
+  src = fetchFromGitHub {
+    owner = "jerith666";
+    repo = "client-ip-echo";
+    rev = "f6e3e115a1e61a387cf79956ead36d7ac25a2901";
+    sha256 = "0irxcaiwxxn4ggd2dbya1mvpnyfanx0x06whp8ccrha141cafwqp";
+  };
+  isLibrary = false;
+  isExecutable = true;
+  executableHaskellDepends = [ base bytestring network ];
+  description = "accepts TCP connections and echoes the client's IP address back to it";
+  license = stdenv.lib.licenses.lgpl3;
+  broken = true; # 2018-04-10
+}
diff --git a/pkgs/servers/misc/client-ip-echo/default.nix b/pkgs/servers/misc/client-ip-echo/default.nix
new file mode 100644
index 000000000000..5bc0ea45e2b6
--- /dev/null
+++ b/pkgs/servers/misc/client-ip-echo/default.nix
@@ -0,0 +1,2 @@
+{ pkgs }:
+pkgs.haskellPackages.callPackage ./client-ip-echo.nix { }
diff --git a/pkgs/servers/misc/subsonic/default.nix b/pkgs/servers/misc/subsonic/default.nix
index 4e7ed6712da9..f546b0b075e5 100644
--- a/pkgs/servers/misc/subsonic/default.nix
+++ b/pkgs/servers/misc/subsonic/default.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, jre }:
 
-let version = "5.2.1"; in
+let version = "6.1.3"; in
 
 stdenv.mkDerivation rec {
   name = "subsonic-${version}";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "mirror://sourceforge/subsonic/subsonic-${version}-standalone.tar.gz";
-    sha256 = "523fa8357c961c1ae742a15f0ceaabdd41fcba9137c29d244957922af90ee791";
+    sha256 = "1v21gfymaqcx6n6d88hvha60q9hgj5z1wsac5gcwq7cjah1893jx";
   };
 
   inherit jre;
@@ -29,6 +29,7 @@ stdenv.mkDerivation rec {
     description = "Personal media streamer";
     license = stdenv.lib.licenses.gpl3;
     maintainers = with stdenv.lib.maintainers; [ telotortium ];
+    platforms = with stdenv.lib.platforms; unix;
   };
 
   phases = ["unpackPhase" "installPhase"];
diff --git a/pkgs/servers/misc/taskserver/default.nix b/pkgs/servers/misc/taskserver/default.nix
index 3d34bb8e11f2..466c3873c600 100644
--- a/pkgs/servers/misc/taskserver/default.nix
+++ b/pkgs/servers/misc/taskserver/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, cmake, libuuid, gnutls }:
+{ stdenv, fetchurl, cmake, libuuid, gnutls, makeWrapper }:
 
 stdenv.mkDerivation rec {
   name = "taskserver-${version}";
@@ -11,6 +11,26 @@ stdenv.mkDerivation rec {
     sha256 = "1d110q9vw8g5syzihxymik7hd27z1592wkpz55kya6lphzk8i13v";
   };
 
+  patchPhase = ''
+    pkipath=$out/share/taskd/pki
+    mkdir -p $pkipath
+    cp -r pki/* $pkipath
+    echo "patching paths in pki/generate"
+    sed -i "s#^\.#$pkipath#" $pkipath/generate
+    for f in $pkipath/generate* ;do
+      i=$(basename $f)
+      echo patching $i
+      sed -i \
+          -e 's/which/type -p/g' \
+          -e 's#^\. ./vars#if test -e ./vars;then . ./vars; else echo "cannot find ./vars - copy the template from '$pkipath'/vars into the working directory";exit 1; fi#' $f
+
+      echo wrapping $i
+      makeWrapper  $pkipath/$i $out/bin/taskd-pki-$i \
+        --prefix PATH : ${stdenv.lib.makeBinPath [ gnutls ]}
+    done
+  '';
+
+  buildInputs = [ makeWrapper ];
   nativeBuildInputs = [ cmake libuuid gnutls ];
 
   meta = {
@@ -18,6 +38,6 @@ stdenv.mkDerivation rec {
     homepage = http://taskwarrior.org;
     license = stdenv.lib.licenses.mit;
     platforms = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ matthiasbeyer ];
+    maintainers = with stdenv.lib.maintainers; [ makefu ];
   };
 }
diff --git a/pkgs/servers/monitoring/bosun/default.nix b/pkgs/servers/monitoring/bosun/default.nix
new file mode 100644
index 000000000000..905244833602
--- /dev/null
+++ b/pkgs/servers/monitoring/bosun/default.nix
@@ -0,0 +1,24 @@
+{ lib, fetchFromGitHub, buildGoPackage }:
+
+buildGoPackage rec {
+  name = "bosun-${version}";
+  version = "0.5.0";
+
+  src = fetchFromGitHub {
+    owner = "bosun-monitor";
+    repo = "bosun";
+    rev = version;
+    sha256 = "1qj97wiqj6awivvac1n00k0x8wdv4ambzdj4502nmmnr5rdbqq88";
+  };
+
+  subPackages = [ "cmd/bosun" "cmd/scollector" ];
+  goPackagePath = "bosun.org";
+
+  meta = with lib; {
+    description = "Time Series Alerting Framework";
+    license = licenses.mit;
+    homepage = https://bosun.org;
+    maintainers = with maintainers; [ offline ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/monitoring/cadvisor/default.nix b/pkgs/servers/monitoring/cadvisor/default.nix
index c0126fda5723..0480d056c592 100644
--- a/pkgs/servers/monitoring/cadvisor/default.nix
+++ b/pkgs/servers/monitoring/cadvisor/default.nix
@@ -2,16 +2,16 @@
 
 stdenv.mkDerivation rec {
   name = "cadvisor-${version}";
-  version = "0.10.1";
+  version = "0.29.1";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "cadvisor";
-    rev = "${version}";
-    sha256 = "0k0qfhw755k3ripsfkhml0ixaglhy64hdzxrjvlmbgc50s3j37vh";
+    rev = "v${version}";
+    sha256 = "132mpcp35cymm2zqig0yrvhnvgn72k7cmn6gla0v7r0yxfl879m3";
   };
 
-  buildInputs = [ go ];
+  nativeBuildInputs = [ go ];
 
   buildPhase = ''
     mkdir -p Godeps/_workspace/src/github.com/google/
@@ -29,6 +29,6 @@ stdenv.mkDerivation rec {
     homepage = https://github.com/google/cadvisor;
     license = licenses.asl20;
     maintainers = with maintainers; [ offline ];
-    platforms = platforms.unix;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/servers/monitoring/consul-alerts/default.nix b/pkgs/servers/monitoring/consul-alerts/default.nix
new file mode 100644
index 000000000000..ad840dfd607f
--- /dev/null
+++ b/pkgs/servers/monitoring/consul-alerts/default.nix
@@ -0,0 +1,16 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "consul-alerts-${version}";
+  version = "0.3.3";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/AcalephStorage/consul-alerts";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "AcalephStorage";
+    repo = "consul-alerts";
+    sha256 = "1w0mb20w1yazyh84sa30bsw271c5nm7lsx2qg0g3gf6mxdb63lpq";
+  };
+}
diff --git a/pkgs/servers/monitoring/facette/default.nix b/pkgs/servers/monitoring/facette/default.nix
new file mode 100644
index 000000000000..3858720bed5c
--- /dev/null
+++ b/pkgs/servers/monitoring/facette/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub
+, go, pkgconfig, nodejs, nodePackages, pandoc, rrdtool }:
+
+stdenv.mkDerivation rec {
+  name = "facette-${version}";
+  version = "0.4.0";
+  src = fetchFromGitHub {
+    owner = "facette";
+    repo = "facette";
+    rev = "${version}";
+    sha256 = "1m7krq439qlf7b4l4bfjw0xfvjgj67w59mh8rf7c398rky04p257";
+  };
+  nativeBuildInputs = [ go pkgconfig nodejs nodePackages.npm pandoc ];
+  buildInputs = [ rrdtool ];
+  preBuild = ''
+    export HOME="$NIX_BUILD_ROOT" # npm needs a writable home
+  '';
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  meta = with stdenv.lib; {
+    description = "Time series data visualization software";
+    longDescription = ''
+      Facette is a web application to display time series data from various
+      sources — such as collectd, Graphite, InfluxDB or KairosDB — on graphs.
+    '';
+    homepage = https://facette.io/;
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ fgaz ];
+  };
+}
diff --git a/pkgs/servers/monitoring/fusion-inventory/default.nix b/pkgs/servers/monitoring/fusion-inventory/default.nix
new file mode 100644
index 000000000000..34b4e87bf65c
--- /dev/null
+++ b/pkgs/servers/monitoring/fusion-inventory/default.nix
@@ -0,0 +1,93 @@
+{ stdenv, lib, fetchurl, buildPerlPackage, perlPackages, gnused, nix, dmidecode, pciutils, usbutils, iproute, nettools
+, fetchFromGitHub, makeWrapper
+}:
+
+buildPerlPackage rec {
+  name = "FusionInventory-Agent-${version}";
+  version = "2.3.21";
+
+  src = fetchFromGitHub {
+    owner = "fusioninventory";
+    repo = "fusioninventory-agent";
+    rev = version;
+    sha256 = "034clffcn0agx85macjgml4lyhvvck7idn94pqd2c77pk6crvw2y";
+  };
+
+  patches = [
+    ./remove_software_test.patch
+    # support for os-release file
+    (fetchurl {
+      url = https://github.com/fusioninventory/fusioninventory-agent/pull/396.diff;
+      sha256 = "0bxrjmff80ab01n23xggci32ajsah6zvcmz5x4hj6ayy6dzwi6jb";
+    })
+    # support for Nix software inventory
+    (fetchurl {
+      url = https://github.com/fusioninventory/fusioninventory-agent/pull/397.diff;
+      sha256 = "0pyf7mp0zsb3zcqb6yysr1zfp54p9ciwjn1pzayw6s9flmcgrmbw";
+    })
+    ];
+
+  postPatch = ''
+
+    patchShebangs bin
+
+    substituteInPlace "lib/FusionInventory/Agent/Tools/Linux.pm" \
+      --replace /sbin/ip ${iproute}/sbin/ip
+    substituteInPlace "lib/FusionInventory/Agent/Task/Inventory/Linux/Networks.pm" \
+      --replace /sbin/ip ${iproute}/sbin/ip
+  '';
+
+  buildTools = [];
+  buildInputs = [ makeWrapper ] ++ (with perlPackages; [
+    CGI
+    DataStructureUtil
+    FileCopyRecursive
+    HTTPProxy
+    HTTPServerSimple
+    HTTPServerSimpleAuthen
+    IOCapture
+    IOSocketSSL
+    IPCRun
+    JSON
+    LWPProtocolhttps
+    ModuleInstall
+    NetSNMP
+    TestCompile
+    TestDeep
+    TestException
+    TestMockModule
+    TestMockObject
+    TestNoWarnings
+  ]);
+  propagatedBuildInputs = with perlPackages; [
+    FileWhich
+    LWP
+    NetIP
+    TextTemplate
+    UNIVERSALrequire
+    XMLTreePP
+  ];
+
+  installPhase = ''
+    mkdir -p $out
+
+    cp -r bin $out
+    cp -r lib $out
+
+    for cur in $out/bin/*; do
+      if [ -x "$cur" ]; then
+        sed -e "s|./lib|$out/lib|" -i "$cur"
+        wrapProgram "$cur" --prefix PATH : ${lib.makeBinPath [nix dmidecode pciutils usbutils nettools iproute]}
+      fi
+    done
+  '';
+
+  outputs = [ "out" ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.fusioninventory.org;
+    description = "FusionInventory unified Agent for UNIX, Linux, Windows and MacOSX";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ maintainers.phile314 ];
+  };
+}
diff --git a/pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch b/pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch
new file mode 100644
index 000000000000..b360f418aa0b
--- /dev/null
+++ b/pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch
@@ -0,0 +1,67 @@
+diff --git a/t/agent/snmp/live.t b/t/agent/snmp/live.t
+index 8ee7ff02c..bd5551ab3 100755
+--- a/t/agent/snmp/live.t
++++ b/t/agent/snmp/live.t
+@@ -11,7 +11,7 @@ use Test::More;
+ use FusionInventory::Agent::XML::Response;
+ use FusionInventory::Agent::SNMP::Live;
+ 
+-plan tests => 12;
++plan tests => 11;
+ 
+ my $snmp;
+ throws_ok {
+@@ -52,15 +52,6 @@ throws_ok {
+ } qr/^Unable to resolve the UDP\/IPv4 address "none"/,
+ 'instanciation: unresolvable host';
+ 
+-throws_ok {
+-    $snmp = FusionInventory::Agent::SNMP::Live->new(
+-        version   => 1,
+-        community => 'public',
+-        hostname  => '1.1.1.1'
+-    );
+-} qr/no response from host 1.1.1.1/,
+-'instanciation: unresponding host';
+-
+ SKIP: {
+ skip 'live SNMP test disabled', 6 unless $ENV{TEST_LIVE_SNMP};
+ 
+diff --git a/t/apps/agent.t b/t/apps/agent.t
+index c0f6fc52f..c83837d70 100755
+--- a/t/apps/agent.t
++++ b/t/apps/agent.t
+@@ -12,7 +12,7 @@ use XML::TreePP;
+ use FusionInventory::Agent::Tools;
+ use FusionInventory::Test::Utils;
+ 
+-plan tests => 34;
++plan tests => 33;
+ 
+ my ($content, $out, $err, $rc);
+ 
+@@ -71,11 +71,6 @@ subtest "first inventory execution and content" => sub {
+     check_content_ok($out);
+ };
+ 
+-ok(
+-    exists $content->{REQUEST}->{CONTENT}->{SOFTWARES},
+-    'inventory has software'
+-);
+-
+ ok(
+     exists $content->{REQUEST}->{CONTENT}->{ENVS},
+     'inventory has environment variables'
+diff --git a/t/tasks/inventory/linux/softwares.t b/t/tasks/inventory/linux/softwares.t
+index 72a0e578c..13944f34f 100755
+--- a/t/tasks/inventory/linux/softwares.t
++++ b/t/tasks/inventory/linux/softwares.t
+@@ -89,7 +89,7 @@ my $rpm_packages = [
+         PUBLISHER   => 'Mageia.Org',
+         NAME        => 'xfsprogs',
+         COMMENTS    => 'Utilities for managing the XFS filesystem',
+-        INSTALLDATE => '25/03/2012',
++        INSTALLDATE => '24/03/2012',
+         FILESIZE    => '3628382',
+         FROM        => 'rpm',
+         ARCH        => 'x86_64',
diff --git a/pkgs/servers/monitoring/grafana/default.nix b/pkgs/servers/monitoring/grafana/default.nix
new file mode 100644
index 000000000000..646401ce02f9
--- /dev/null
+++ b/pkgs/servers/monitoring/grafana/default.nix
@@ -0,0 +1,35 @@
+{ lib, buildGoPackage, fetchurl, fetchFromGitHub, phantomjs2 }:
+
+buildGoPackage rec {
+  version = "5.1.3";
+  name = "grafana-${version}";
+  goPackagePath = "github.com/grafana/grafana";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner = "grafana";
+    repo = "grafana";
+    sha256 = "09q4xrh4j02b8nrkskndahs039rhmcs8hrcgvnnpg36qqyvs1x0g";
+  };
+
+  srcStatic = fetchurl {
+    url = "https://grafana-releases.s3.amazonaws.com/release/grafana-${version}.linux-x64.tar.gz";
+    sha256 = "131dxpjnzhsjh6c0fp48jhxf5piy6wh287pfm2s7pm4ywq9m0q46";
+  };
+
+  preBuild = "export GOPATH=$GOPATH:$NIX_BUILD_TOP/go/src/${goPackagePath}/Godeps/_workspace";
+  postInstall = ''
+    tar -xvf $srcStatic
+    mkdir -p $bin/share/grafana
+    mv grafana-*/{public,conf,tools} $bin/share/grafana/
+    ln -sf ${phantomjs2}/bin/phantomjs $bin/share/grafana/tools/phantomjs/phantomjs
+  '';
+
+  meta = with lib; {
+    description = "Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB";
+    license = licenses.asl20;
+    homepage = https://grafana.org/;
+    maintainers = with maintainers; [ offline fpletz willibutz ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/monitoring/heapster/default.nix b/pkgs/servers/monitoring/heapster/default.nix
new file mode 100644
index 000000000000..39c048576388
--- /dev/null
+++ b/pkgs/servers/monitoring/heapster/default.nix
@@ -0,0 +1,27 @@
+{ lib, buildGoPackage, fetchFromGitHub, docker }:
+
+buildGoPackage rec {
+  rev = "3057a2c07061c8d9ffaf77e5442ffd7512ac0133";
+  name = "heapster-${lib.strings.substring 0 7 rev}";
+  goPackagePath = "k8s.io/heapster";
+  subPackages = [ "./" ];
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "kubernetes";
+    repo = "heapster";
+    sha256 = "1vg83207y7yigydnnhlvzs3s94vx02i56lqgs6a96c6i3mr3ydpb";
+  };
+
+  preBuild = ''
+    export GOPATH=$GOPATH:$NIX_BUILD_TOP/go/src/${goPackagePath}/Godeps/_workspace
+  '';
+
+  meta = with lib; {
+    description = "Compute Resource Usage Analysis and Monitoring of Container Clusters";
+    license = licenses.asl20;
+    homepage = https://github.com/kubernetes/heapster;
+    maintainers = with maintainers; [ offline ];
+    platforms = docker.meta.platforms;
+  };
+}
diff --git a/pkgs/servers/monitoring/kapacitor/default.nix b/pkgs/servers/monitoring/kapacitor/default.nix
new file mode 100644
index 000000000000..409801e8b7dc
--- /dev/null
+++ b/pkgs/servers/monitoring/kapacitor/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, lib, fetchFromGitHub, buildGoPackage }:
+
+buildGoPackage rec {
+  name = "kapacitor-${version}";
+  version = "1.4.0";
+
+  goPackagePath = "github.com/influxdata/kapacitor";
+
+  src = fetchFromGitHub {
+    owner = "influxdata";
+    repo = "kapacitor";
+    rev = "v${version}";
+    sha256 = "1qanf7qljzqqkyw2cdazg0ll13q8a3fs3sqydcgfbgpdmf707sj2";
+  };
+
+  meta = with lib; {
+    description = "Open source framework for processing, monitoring, and alerting on time series data";
+    license = licenses.mit;
+    homepage = https://influxdata.com/time-series-platform/kapacitor/;
+    maintainers = with maintainers; [offline];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/pkgs/servers/monitoring/lcdproc/default.nix b/pkgs/servers/monitoring/lcdproc/default.nix
new file mode 100644
index 000000000000..859849f7b2c7
--- /dev/null
+++ b/pkgs/servers/monitoring/lcdproc/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, makeWrapper, pkgconfig
+, doxygen, freetype, libX11, libftdi, libftdi1, libusb, libusb1, ncurses, perl }:
+
+stdenv.mkDerivation rec {
+  name = "lcdproc-${version}";
+  version = "0.5.9";
+
+  src = fetchFromGitHub {
+    owner  = "lcdproc";
+    repo   = "lcdproc";
+    rev    = "v${version}";
+    sha256 = "1r885zv1gsh88j43x6fvzbdgfkh712a227d369h4fdcbnnfd0kpm";
+  };
+
+  patches = [
+    ./hardcode_mtab.patch
+  ];
+
+  configureFlags = [
+    "--enable-lcdproc-menus"
+    "--enable-drivers=all"
+    "--with-pidfile-dir=/run"
+  ];
+
+  buildInputs = [ freetype libX11 libftdi libusb libusb1 ncurses ];
+  nativeBuildInputs = [ autoreconfHook doxygen makeWrapper pkgconfig ];
+
+  # In 0.5.9: gcc: error: libbignum.a: No such file or directory
+  enableParallelBuilding = false;
+
+  postFixup = ''
+    for f in $out/bin/*.pl ; do
+      substituteInPlace $f \
+        --replace /usr/bin/perl ${stdenv.lib.getBin perl}/bin/perl
+    done
+
+    # NixOS will not use this file anyway but at least we can now execute LCDd
+    substituteInPlace $out/etc/LCDd.conf \
+      --replace server/drivers/ $out/lib/lcdproc/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Client/server suite for controlling a wide variety of LCD devices";
+    homepage    = http://lcdproc.org/;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/lcdproc/hardcode_mtab.patch b/pkgs/servers/monitoring/lcdproc/hardcode_mtab.patch
new file mode 100644
index 000000000000..33c4b8e83b2d
--- /dev/null
+++ b/pkgs/servers/monitoring/lcdproc/hardcode_mtab.patch
@@ -0,0 +1,17 @@
+diff --git a/clients/lcdproc/machine_Linux.c b/clients/lcdproc/machine_Linux.c
+index 7bb7266..a629674 100644
+--- a/clients/lcdproc/machine_Linux.c
++++ b/clients/lcdproc/machine_Linux.c
+@@ -259,11 +259,7 @@ machine_get_fs(mounts_type fs[], int *cnt)
+	char line[256];
+	int x = 0, err;
+
+-#ifdef MTAB_FILE
+-	mtab_fd = fopen(MTAB_FILE, "r");
+-#else
+-#error "Can't find your mounted filesystem table file."
+-#endif
++	mtab_fd = fopen("/etc/mtab", "r");
+
+	/* Get rid of old, unmounted filesystems... */
+	memset(fs, 0, sizeof(mounts_type) * 256);
diff --git a/pkgs/servers/monitoring/longview/default.nix b/pkgs/servers/monitoring/longview/default.nix
new file mode 100644
index 000000000000..dcc6f6f16b7f
--- /dev/null
+++ b/pkgs/servers/monitoring/longview/default.nix
@@ -0,0 +1,68 @@
+{stdenv, fetchFromGitHub, perl, perlPackages, makeWrapper, glibc }:
+
+stdenv.mkDerivation rec {
+  version = "1.1.5";
+  name = "longview-${version}";
+
+  src = fetchFromGitHub {
+    owner = "linode";
+    repo = "longview";
+    rev = "v${version}";
+    sha256 = "1i9lli8iw8sb1bd633i82fzhx5gz85ma9d1hra41pkv2p3h823pa";
+  };
+
+  patches = [
+    # log to systemd journal
+    ./log-stdout.patch
+  ];
+
+  # Read all configuration from /run/longview
+  postPatch = ''
+    substituteInPlace Linode/Longview/Util.pm \
+        --replace /var/run/longview.pid /run/longview/longview.pid \
+        --replace /etc/linode /run/longview
+    substituteInPlace Linode/Longview.pl \
+        --replace /etc/linode /run/longview
+  '';
+
+  buildInputs = [ perl makeWrapper glibc ]
+    ++ (with perlPackages; [
+      LWPUserAgent
+      LWPProtocolHttps
+      MozillaCA
+      CryptSSLeay
+      IOSocketInet6
+      LinuxDistribution
+      JSONPP
+      JSON
+      LogLogLite
+      TryTiny
+      DBI
+      DBDmysql
+    ]);
+
+  dontBuild = true;
+
+  installPhase = ''
+    mkdir -p $out/bin $out/usr
+    mv Linode $out
+    ln -s ../Linode/Longview.pl $out/bin/longview
+    for h in syscall.h sys/syscall.h asm/unistd.h asm/unistd_32.h asm/unistd_64.h bits/wordsize.h bits/syscall.h; do
+        ${perl}/bin/h2ph -d $out ${glibc.dev}/include/$h
+        mkdir -p $out/usr/include/$(dirname $h)
+        mv $out${glibc.dev}/include/''${h%.h}.ph $out/usr/include/$(dirname $h)
+    done
+    wrapProgram $out/Linode/Longview.pl --prefix PATH : ${perl}/bin:$out/bin \
+     --suffix PERL5LIB : $out/Linode --suffix PERL5LIB : $PERL5LIB \
+     --suffix PERL5LIB : $out --suffix INC : $out
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.linode.com/longview;
+    description = "Longview collects all of your system-level metrics and sends them to Linode";
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.rvl ];
+    inherit version;
+    platforms = [ "x86_64-linux" "i686-linux" ];
+  };
+}
diff --git a/pkgs/servers/monitoring/longview/log-stdout.patch b/pkgs/servers/monitoring/longview/log-stdout.patch
new file mode 100644
index 000000000000..3e009254bcad
--- /dev/null
+++ b/pkgs/servers/monitoring/longview/log-stdout.patch
@@ -0,0 +1,38 @@
+diff -ru longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Logger.pm longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Logger.pm
+--- longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Logger.pm	2015-10-28 17:15:32.816515318 +0000
++++ longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Logger.pm	2015-10-28 18:00:50.760332026 +0000
+@@ -26,9 +26,7 @@
+         my ( $self, $message ) = @_;
+ 
+         my $ts = strftime( '%m/%d %T', localtime );
+-        $self->{logger}->write(
+-            sprintf( '%s %s Longview[%i] - %s', $ts, uc($level), $$, $message ),
+-            $levels->{$level} );
++        printf( "%s %s Longview[%i] - %s\n", $ts, uc($level), $$, $message );
+         die "$message" if $level eq 'logdie';
+     };
+ }
+@@ -37,12 +35,6 @@
+     my ( $class, $level ) = @_;
+     my $self = {};
+ 
+-    mkpath($LOGDIR) unless (-d $LOGDIR);
+-    $self->{logger}
+-        = Log::LogLite->new( $LOGDIR . 'longview.log', $level )
+-        or die "Couldn't create logger object: $!";
+-    $self->{logger}->template("<message>\n");
+-
+     return bless $self, $class;
+ }
+ 
+diff -ru longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Util.pm longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Util.pm
+--- longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Util.pm	2015-10-28 17:15:32.816515318 +0000
++++ longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Util.pm	2015-10-28 19:20:30.894314658 +0000
+@@ -225,7 +225,6 @@
+  	#<<<   perltidy ignore
+  	chdir '/'                      or $logger->logdie("Can't chdir to /: $!");
+  	open STDIN, '<', '/dev/null'   or $logger->logdie("Can't read /dev/null: $!");
+- 	open STDOUT, '>>', '/dev/null' or $logger->logdie("Can't write to /dev/null: $!");
+  	open STDERR, '>>', '/dev/null' or $logger->logdie("Can't write to /dev/null: $!");
+ 	tie *STDERR, "Linode::Longview::STDERRLogger";
+  	defined( my $pid = fork )      or $logger->logdie("Can't fork: $!");
diff --git a/pkgs/servers/monitoring/mtail/default.nix b/pkgs/servers/monitoring/mtail/default.nix
new file mode 100644
index 000000000000..5044aef2bb53
--- /dev/null
+++ b/pkgs/servers/monitoring/mtail/default.nix
@@ -0,0 +1,26 @@
+{ lib, fetchFromGitHub, gotools, buildGoPackage }:
+
+buildGoPackage rec {
+  name = "mtail-${version}";
+  version = "3.0.0-rc4";
+  goPackagePath = "github.com/google/mtail";
+
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "mtail";
+    rev = "v${version}";
+    sha256 = "1n7pqvid48ayn15qfpgpbsx0iqg24x08wphzpc08mlfw47gq7jg3";
+  };
+
+  buildInputs = [ gotools ];
+  goDeps = ./deps.nix;
+  patches = [ ./fix-gopath.patch ];
+  preBuild = "go generate -x ./go/src/github.com/google/mtail/vm/";
+
+
+  meta = with lib; {
+    license = licenses.asl20;
+    homepage = "https://github.com/google/mtail";
+    description = "Tool for extracting metrics from application logs";
+  };
+}
diff --git a/pkgs/servers/monitoring/mtail/deps.nix b/pkgs/servers/monitoring/mtail/deps.nix
new file mode 100644
index 000000000000..6de3c8b6e139
--- /dev/null
+++ b/pkgs/servers/monitoring/mtail/deps.nix
@@ -0,0 +1,56 @@
+[
+  rec {
+    goPackagePath = "github.com/golang/glog";
+    fetch = {
+      type = "git";
+      url = "https://${goPackagePath}.git";
+      rev = "23def4e6c14b4da8ac2ed8007337bc5eb5007998";
+      sha256 = "0jb2834rw5sykfr937fxi8hxi2zy80sj2bdn9b3jb4b26ksqng30";
+    };
+  }
+  rec {
+    goPackagePath = "github.com/spf13/afero";
+    fetch = {
+      type = "git";
+      url = "https://${goPackagePath}.git";
+      rev = "5660eeed305fe5f69c8fc6cf899132a459a97064";
+      sha256 = "0rpwvjp9xfmy2yvbmy810qamjhimr56zydvx7hb1gjn3b7jp4rhd";
+    };
+  }
+  rec {
+    goPackagePath = "github.com/fsnotify/fsnotify";
+    fetch = {
+      type = "git";
+      url = "https://${goPackagePath}.git";
+      rev = "v1.4.2";
+      sha256 = "06wfg1mmzjj04z7d0q1x2fai9k6hm957brngsaf02fa9a3qqanv3";
+    };
+  }
+  rec {
+    goPackagePath = "github.com/pkg/errors";
+    fetch = {
+      type = "git";
+      url = "https://${goPackagePath}.git";
+      rev = "v0.8.0";
+      sha256 = "001i6n71ghp2l6kdl3qq1v2vmghcz3kicv9a5wgcihrzigm75pp5";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "95c6576299259db960f6c5b9b69ea52422860fce";
+      sha256 = "1fhq8bianb9a1iccpr92mi2hix9zvm10n0f7syx6vfbxdw32i316";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "3ba1a4dc141f5236b19ccbf2f67cb63d1a688d46";
+      sha256 = "07sbakmman41p5hmdbf4y2wak0gh7k1z88m0zb72acsypp4179h1";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/mtail/fix-gopath.patch b/pkgs/servers/monitoring/mtail/fix-gopath.patch
new file mode 100644
index 000000000000..9421d194a9e5
--- /dev/null
+++ b/pkgs/servers/monitoring/mtail/fix-gopath.patch
@@ -0,0 +1,13 @@
+diff --git a/vm/compiler.go b/vm/compiler.go
+index c55266b..a46417c 100644
+--- a/vm/compiler.go
++++ b/vm/compiler.go
+@@ -2,7 +2,7 @@
+ // This file is available under the Apache license.
+ 
+ // Build the parser:
+-//go:generate $GOPATH/bin/goyacc -v y.output -o parser.go -p mtail parser.y
++//go:generate goyacc -v y.output -o parser.go -p mtail parser.y
+ 
+ package vm
+ 
diff --git a/pkgs/servers/monitoring/munin/adding_sconfdir_munin-node.patch b/pkgs/servers/monitoring/munin/adding_sconfdir_munin-node.patch
new file mode 100644
index 000000000000..6e14d6137034
--- /dev/null
+++ b/pkgs/servers/monitoring/munin/adding_sconfdir_munin-node.patch
@@ -0,0 +1,41 @@
+commit af5fa3623bb9a73052f9154be4a0f38c60ea42a2
+Author: Kjetil Orbekk <kjetil.orbekk@gmail.com>
+Date:   Thu Nov 23 21:21:36 2017 -0500
+
+    node: add --sconfdir to set plugin configuration dir
+
+diff --git a/node/sbin/munin-node b/node/sbin/munin-node
+index 909c8c4e..0ccf3941 100755
+--- a/node/sbin/munin-node
++++ b/node/sbin/munin-node
+@@ -100,9 +100,11 @@ sub parse_args
+     my @ORIG_ARGV  = @ARGV;
+ 
+     my $servicedir_cmdline;
++    my $sconfdir_cmdline;
+     print_usage_and_exit() unless GetOptions(
+         "config=s"     => \$conffile,
+         "servicedir=s" => \$servicedir_cmdline,
++        "sconfdir=s"   => \$sconfdir_cmdline,
+         "debug!"       => \$DEBUG,
+         "pidebug!"     => \$PIDEBUG,
+         "paranoia!"    => \$paranoia,
+@@ -112,6 +114,7 @@ sub parse_args
+ 
+     # We untaint the args brutally, since the sysadm should know what he does
+     $servicedir = $1 if defined $servicedir_cmdline && $servicedir_cmdline =~ m/(.*)/;
++    $sconfdir = $1 if defined $sconfdir_cmdline && $sconfdir_cmdline =~ m/(.*)/;
+ 
+     # Reset ARGV (for HUPing)
+     @ARGV = @ORIG_ARGV;
+@@ -175,6 +178,10 @@ Use E<lt>fileE<gt> as configuration file. [@@CONFDIR@@/munin-node.conf]
+ 
+ Override plugin directory [@@CONFDIR@@/plugins/]
+ 
++=item B<< --sconfdir <dir> >>
++
++Override plugin configuration directory [@@CONFDIR@@/plugin-conf.d/]
++
+ =item B< --[no]paranoia >
+ 
+ Only run plugins owned by root. Check permissions as well. [--noparanoia]
diff --git a/pkgs/servers/monitoring/munin/default.nix b/pkgs/servers/monitoring/munin/default.nix
index 51eda757e3c2..62fc3c6f8f55 100644
--- a/pkgs/servers/monitoring/munin/default.nix
+++ b/pkgs/servers/monitoring/munin/default.nix
@@ -1,14 +1,16 @@
-{ stdenv, fetchurl, makeWrapper, which, coreutils, rrdtool, perl, perlPackages
-, python, ruby, jre, nettools
+{ stdenv, fetchFromGitHub, makeWrapper, which, coreutils, rrdtool, perl, perlPackages
+, python, ruby, jre, nettools, bc
 }:
 
 stdenv.mkDerivation rec {
-  version = "2.0.25";
+  version = "2.0.37";
   name = "munin-${version}";
 
-  src = fetchurl {
-    url = "https://github.com/munin-monitoring/munin/archive/${version}.tar.gz";
-    sha256 = "1ig67l3p5fnx44fcvbbinajxlin9i7g9cbac93h2hcvb2qhzzzra";
+  src = fetchFromGitHub {
+    owner = "munin-monitoring";
+    repo = "munin";
+    rev = version;
+    sha256 = "10niyzckx90dwdr4d7vj07d1qjy3nk7xzp30nqnlxzbaww7n5v78";
   };
 
   buildInputs = [ 
@@ -55,7 +57,7 @@ stdenv.mkDerivation rec {
   doCheck = false;
 
   checkPhase = ''
-   export PERL5LIB="$PERL5LIB:${rrdtool}/lib/perl"
+   export PERL5LIB="$PERL5LIB:${rrdtool}/lib/perl5/site_perl"
    LC_ALL=C make -j1 test 
   '';
 
@@ -65,6 +67,9 @@ stdenv.mkDerivation rec {
 
     # https://github.com/munin-monitoring/munin/pull/134
     ./adding_servicedir_munin-node.patch
+
+    ./adding_sconfdir_munin-node.patch
+    ./preserve_environment.patch
   ];
 
   preBuild = ''
@@ -97,10 +102,11 @@ stdenv.mkDerivation rec {
 
   postFixup = ''
     echo "Removing references to /usr/{bin,sbin}/ from munin plugins..."
-    find "$out/lib/plugins" -type f -print0 | xargs -0 -L1 sed -i -e "s|/usr/bin/||g" -e "s|/usr/sbin/||g"
+    find "$out/lib/plugins" -type f -print0 | xargs -0 -L1 \
+        sed -i -e "s|/usr/bin/||g" -e "s|/usr/sbin/||g" -e "s|\<bc\>|${bc}/bin/bc|g"
 
-    if test -e $out/nix-support/propagated-native-build-inputs; then
-        ln -s $out/nix-support/propagated-native-build-inputs $out/nix-support/propagated-user-env-packages
+    if test -e $out/nix-support/propagated-build-inputs; then
+        ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
     fi
 
     for file in "$out"/bin/munindoc "$out"/sbin/munin-* "$out"/lib/munin-* "$out"/www/cgi/*; do
@@ -109,10 +115,10 @@ stdenv.mkDerivation rec {
             *.jar) continue;;
         esac
         wrapProgram "$file" \
-          --set PERL5LIB "$out/lib/perl5/site_perl:${rrdtool}/lib/perl:${with perlPackages; stdenv.lib.makePerlPath [
+          --set PERL5LIB "$out/lib/perl5/site_perl:${with perlPackages; stdenv.lib.makePerlPath [
                 Log4Perl IOSocketInet6 Socket6 URI DBFile DateManip
                 HTMLTemplate FileCopyRecursive FCGI NetCIDR NetSNMP NetServer
-                ListMoreUtils TimeHiRes DBDPg LWPUserAgent
+                ListMoreUtils TimeHiRes DBDPg LWPUserAgent rrdtool
                 ]}"
     done
   '';
@@ -127,7 +133,7 @@ stdenv.mkDerivation rec {
     '';
     homepage = http://munin-monitoring.org/;
     license = licenses.gpl2;
-    maintainers = [ maintainers.iElectric maintainers.bjornfor ];
+    maintainers = [ maintainers.domenkozar maintainers.bjornfor ];
     platforms = platforms.linux;
   };
 }
diff --git a/pkgs/servers/monitoring/munin/preserve_environment.patch b/pkgs/servers/monitoring/munin/preserve_environment.patch
new file mode 100644
index 000000000000..ef66f48ecb42
--- /dev/null
+++ b/pkgs/servers/monitoring/munin/preserve_environment.patch
@@ -0,0 +1,41 @@
+commit d94c29b7397362857b81d8c877a989fdb28490d8
+Author: Kjetil Orbekk <kjetil.orbekk@gmail.com>
+Date:   Tue Nov 21 15:37:42 2017 -0500
+
+    Keep environment variables instead of overwriting them.
+
+diff --git a/common/lib/Munin/Common/Defaults.pm b/common/lib/Munin/Common/Defaults.pm
+index 131f52c0..bbf42697 100644
+--- a/common/lib/Munin/Common/Defaults.pm
++++ b/common/lib/Munin/Common/Defaults.pm
+@@ -71,7 +71,7 @@ sub export_to_environment {
+ 
+     my %defaults = %{$class->get_defaults()};
+     while (my ($k, $v) = each %defaults) {
+-        $ENV{$k} = $v;
++        $ENV{$k} = $ENV{$k} || $v;
+     }
+ 
+     return
+diff --git a/node/lib/Munin/Node/Service.pm b/node/lib/Munin/Node/Service.pm
+index 1b4f6114..be58bd77 100644
+--- a/node/lib/Munin/Node/Service.pm
++++ b/node/lib/Munin/Node/Service.pm
+@@ -122,7 +122,7 @@ sub export_service_environment {
+     # We append the USER to the MUNIN_PLUGSTATE, to avoid CVE-2012-3512
+     my $uid = $self->_resolve_uid($service);
+     my $user = getpwuid($uid);
+-    $ENV{MUNIN_PLUGSTATE} = "$Munin::Common::Defaults::MUNIN_PLUGSTATE/$user";
++    $ENV{MUNIN_PLUGSTATE} = "$ENV{MUNIN_PLUGSTATE}/$user";
+ 
+     # Provide a consistent default state-file.
+     $ENV{MUNIN_STATEFILE} = "$ENV{MUNIN_PLUGSTATE}/$service-$ENV{MUNIN_MASTER_IP}";
+@@ -243,7 +243,7 @@ sub exec_service
+ 
+     # XXX - Create the statedir for the user
+     my $uid = $self->_resolve_uid($service);
+-    Munin::Node::OS->mkdir_subdir("$Munin::Common::Defaults::MUNIN_PLUGSTATE", $uid);
++    Munin::Node::OS->mkdir_subdir("$ENV{MUNIN_PLUGSTATE}", $uid);
+ 
+     $self->change_real_and_effective_user_and_group($service);
+ 
diff --git a/pkgs/servers/monitoring/nagios/default.nix b/pkgs/servers/monitoring/nagios/default.nix
index bf43a93a81b2..47bc6d58da90 100644
--- a/pkgs/servers/monitoring/nagios/default.nix
+++ b/pkgs/servers/monitoring/nagios/default.nix
@@ -1,16 +1,16 @@
-{ stdenv, fetchurl, perl, php, gd, libpng, zlib }:
+{ stdenv, fetchurl, perl, php, gd, libpng, zlib, unzip }:
 
 stdenv.mkDerivation rec {
   name = "nagios-${version}";
-  version = "4.0.8";
+  version = "4.3.4";
 
   src = fetchurl {
     url = "mirror://sourceforge/nagios/nagios-4.x/${name}/${name}.tar.gz";
-    sha256 = "0jyad39wa318613awlnpczrrakvjcipz8qp1mdsig1cp1hjqs9lb";
+    sha256 = "1wa4m952sb23dqi5w759adimsp21bkhp598rpq9dnhz3v497h2y9";
   };
 
   patches = [ ./nagios.patch ];
-  buildInputs = [ php perl gd libpng zlib ];
+  buildInputs = [ php perl gd libpng zlib unzip ];
 
   configureFlags = [ "--localstatedir=/var/lib/nagios" ];
   buildFlags = "all";
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "A host, service and network monitoring program";
-    homepage    = http://www.nagios.org/;
+    homepage    = https://www.nagios.org/;
     license     = stdenv.lib.licenses.gpl2;
     platforms   = stdenv.lib.platforms.linux;
     maintainers = with stdenv.lib.maintainers; [ thoughtpolice relrod ];
diff --git a/pkgs/servers/monitoring/nagios/plugins/check_ssl_cert.nix b/pkgs/servers/monitoring/nagios/plugins/check_ssl_cert.nix
new file mode 100644
index 000000000000..deac45eadb62
--- /dev/null
+++ b/pkgs/servers/monitoring/nagios/plugins/check_ssl_cert.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, file, openssl, makeWrapper, which, curl }:
+
+stdenv.mkDerivation rec {
+  name = "check_ssl_cert-${version}";
+  version = "1.64.0";
+
+  src = fetchFromGitHub {
+    owner = "matteocorti";
+    repo = "check_ssl_cert";
+    rev = "v${version}";
+    sha256 = "0pq297sbz9hzcaccnnsfmra0bac81cki9xfrnb22a1hgfhqjxy5r";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  makeFlags = [ "DESTDIR=$(out)/bin" "MANDIR=$(out)/share/man" ];
+
+  postInstall = ''
+    wrapProgram $out/bin/check_ssl_cert \
+      --prefix PATH : "${stdenv.lib.makeBinPath [ openssl file which curl ]}"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A Nagios plugin to check the CA and validity of an X.509 certificate";
+    license = licenses.gpl3;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/monitoring/nagios/plugins/official-2.x.nix b/pkgs/servers/monitoring/nagios/plugins/official-2.x.nix
deleted file mode 100644
index 79180f172417..000000000000
--- a/pkgs/servers/monitoring/nagios/plugins/official-2.x.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{ stdenv, fetchurl, openssh }:
-
-stdenv.mkDerivation rec {
-  name = "nagios-plugins-${version}";
-  version = "2.0.3";
-
-  src = fetchurl {
-    url = "http://nagios-plugins.org/download/${name}.tar.gz";
-    sha256 = "0jm0mn55hqwl8ffx8ww9mql2wrkhp1h2k8jw53q3h0ff5m22204g";
-  };
-
-  # !!! Awful hack. Grrr... this of course only works on NixOS.
-  # Anyway the check that configure performs to figure out the ping
-  # syntax is totally impure, because it runs an actual ping to
-  # localhost (which won't work for ping6 if IPv6 support isn't
-  # configured on the build machine).
-  preConfigure= "
-    configureFlagsArray=(
-      --with-ping-command='/var/setuid-wrappers/ping -n -U -w %d -c %d %s'
-      --with-ping6-command='/var/setuid-wrappers/ping6 -n -U -w %d -c %d %s'
-    )
-  ";
-
-  postInstall = "ln -s libexec $out/bin";
-
-  # !!! make openssh a runtime dependency only
-  buildInputs = [ openssh ];
-
-  meta = {
-    description = "Official plugins for Nagios";
-    homepage    = http://www.nagios.org/download/plugins;
-    license     = stdenv.lib.licenses.gpl2;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice relrod ];
-  };
-}
diff --git a/pkgs/servers/monitoring/net-snmp/default.nix b/pkgs/servers/monitoring/net-snmp/default.nix
index efc61b9fd6b2..a6b738270a9a 100644
--- a/pkgs/servers/monitoring/net-snmp/default.nix
+++ b/pkgs/servers/monitoring/net-snmp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, autoreconfHook, file, openssl, perl, unzip }:
+{ stdenv, fetchurl, fetchpatch, autoreconfHook, file, openssl, perl, unzip }:
 
 stdenv.mkDerivation rec {
   name = "net-snmp-5.7.3";
@@ -8,6 +8,19 @@ stdenv.mkDerivation rec {
     sha256 = "0gkss3zclm23zwpqfhddca8278id7pk6qx1mydpimdrrcndwgpz8";
   };
 
+  patches =
+    let fetchAlpinePatch = name: sha256: fetchpatch {
+      url = "https://git.alpinelinux.org/cgit/aports/plain/main/net-snmp/${name}?id=f25d3fb08341b60b6ccef424399f060dfcf3f1a5";
+      inherit name sha256;
+    };
+  in [
+    (fetchAlpinePatch "CVE-2015-5621.patch" "05098jyvd9ddr5q26z7scbbvk1bk6x4agpjm6pyprvpc1zpi0y09")
+    (fetchAlpinePatch "fix-Makefile-PL.patch" "14ilnkj3cr6mpi242hrmmmv8nv4dj0fdgn42qfk9aa7scwsc0lc7")
+    (fetchAlpinePatch "fix-includes.patch" "0zpkbb6k366qpq4dax5wknwprhwnhighcp402mlm7950d39zfa3m")
+    (fetchAlpinePatch "netsnmp-swinst-crash.patch" "0gh164wy6zfiwiszh58fsvr25k0ns14r3099664qykgpmickkqid")
+    (fetchAlpinePatch "remove-U64-typedef.patch" "1msxyhcqkvhqa03dwb50288g7f6nbrcd9cs036m9xc8jdgjb8k8j")
+  ];
+
   preConfigure =
     ''
       perlversion=$(perl -e 'use Config; print $Config{version};')
@@ -24,18 +37,26 @@ stdenv.mkDerivation rec {
       "--with-sys-contact=root@unknown"
       "--with-logfile=/var/log/net-snmpd.log"
       "--with-persistent-directory=/var/lib/net-snmp"
-      "--with-openssl=${openssl}"
-    ];
+      "--with-openssl=${openssl.dev}"
+    ] ++ stdenv.lib.optional stdenv.isLinux "--with-mnttab=/proc/mounts";
 
-  buildInputs = [ autoreconfHook file perl unzip openssl ];
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ file perl unzip openssl ];
 
   enableParallelBuilding = true;
+  doCheck = false; # fails
+
+  postInstall = ''
+    for f in "$out/lib/"*.la $out/bin/net-snmp-config $out/bin/net-snmp-create-v3-user; do
+      sed 's|-L${openssl.dev}|-L${openssl.out}|g' -i $f
+    done
+  '';
 
   meta = with stdenv.lib; {
     description = "Clients and server for the SNMP network monitoring protocol";
     homepage = http://net-snmp.sourceforge.net/;
     license = licenses.bsd3;
-    platforms = platforms.unix;
+    platforms = platforms.linux;
     maintainers = with maintainers; [ wkennington ];
   };
 }
diff --git a/pkgs/servers/monitoring/newrelic-sysmond/default.nix b/pkgs/servers/monitoring/newrelic-sysmond/default.nix
index a300d3514ee2..e9a9fcff2b93 100644
--- a/pkgs/servers/monitoring/newrelic-sysmond/default.nix
+++ b/pkgs/servers/monitoring/newrelic-sysmond/default.nix
@@ -1,14 +1,12 @@
 { stdenv, fetchurl }:
 
-assert stdenv.system == "x86_64-linux";
-
 stdenv.mkDerivation rec {
-  name = "newrelic-sysmond-1.5.1.93";
+  name = "newrelic-sysmond-${version}";
+  version = "2.3.0.132";
 
   src = fetchurl {
-    url = "http://download.newrelic.com/server_monitor/release/newrelic-sysmond-1.5.1.93-linux.tar.gz";
-
-    sha256 = "1bfwyczcf7pvji8lx566jxgy8dhyf1gmqmi64lj10673a86axnwz";
+    url = "http://download.newrelic.com/server_monitor/archive/${version}/newrelic-sysmond-${version}-linux.tar.gz";
+    sha256 = "0cdvffdsadfahfn1779zjfawz6l77awab3g9mw43vsba1568jh4f";
   };
 
   installPhase = ''
@@ -18,11 +16,11 @@ stdenv.mkDerivation rec {
       $out/bin/nrsysmond
   '';
 
-  meta = {
-    homepage = http://newrelic.com/;
-
+  meta = with stdenv.lib; {
     description = "System-wide monitoring for newrelic";
-
-    license = stdenv.lib.licenses.unfree;
+    homepage = http://newrelic.com/;
+    license = licenses.unfree;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ lnl7 ];
   };
 }
diff --git a/pkgs/servers/monitoring/plugins/default.nix b/pkgs/servers/monitoring/plugins/default.nix
new file mode 100644
index 000000000000..a0f7341571ce
--- /dev/null
+++ b/pkgs/servers/monitoring/plugins/default.nix
@@ -0,0 +1,71 @@
+{ stdenv, fetchFromGitHub, autoreconfHook
+, coreutils, gnugrep, gnused, lm_sensors, net_snmp, openssh, openssl, perl }:
+
+with stdenv.lib;
+
+let
+  majorVersion = "2.2";
+  minorVersion = ".0";
+
+  binPath = makeBinPath [ coreutils gnugrep gnused lm_sensors net_snmp ];
+
+in stdenv.mkDerivation rec {
+  name = "monitoring-plugins-${majorVersion}${minorVersion}";
+
+  src = fetchFromGitHub {
+    owner  = "monitoring-plugins";
+    repo   = "monitoring-plugins";
+    rev    = "v${majorVersion}";
+    sha256 = "1pw7i6d2cnb5nxi2lbkwps2qzz04j9zd86fzpv9ka896b4aqrwv1";
+  };
+
+  # !!! Awful hack. Grrr... this of course only works on NixOS.
+  # Anyway the check that configure performs to figure out the ping
+  # syntax is totally impure, because it runs an actual ping to
+  # localhost (which won't work for ping6 if IPv6 support isn't
+  # configured on the build machine).
+  preConfigure= ''
+    substituteInPlace po/Makefile.in.in \
+      --replace /bin/sh ${stdenv.shell}
+
+    sed -i configure.ac \
+      -e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"\$out/bin:/run/wrappers/bin:${binPath}\"|'
+
+    configureFlagsArray=(
+      --with-ping-command='/run/wrappers/bin/ping -4 -n -U -w %d -c %d %s'
+      --with-ping6-command='/run/wrappers/bin/ping -6 -n -U -w %d -c %d %s'
+    )
+  '';
+
+  # !!! make openssh a runtime dependency only
+  buildInputs = [ net_snmp openssh openssl perl ];
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  enableParallelBuilding = true;
+
+  # For unknown reasons the installer tries executing $out/share and fails if
+  # it doesn't succeed.
+  # So we create it and remove it again later.
+  preBuild = ''
+    mkdir -p $out
+    cat <<_EOF > $out/share
+#!${stdenv.shell}
+exit 0
+_EOF
+    chmod 755 $out/share
+  '';
+
+  postInstall = ''
+    rm $out/share
+    ln -s libexec $out/bin
+  '';
+
+  meta = {
+    description = "Official monitoring plugins for Nagios/Icinga/Sensu and others.";
+    homepage    = https://www.monitoring-plugins.org;
+    license     = licenses.gpl2;
+    platforms   = platforms.linux;
+    maintainers = with maintainers; [ thoughtpolice relrod ];
+  };
+}
diff --git a/pkgs/servers/monitoring/plugins/esxi.nix b/pkgs/servers/monitoring/plugins/esxi.nix
new file mode 100644
index 000000000000..e458e130ba49
--- /dev/null
+++ b/pkgs/servers/monitoring/plugins/esxi.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub, python2Packages }:
+
+let
+  bName = "check_esxi_hardware";
+  pName = stdenv.lib.replaceStrings [ "_" ] [ "-" ] "${bName}";
+
+in python2Packages.buildPythonApplication rec {
+  name = "${pName}-${version}";
+  version = "20161013";
+
+  src = fetchFromGitHub {
+    owner  = "Napsty";
+    repo   = bName;
+    rev    = version;
+    sha256 = "19zybcg62dqcinixnp1p8zw916x3w7xvy6dlsmn347iigfa5s55s";
+  };
+
+  dontBuild = true;
+  doCheck = false;
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm755 -t $out/bin                ${bName}.py
+    install -Dm644 -t $out/share/doc/${pName} README.md
+
+    runHook postInstall
+  '';
+
+  propagatedBuildInputs = with python2Packages; [ pywbem ];
+
+  meta = with stdenv.lib; {
+    homepage = https://www.claudiokuenzler.com/nagios-plugins/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ peterhoeg ];
+  };
+}
diff --git a/pkgs/servers/monitoring/plugins/labs_consol_de.nix b/pkgs/servers/monitoring/plugins/labs_consol_de.nix
new file mode 100644
index 000000000000..957aee43691a
--- /dev/null
+++ b/pkgs/servers/monitoring/plugins/labs_consol_de.nix
@@ -0,0 +1,79 @@
+{ stdenv, fetchFromGitHub, fetchurl, buildPerlPackage, autoreconfHook, makeWrapper
+, perl, DBDsybase, NetSNMP, coreutils, gnused, gnugrep }:
+
+let
+  glplugin = fetchFromGitHub {
+    owner = "lausser";
+    repo   = "GLPlugin";
+    rev    = "e8e1a2907a54435c932b3e6c584ba1d679754849";
+    sha256 = "0wb55a9pmgbilfffx0wkiikg9830qd66j635ypczqp4basslpq5b";
+  };
+
+  generic = { pname, version, sha256, description, buildInputs, ... }:
+  let
+    name' = "${stdenv.lib.replaceStrings [ "-" ] [ "_" ] "${pname}"}-${version}";
+  in perl.stdenv.mkDerivation {
+    name = "${pname}-${version}";
+
+    src = fetchurl {
+      url = "https://labs.consol.de/assets/downloads/nagios/${name'}.tar.gz";
+      inherit sha256;
+    };
+
+    buildInputs = [ perl ] ++ buildInputs;
+
+    nativeBuildInputs = [ autoreconfHook makeWrapper ];
+
+    prePatch = with stdenv.lib; ''
+      rm -rf GLPlugin
+      ln -s ${glplugin} GLPlugin
+      substituteInPlace plugins-scripts/Makefile.am \
+        --replace /bin/cat  ${getBin coreutils}/bin/cat \
+        --replace /bin/echo ${getBin coreutils}/bin/echo \
+        --replace /bin/grep ${getBin gnugrep}/bin/grep \
+        --replace /bin/sed  ${getBin gnused}/bin/sed
+    '';
+
+    postInstall = ''
+      test -d $out/libexec && ln -sr $out/libexec $out/bin
+    '';
+
+    postFixup = ''
+      for f in $out/bin/* ; do
+        wrapProgram $f --prefix PERL5LIB : $PERL5LIB
+      done
+    '';
+
+    meta = with stdenv.lib; {
+      homepage    = https://labs.consol.de/;
+      license     = licenses.gpl2;
+      maintainers = with maintainers; [ peterhoeg ];
+      inherit description;
+    };
+  };
+
+in {
+  check-mssql-health = generic {
+    pname       = "check_mssql_health";
+    version     = "2.6.4.14";
+    sha256      = "0w6gybrs7imx169l8740s0ax3adya867fw0abrampx59mnsj5pm1";
+    description = "Check plugin for Microsoft SQL Server.";
+    buildInputs = [ DBDsybase ];
+  };
+
+  check-nwc-health = generic {
+    pname       = "check_nwc_health";
+    version     = "7.0.1.3";
+    sha256      = "0rgd6zgd7kplx3z72n8zbzwkh8vnd83361sk9ibh6ng78sds1sl5";
+    description = "Check plugin for network equipment.";
+    buildInputs = [ NetSNMP ];
+  };
+
+  check-ups-health = generic {
+    pname       = "check_ups_health";
+    version     = "2.8.2.2";
+    sha256      = "1gc2wjsymay2vk5ywc1jj9cvrbhs0fs851x8l4nc75df2g75v521";
+    description = "Check plugin for UPSs.";
+    buildInputs = [ NetSNMP ];
+  };
+}
diff --git a/pkgs/servers/monitoring/plugins/uptime.nix b/pkgs/servers/monitoring/plugins/uptime.nix
new file mode 100644
index 000000000000..9f03c9ea96f6
--- /dev/null
+++ b/pkgs/servers/monitoring/plugins/uptime.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  name = "check-uptime-${version}";
+  version = "20161112";
+
+  src = fetchFromGitHub {
+    owner  = "madrisan";
+    repo   = "nagios-plugins-uptime";
+    rev    = "51822dacd1d404b3eabf3b4984c64b2475ed6f3b";
+    sha256 = "18q9ibzqn97dsyr9xs3w9mqk80nmmfw3kcjidrdsj542amlsycyk";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  enableParallelBuilding = true;
+
+  postInstall = "ln -sr $out/libexec $out/bin";
+
+  meta = with stdenv.lib; {
+    description = "Uptime check plugin for Sensu/Nagios/others";
+    homepage    = https://github.com/madrisan/nagios-plugins-uptime;
+    license     = licenses.gpl3;
+    maintainers = with maintainers; [ peterhoeg ];
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/alertmanager.nix b/pkgs/servers/monitoring/prometheus/alertmanager.nix
new file mode 100644
index 000000000000..2f9016b74991
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/alertmanager.nix
@@ -0,0 +1,42 @@
+{ stdenv, go, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "alertmanager-${version}";
+  version = "0.14.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/prometheus/alertmanager";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "alertmanager";
+    sha256 = "0f6yi19zffxnp3dlr4zs52b7bllks3kjxkdn9zvvi5lvpkzmba5j";
+  };
+
+  # Tests exist, but seem to clash with the firewall.
+  doCheck = false;
+
+  buildFlagsArray = let t = "${goPackagePath}/vendor/github.com/prometheus/common/version"; in ''
+    -ldflags=
+       -X ${t}.Version=${version}
+       -X ${t}.Revision=${src.rev}
+       -X ${t}.Branch=unknown
+       -X ${t}.BuildUser=nix@nixpkgs
+       -X ${t}.BuildDate=unknown
+       -X ${t}.GoVersion=${stdenv.lib.getVersion go}
+  '';
+
+  postInstall = ''
+    mkdir -p $bin/etc/bash_completion.d
+    $NIX_BUILD_TOP/go/bin/amtool --completion-script-bash > $bin/etc/bash_completion.d/amtool_completion.sh
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Alert dispatcher for the Prometheus monitoring system";
+    homepage = https://github.com/prometheus/alertmanager;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/bind-exporter.nix b/pkgs/servers/monitoring/prometheus/bind-exporter.nix
new file mode 100644
index 000000000000..db58c7e14e5f
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/bind-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "bind_exporter-${version}";
+  version = "20161221-${stdenv.lib.strings.substring 0 7 rev}";
+  rev = "4e1717c7cd5f31c47d0c37274464cbaabdd462ba";
+
+  goPackagePath = "github.com/digitalocean/bind_exporter";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "digitalocean";
+    repo = "bind_exporter";
+    sha256 = "1nd6pc1z627w4x55vd42zfhlqxxjmfsa9lyn0g6qq19k4l85v1qm";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Prometheus exporter for bind9 server";
+    homepage = https://github.com/digitalocean/bind_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ rtreffer ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/blackbox-exporter.nix b/pkgs/servers/monitoring/prometheus/blackbox-exporter.nix
new file mode 100644
index 000000000000..798f31c3458e
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/blackbox-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "blackbox_exporter-${version}";
+  version = "0.12.0";
+  rev = version;
+
+  goPackagePath = "github.com/prometheus/blackbox_exporter";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner = "prometheus";
+    repo = "blackbox_exporter";
+    sha256 = "0gd3vymk3qdfjnf0rx9kwc6v0jv7f8l30igvj2v7bljar2d6hzxf";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Blackbox probing of endpoints over HTTP, HTTPS, DNS, TCP and ICMP";
+    homepage = https://github.com/prometheus/blackbox_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ globin fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/collectd-exporter.nix b/pkgs/servers/monitoring/prometheus/collectd-exporter.nix
new file mode 100644
index 000000000000..2bd9b6af0748
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/collectd-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "collectd-exporter-${version}";
+  version = "0.3.1";
+  rev = version;
+
+  goPackagePath = "github.com/prometheus/collectd_exporter";
+
+  src= fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "collectd_exporter";
+    sha256 = "1p0kb7c8g0r0sp5a6xrx8vnwbw14hhwlqzk4n2xx2y8pvnbivajz";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Relay server for exporting metrics from collectd to Prometheus";
+    homepage = https://github.com/prometheus/collectd_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/consul-exporter.nix b/pkgs/servers/monitoring/prometheus/consul-exporter.nix
new file mode 100644
index 000000000000..47abcb33ee79
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/consul-exporter.nix
@@ -0,0 +1,23 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "consul_exporter-${version}";
+  version = "0.3.0";
+
+  goPackagePath = "github.com/prometheus/consul_exporter";
+
+  src = fetchFromGitHub {
+    owner = "prometheus";
+    repo = "consul_exporter";
+    rev = "v${version}";
+    sha256 = "1zffbxyfmqpbdqkx5rb5vjgd9j4p4zcrh6jvn1zhbdzrcs7khnd9";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Prometheus exporter for Consul metrics";
+    homepage = https://github.com/prometheus/consul_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ hectorj ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/default.nix b/pkgs/servers/monitoring/prometheus/default.nix
new file mode 100644
index 000000000000..37d82326cc29
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, go, buildGoPackage, fetchFromGitHub }:
+
+let
+  goPackagePath = "github.com/prometheus/prometheus";
+
+  generic = { version, sha256, ... }@attrs:
+    let attrs' = builtins.removeAttrs attrs ["version" "sha256"]; in
+      buildGoPackage ({
+        name = "prometheus-${version}";
+
+        inherit goPackagePath;
+
+        src = fetchFromGitHub {
+          rev = "v${version}";
+          owner = "prometheus";
+          repo = "prometheus";
+          inherit sha256;
+        };
+
+        doCheck = true;
+
+        buildFlagsArray = let t = "${goPackagePath}/vendor/github.com/prometheus/common/version"; in ''
+          -ldflags=
+             -X ${t}.Version=${version}
+             -X ${t}.Revision=unknown
+             -X ${t}.Branch=unknown
+             -X ${t}.BuildUser=nix@nixpkgs
+             -X ${t}.BuildDate=unknown
+             -X ${t}.GoVersion=${stdenv.lib.getVersion go}
+        '';
+
+        preInstall = ''
+          mkdir -p "$bin/share/doc/prometheus" "$bin/etc/prometheus"
+          cp -a $src/documentation/* $bin/share/doc/prometheus
+          cp -a $src/console_libraries $src/consoles $bin/etc/prometheus
+        '';
+
+        meta = with stdenv.lib; {
+          description = "Service monitoring system and time series database";
+          homepage = https://prometheus.io;
+          license = licenses.asl20;
+          maintainers = with maintainers; [ benley fpletz ];
+          platforms = platforms.unix;
+        };
+    } // attrs');
+in rec {
+  prometheus_1 = generic {
+    version = "1.8.2";
+    sha256 = "088flpg3qgnj9afl9vbaa19v2s1d21yxy38nrlv5m7cxwy2pi5pv";
+  };
+
+  prometheus_2 = generic {
+    version = "2.2.1";
+    sha256 = "1zwxjmj8jh02i4y3i3zrkz7ml66zyhg3ad1npjzf3319mglsp7ch";
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/dnsmasq-exporter-deps.nix b/pkgs/servers/monitoring/prometheus/dnsmasq-exporter-deps.nix
new file mode 100644
index 000000000000..1acf859e81a6
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/dnsmasq-exporter-deps.nix
@@ -0,0 +1,93 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "3a771d992973f24aa725d07868b467d1ddfceafb";
+      sha256 = "1l2lns4f5jabp61201sh88zf3b0q793w4zdgp9nll7mmfcxxjif3";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "b4deda0973fb4c70b50d226b1af49f3da59f5265";
+      sha256 = "0ya4ha7m20bw048m1159ppqzlvda4x0vdprlbk5sdgmy74h3xcdq";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/miekg/dns";
+    fetch = {
+      type = "git";
+      url = "https://github.com/miekg/dns";
+      rev = "9c76f9827e170bfcd354c2cb02a6fd428faf81a6";
+      sha256 = "0yym4jr15cqwlppnqfsp92i7p1ir12ys695wffb3in7gnnm0d38n";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "82f5ff156b29e276022b1a958f7d385870fb9814";
+      sha256 = "111j329yrlgvh73dm80gawwxsh9dgjkw74254kyj5c2rfmra7znz";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "d811d2e9bf898806ecfb6ef6296774b13ffc314c";
+      sha256 = "0r4067r4ysmljksqw3awcxx5qplqhykahc5igdzgkky7i4bvaik1";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e";
+      sha256 = "0x128p15h35mgwqxkigfkk1lfrcz9g697ahl8v6xp9kwvcqvjrrf";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "640f4622ab692b87c2f3a94265e6f579fe38263d";
+      sha256 = "097m4qhcljhp180171j5fjhq4740iirfkkajfd7yrxqhp4s9hljx";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sync";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sync";
+      rev = "1d60e4601c6fd243af51cc01ddf169918a5407ca";
+      sha256 = "046jlanz2lkxq1r57x9bl6s4cvfqaic6p2xybsj8mq1120jv4rs6";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/dnsmasq-exporter.nix b/pkgs/servers/monitoring/prometheus/dnsmasq-exporter.nix
new file mode 100644
index 000000000000..bcfc82adf478
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/dnsmasq-exporter.nix
@@ -0,0 +1,23 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "dnsmasq_exporter-unstable-2018-05-05";
+
+  goPackagePath = "github.com/google/dnsmasq_exporter";
+
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "dnsmasq_exporter";
+    sha256 = "1kzq4h7z28xadx425nbgxadk62yiz6279d300fyiyi83hwq0ay8c";
+    rev = "e1f281b435bbefbb2d17fc57c051ede0ab973c59";
+  };
+
+  goDeps = ./dnsmasq-exporter-deps.nix;
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "A dnsmasq exporter for Prometheus";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ willibutz ];
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/dovecot-exporter-deps.nix b/pkgs/servers/monitoring/prometheus/dovecot-exporter-deps.nix
new file mode 100644
index 000000000000..c2dea18ee815
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/dovecot-exporter-deps.nix
@@ -0,0 +1,93 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/alecthomas/template";
+    fetch = {
+      type = "git";
+      url = "https://github.com/alecthomas/template";
+      rev = "a0175ee3bccc567396460bf5acd36800cb10c49c";
+      sha256 = "0qjgvvh26vk1cyfq9fadyhfgdj36f1iapbmr5xp6zqipldz8ffxj";
+    };
+  }
+  {
+    goPackagePath = "github.com/alecthomas/units";
+    fetch = {
+      type = "git";
+      url = "https://github.com/alecthomas/units";
+      rev = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a";
+      sha256 = "1j65b91qb9sbrml9cpabfrcf07wmgzzghrl7809hjjhrmbzri5bl";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "bbd03ef6da3a115852eaf24c8a1c46aeb39aa175";
+      sha256 = "1pyli3dcagi7jzpiazph4fhkz7a3z4bhd25nwbb7g0iy69b8z1g4";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "c3324c1198cf3374996e9d3098edd46a6b55afc9";
+      sha256 = "19qcz5bpzj5kqyhmbq5kxr8nrqqlszazzq6w0wldis1yk1wwww00";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "e4aa40a9169a88835b849a6efb71e05dc04b88f0";
+      sha256 = "0m1n616d694jca0qjwjn5ci7scfgm2jpi94dhi356arm9lhda4jc";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "54d17b57dd7d4a3aa092476596b3f8a933bde349";
+      sha256 = "1b5218hi6k9i637k6xc7ynpll577zbnrhjm9jr2iczy3j0rr4rvr";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/alecthomas/kingpin.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/alecthomas/kingpin.v2";
+      rev = "947dcec5ba9c011838740e680966fd7087a71d0d";
+      sha256 = "0mndnv3hdngr3bxp7yxfd47cas4prv98sqw534mx7vp38gd88n5r";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/dovecot-exporter.nix b/pkgs/servers/monitoring/prometheus/dovecot-exporter.nix
new file mode 100644
index 000000000000..86f43116f746
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/dovecot-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "dovecot_exporter-${version}";
+  version = "0.1.1";
+
+  goPackagePath = "github.com/kumina/dovecot_exporter";
+
+  src = fetchFromGitHub {
+    owner = "kumina";
+    repo = "dovecot_exporter";
+    rev = version;
+    sha256 = "0i7nfgkb5jqdbgr16i29jdsvh69dx9qgn6nazpw78k0lgy7mpidn";
+  };
+
+  goDeps = ./dovecot-exporter-deps.nix;
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Prometheus metrics exporter for Dovecot";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ willibutz ];
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/fritzbox-exporter.nix b/pkgs/servers/monitoring/prometheus/fritzbox-exporter.nix
new file mode 100644
index 000000000000..2e7a4932de62
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/fritzbox-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "fritzbox-exporter-${version}";
+  version = "1.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/ndecker/fritzbox_exporter";
+
+  src= fetchFromGitHub {
+    inherit rev;
+    owner = "ndecker";
+    repo = "fritzbox_exporter";
+    sha256 = "1qk3dgxxz3cnz52jzz0yvfkrkk4s5kdhc26nbfgdpn0ifzqj0awr";
+  };
+
+  meta = with stdenv.lib; {
+    description = "FRITZ!Box UPnP statistics exporter for prometheus";
+    homepage = https://github.com/ndecker/fritzbox_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ bachp ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/haproxy-exporter.nix b/pkgs/servers/monitoring/prometheus/haproxy-exporter.nix
new file mode 100644
index 000000000000..b2a0e3875891
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/haproxy-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "haproxy_exporter-${version}";
+  version = "0.8.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/prometheus/haproxy_exporter";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "haproxy_exporter";
+    sha256 = "0gx8pq67w71ch3g3c77xaz39msrd9graizc6d3shwabdjx35yc6q";
+  };
+
+  meta = with stdenv.lib; {
+    description = "HAProxy Exporter for the Prometheus monitoring system";
+    homepage = https://github.com/prometheus/haproxy_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/json-exporter.nix b/pkgs/servers/monitoring/prometheus/json-exporter.nix
new file mode 100644
index 000000000000..ea17c0b18b23
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/json-exporter.nix
@@ -0,0 +1,25 @@
+# This file was generated by go2nix.
+{ stdenv, buildGoPackage, fetchFromGitHub, lib }:
+
+buildGoPackage rec {
+  name = "prometheus-json-exporter-${version}";
+  version = "unstable-2016-09-13";
+  rev = "d45e5ebdb08cb734ad7a8683966032af1d91a76c";
+
+  goPackagePath = "github.com/kawamuray/prometheus-json-exporter";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "kawamuray";
+    repo = "prometheus-json-exporter";
+    sha256 = "0v3as7gakdqpsir97byknsrqxxxkq66hp23j4cscs45hsdb24pi9";
+  };
+
+  goDeps = ./json-exporter_deps.nix;
+
+  meta = {
+    description = "A prometheus exporter which scrapes remote JSON by JSONPath";
+    homepage = https://github.com/kawamuray/prometheus-json-exporter;
+    license = lib.licenses.asl20;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/json-exporter_deps.nix b/pkgs/servers/monitoring/prometheus/json-exporter_deps.nix
new file mode 100644
index 000000000000..9416125bc0c2
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/json-exporter_deps.nix
@@ -0,0 +1,111 @@
+# This file was generated by go2nix.
+[
+  {
+    goPackagePath = "github.com/Sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Sirupsen/logrus";
+      rev = "a437dfd2463eaedbec3dfe443e477d3b0a810b3f";
+      sha256 = "1904s2bbc7p88anzjp6fyj3jrbm5p6wbb8j4490674dq10kkcfbj";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "8ee79997227bf9b34611aee7946ae64735e6fd93";
+      sha256 = "0qm1lpdhf97k2hxgivq2cpjgawhlmmz39y230kgxijhm96xijxb8";
+    };
+  }
+  {
+    goPackagePath = "github.com/kawamuray/jsonpath";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kawamuray/jsonpath";
+      rev = "5c448ebf973557834ef870e788b0b2d95ac68d12";
+      sha256 = "1i1id1i85rf09rldp03h0ibyi6zg0fz9p9l5qj7i8dfs6h6y8f0a";
+    };
+  }
+  {
+    goPackagePath = "github.com/kawamuray/prometheus-exporter-harness";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kawamuray/prometheus-exporter-harness";
+      rev = "97eeea7b8b0619ea2a065d75c0f0f5909327afa6";
+      sha256 = "12al8irf8jb6p2xmm4wbh0wjqsyrdywynr4w122wxxnsx2n56xyv";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "575f371f7862609249a1be4c9145f429fe065e32";
+      sha256 = "0hyvszjv5m6i40k2fn21c3bjr8jhlfdqavk1r6g2v5dybyj47vps";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "fa8ad6fec33561be4280a8f0514318c79d7f6cb6";
+      sha256 = "11a7v1fjzhhwsl128znjcf5v7v6129xjgkdpym2lial4lac1dhm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "0d5de9d6d8629cb8bee6d4674da4127cd8b615a3";
+      sha256 = "1zlvvgw67p66fz9nswkydq15j4a5z5kkiskl0jxps8i27ya1baq0";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "abf152e5f3e97f2fafac028d2cc06c1feb87ffa5";
+      sha256 = "0cp8lznv1b4zhi3wnbjkfxwzhkqd3wbmiy6mwgjanip8l9l3ykws";
+    };
+  }
+  {
+    goPackagePath = "github.com/urfave/cli";
+    fetch = {
+      type = "git";
+      url = "https://github.com/urfave/cli";
+      rev = "0bdeddeeb0f650497d603c4ad7b20cfe685682f6";
+      sha256 = "1ny63c7bfwfrsp7vfkvb4i0xhq4v7yxqnwxa52y4xlfxs4r6v6fg";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/yaml.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/yaml.v2";
+      rev = "a5b47d31c556af34a302ce5d659e6fea44d90de0";
+      sha256 = "0v6l48fshdjrqzyq1kwn22gy7vy434xdr1i0lm3prsf6jbln9fam";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/mesos-exporter.nix b/pkgs/servers/monitoring/prometheus/mesos-exporter.nix
new file mode 100644
index 000000000000..42ff2496df12
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/mesos-exporter.nix
@@ -0,0 +1,26 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "mesos_exporter-${version}";
+  version = "0.1.0";
+  rev = version;
+
+  goPackagePath = "github.com/prometheus/mesos_exporter";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "mesos_exporter";
+    sha256 = "059az73j717gd960g4jigrxnvqrjh9jw1c324xpwaafa0bf10llm";
+  };
+
+  goDeps = ./mesos-exporter_deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Export Mesos metrics to Prometheus";
+    homepage = https://github.com/prometheus/mesos_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/mesos-exporter_deps.nix b/pkgs/servers/monitoring/prometheus/mesos-exporter_deps.nix
new file mode 100644
index 000000000000..e8fdcc95da2f
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/mesos-exporter_deps.nix
@@ -0,0 +1,83 @@
+[
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "59b73b37c1e45995477aae817e4a653c89a858db";
+      sha256 = "1dx22jvhvj34ivpr7gw01fncg9yyx35mbpal4mpgnqka7ajmgjsa";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "fa8ad6fec33561be4280a8f0514318c79d7f6cb6";
+      sha256 = "11a7v1fjzhhwsl128znjcf5v7v6129xjgkdpym2lial4lac1dhm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "b965b613227fddccbfffe13eae360ed3fa822f8d";
+      sha256 = "1p8zsj4r0g61q922khfxpwxhdma2dx4xad1m5qx43mfn28kxngqk";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a";
+      sha256 = "0ajg41h6402big484drvm72wvid1af2sffw0qkzbmpy04lq68ahj";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "6dbab8106ed3ed77359ac85d9cf08e30290df864";
+      sha256 = "1i3g5h2ncdb8b67742kfpid7d0a1jas1pyicglbglwngfmzhpkna";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "c91d8eefde16bd047416409eb56353ea84a186e4";
+      sha256 = "0pj3gzw9b58l72w0rkpn03ayssglmqfmyxghhfad6mh0b49dvj3r";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/glog";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/glog";
+      rev = "fca8c8854093a154ff1eb580aae10276ad6b1b5f";
+      sha256 = "1nr2q0vas0a2f395f4shjxqpas18mjsf8yhgndsav7svngpbbpg8";
+    };
+  }
+  {
+    goPackagePath = "bitbucket.org/ww/goautoneg";
+    fetch = {
+      type = "hg";
+      url = "bitbucket.org/ww/goautoneg";
+      rev = "75cd24fc2f2c2a2088577d12123ddee5f54e0675";
+      sha256 = "19khhn5xhqv1yp7d6k987gh5w5rhrjnp4p0c6fyrd8z6lzz5h9qi";
+    };
+  }
+  {
+    goPackagePath = "github.com/antonlindstrom/mesos_stats";
+    fetch = {
+      type = "git";
+      url = "https://github.com/antonlindstrom/mesos_stats";
+      rev = "0c6ea494c19bedc67ebb85ce3d187ec21050e920";
+      sha256 = "18ggyjf4nyn77gkn16wg9krp4dsphgzdgcr3mdflv6mvbr482ar4";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/minio-exporter/default.nix b/pkgs/servers/monitoring/prometheus/minio-exporter/default.nix
new file mode 100644
index 000000000000..59314f1f282a
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/minio-exporter/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub, fetchpatch }:
+
+buildGoPackage rec {
+  name = "minio-exporter-${version}";
+  version = "0.2.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/joe-pll/minio-exporter";
+
+  src= fetchFromGitHub {
+    inherit rev;
+    owner = "joe-pll";
+    repo = "minio-exporter";
+    sha256 = "1my3ii5s479appiapw8gjzkq1pk62fl7d7if8ljvdj6qw4man6aa";
+  };
+
+  # Required to make 0.2.0 build against latest dependencies
+  # TODO: Remove on update to 0.3.0
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/joe-pll/minio-exporter/commit/50ab89d42322dc3e2696326a9ae4d3f951f646de.patch";
+      sha256 = "0aiixhvb4x8c8abrlf1i4hmca9i6xd6b638a5vfkvawx0q7gxl97";
+    })
+  ];
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "A Prometheus exporter for Minio cloud storage server";
+    homepage = https://github.com/joe-pll/minio-exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ bachp ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/minio-exporter/deps.nix b/pkgs/servers/monitoring/prometheus/minio-exporter/deps.nix
new file mode 100644
index 000000000000..1993975e2bfa
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/minio-exporter/deps.nix
@@ -0,0 +1,174 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/alecthomas/template";
+    fetch = {
+      type = "git";
+      url = "https://github.com/alecthomas/template";
+      rev = "a0175ee3bccc567396460bf5acd36800cb10c49c";
+      sha256 = "0qjgvvh26vk1cyfq9fadyhfgdj36f1iapbmr5xp6zqipldz8ffxj";
+    };
+  }
+  {
+    goPackagePath = "github.com/alecthomas/units";
+    fetch = {
+      type = "git";
+      url = "https://github.com/alecthomas/units";
+      rev = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a";
+      sha256 = "1j65b91qb9sbrml9cpabfrcf07wmgzzghrl7809hjjhrmbzri5bl";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-ini/ini";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-ini/ini";
+      rev = "32e4c1e6bc4e7d0d8451aa6b75200d19e37a536a";
+      sha256 = "0mhgxw5q6b0pryhikx3k4wby7g32rwjjljzihi47lwn34kw5y1qn";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "1e59b77b52bf8e4b449a57e6f79f21226d571845";
+      sha256 = "19bkh81wnp6njg3931wky6hsnnl2d1ig20vfjxpv450sd3k6yys8";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/minio/minio-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/minio/minio-go";
+      rev = "d218e4cb1bfc13dcef0eb5c3e74507a35be0dd3a";
+      sha256 = "0d3am33xaavdffz791qi2s0vnkpjw9vlr5p5g4lw7h5vhmy1sjb4";
+    };
+  }
+  {
+    goPackagePath = "github.com/minio/minio";
+    fetch = {
+      type = "git";
+      url = "https://github.com/minio/minio";
+      rev = "bb73c84b104bc447eb603d63481cdc54b8ab3c83";
+      sha256 = "1gjkgdf59yxfr2a7pl3f7z3iid86zsd85xqxcv1s0d46v7j07iga";
+    };
+  }
+  {
+    goPackagePath = "github.com/mitchellh/go-homedir";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mitchellh/go-homedir";
+      rev = "b8bc1bf767474819792c23f32d8286a45736f1c6";
+      sha256 = "13ry4lylalkh4g2vny9cxwvryslzyzwp9r92z0b10idhdq3wad1q";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "06bc6e01f4baf4ee783ffcd23abfcb0b0f9dfada";
+      sha256 = "0dvv21214sn702kc25y5l0gd9d11358976d3w31fgwx7456mjx26";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "89604d197083d4781071d3c65855d24ecfb0a563";
+      sha256 = "169rdlaf2mk9z4fydz7ajmngyhmf3q1lk96yhvx46bn986x5xkyn";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "b15cd069a83443be3154b719d0cc9fe8117f09fb";
+      sha256 = "1cr45wg2m40bj2za8f32mq09rjlcnk5kfam0h0hr8wcb015k4wxj";
+    };
+  }
+  {
+    goPackagePath = "github.com/sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/sirupsen/logrus";
+      rev = "d682213848ed68c0a260ca37d6dd5ace8423f5ba";
+      sha256 = "0nzyqwzx3k7nqfq8q7yv32gaf3ymq3bpwhkmw1hj2zakq5a93d8x";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "a6600008915114d9c087fad9f03d75087b1a74df";
+      sha256 = "099vyf8133bjwaqcv377d9akam3j5xwamwqrihmjhvzbvqs649yc";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec";
+      sha256 = "0bdwdxy2gz48icnh023r5fga3z4x6c8gry8jlfjqr5w12y3s281g";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "2c42eef0765b9837fbdab12011af7830f55f88f0";
+      sha256 = "0gj9nwryyzf9rn33gl3zm6rxvg1zhrhwi36akipqj37x4g86h3gz";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "e19ae1496984b1c655b8044a65c0300a3c878dd3";
+      sha256 = "1cvnnx8nwx5c7gr6ajs7sldhbqh52n7h6fsa3i21l2lhx6xrsh4w";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/alecthomas/kingpin.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/alecthomas/kingpin.v2";
+      rev = "947dcec5ba9c011838740e680966fd7087a71d0d";
+      sha256 = "0mndnv3hdngr3bxp7yxfd47cas4prv98sqw534mx7vp38gd88n5r";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/mysqld-exporter.nix b/pkgs/servers/monitoring/prometheus/mysqld-exporter.nix
new file mode 100644
index 000000000000..9180a5113492
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/mysqld-exporter.nix
@@ -0,0 +1,24 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "mysqld_exporter-${version}";
+  version = "0.10.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/prometheus/mysqld_exporter";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "mysqld_exporter";
+    sha256 = "1133bgyp5vljz2qvfh0qzq8h8bkc8vci3jnmbr633bh3jpaqm2py";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Prometheus exporter for MySQL server metrics";
+    homepage = https://github.com/prometheus/mysqld_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/nginx-exporter.nix b/pkgs/servers/monitoring/prometheus/nginx-exporter.nix
new file mode 100644
index 000000000000..5c5042b6c7cd
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/nginx-exporter.nix
@@ -0,0 +1,25 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "nginx_exporter-${version}";
+  version = "0.1.0";
+
+  goPackagePath = "github.com/discordianfish/nginx_exporter";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner = "discordianfish";
+    repo = "nginx_exporter";
+    sha256 = "1xwxnvkzslaj44r44ag24a9qfzjdxwz67hhpkdq42193zqpnlim7";
+  };
+
+  goDeps = ./nginx-exporter_deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Metrics relay from nginx stats to Prometheus";
+    homepage = https://github.com/discordianfish/nginx_exporter;
+    license = licenses.mit;
+    maintainers = with maintainers; [ benley fpletz willibutz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/nginx-exporter_deps.nix b/pkgs/servers/monitoring/prometheus/nginx-exporter_deps.nix
new file mode 100644
index 000000000000..2fa60de5b493
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/nginx-exporter_deps.nix
@@ -0,0 +1,119 @@
+[
+  {
+    goPackagePath = "github.com/alecthomas/template";
+    fetch = {
+      type = "git";
+      url = "https://github.com/alecthomas/template";
+      rev = "a0175ee3bccc567396460bf5acd36800cb10c49c";
+      sha256 = "0qjgvvh26vk1cyfq9fadyhfgdj36f1iapbmr5xp6zqipldz8ffxj";
+    };
+  }
+  {
+    goPackagePath = "github.com/alecthomas/units";
+    fetch = {
+      type = "git";
+      url = "https://github.com/alecthomas/units";
+      rev = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a";
+      sha256 = "1j65b91qb9sbrml9cpabfrcf07wmgzzghrl7809hjjhrmbzri5bl";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "3a771d992973f24aa725d07868b467d1ddfceafb";
+      sha256 = "1l2lns4f5jabp61201sh88zf3b0q793w4zdgp9nll7mmfcxxjif3";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "b4deda0973fb4c70b50d226b1af49f3da59f5265";
+      sha256 = "0ya4ha7m20bw048m1159ppqzlvda4x0vdprlbk5sdgmy74h3xcdq";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "82f5ff156b29e276022b1a958f7d385870fb9814";
+      sha256 = "111j329yrlgvh73dm80gawwxsh9dgjkw74254kyj5c2rfmra7znz";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "d811d2e9bf898806ecfb6ef6296774b13ffc314c";
+      sha256 = "0r4067r4ysmljksqw3awcxx5qplqhykahc5igdzgkky7i4bvaik1";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e";
+      sha256 = "0x128p15h35mgwqxkigfkk1lfrcz9g697ahl8v6xp9kwvcqvjrrf";
+    };
+  }
+  {
+    goPackagePath = "github.com/sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/sirupsen/logrus";
+      rev = "778f2e774c725116edbc3d039dc0dfc1cc62aae8";
+      sha256 = "0drlrl192k4qkpcf1b6nw2qlixply31x2jhcckjzl3hn4mzwi6nf";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "ae8bce0030810cf999bb2b9868ae5c7c58e6343b";
+      sha256 = "0aihwcf0g8mq1sb96pwhpgvwxlf862pdhsfr7mdppz7bii4i9shw";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "78d5f264b493f125018180c204871ecf58a2dce1";
+      sha256 = "0x23n60wskys39dwybz5za77ldky9i518kp58ragpd5528kcc68s";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/alecthomas/kingpin.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/alecthomas/kingpin.v2";
+      rev = "947dcec5ba9c011838740e680966fd7087a71d0d";
+      sha256 = "0mndnv3hdngr3bxp7yxfd47cas4prv98sqw534mx7vp38gd88n5r";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/node-exporter.nix b/pkgs/servers/monitoring/prometheus/node-exporter.nix
new file mode 100644
index 000000000000..497f20ac55ed
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/node-exporter.nix
@@ -0,0 +1,27 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "node_exporter-${version}";
+  version = "0.15.2";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/prometheus/node_exporter";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "node_exporter";
+    sha256 = "1vxbkps80ba8c0ndawijg07am5gyc8y49h8fd0ky5h05zmkp25qv";
+  };
+
+  # FIXME: megacli test fails
+  doCheck = false;
+
+  meta = with stdenv.lib; {
+    description = "Prometheus exporter for machine metrics";
+    homepage = https://github.com/prometheus/node_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/openvpn-exporter-deps.nix b/pkgs/servers/monitoring/prometheus/openvpn-exporter-deps.nix
new file mode 100644
index 000000000000..93aae1b867e9
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/openvpn-exporter-deps.nix
@@ -0,0 +1,66 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "748d386b5c1ea99658fd69fe9f03991ce86a90c1";
+      sha256 = "0xm0is6sj6r634vrfx85ir0gd9h1xxk25fgc5z07zrjp19f5wqp5";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "94ff84a9a6ebb5e6eb9172897c221a64df3443bc";
+      sha256 = "188xwc13ml51i29fhp8bz4a7ncmk0lvdw3nnwr56k2l36pp1swil";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "6f3806018612930941127f2a7c6c453ba2c527d2";
+      sha256 = "1413ibprinxhni51p0755dp57r9wvbw7xgj9nmdaxmhzlqhc86j4";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "3e6a7635bac6573d43f49f97b47eb9bda195dba8";
+      sha256 = "1q4nwm9lf4jd90z08s6gz8j1zzrk2jn9vpw49xdb8mwxmhv13xgm";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "e645f4e5aaa8506fc71d6edbc5c4ff02c04c46f2";
+      sha256 = "18hwygbawbqilz7h8fl25xpbciwalkslb4igqn4cr9d8sqp7d3np";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/openvpn-exporter.nix b/pkgs/servers/monitoring/prometheus/openvpn-exporter.nix
new file mode 100644
index 000000000000..eac962f75606
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/openvpn-exporter.nix
@@ -0,0 +1,25 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "openvpn_exporter-unstable-${version}";
+  version = "2017-05-15";
+  rev = "a2a179a222144fa9a10030367045f075375a2803";
+
+  goPackagePath = "github.com/kumina/openvpn_exporter";
+
+  src = fetchFromGitHub {
+    owner = "kumina";
+    repo = "openvpn_exporter";
+    inherit rev;
+    sha256 = "1cjx7ascf532a20wwzrsx3qqs6dr04jyf700s3jvlvhhhx43l8m4";
+  };
+
+  goDeps = ./openvpn-exporter-deps.nix;
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Prometheus exporter for OpenVPN";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ fpletz ];
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/postfix-exporter-deps.nix b/pkgs/servers/monitoring/prometheus/postfix-exporter-deps.nix
new file mode 100644
index 000000000000..07bedaba9f36
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/postfix-exporter-deps.nix
@@ -0,0 +1,66 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "3a771d992973f24aa725d07868b467d1ddfceafb";
+      sha256 = "1l2lns4f5jabp61201sh88zf3b0q793w4zdgp9nll7mmfcxxjif3";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "b4deda0973fb4c70b50d226b1af49f3da59f5265";
+      sha256 = "0ya4ha7m20bw048m1159ppqzlvda4x0vdprlbk5sdgmy74h3xcdq";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "82f5ff156b29e276022b1a958f7d385870fb9814";
+      sha256 = "111j329yrlgvh73dm80gawwxsh9dgjkw74254kyj5c2rfmra7znz";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "d811d2e9bf898806ecfb6ef6296774b13ffc314c";
+      sha256 = "0r4067r4ysmljksqw3awcxx5qplqhykahc5igdzgkky7i4bvaik1";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e";
+      sha256 = "0x128p15h35mgwqxkigfkk1lfrcz9g697ahl8v6xp9kwvcqvjrrf";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/postfix-exporter.nix b/pkgs/servers/monitoring/prometheus/postfix-exporter.nix
new file mode 100644
index 000000000000..97df26aea4e5
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/postfix-exporter.nix
@@ -0,0 +1,56 @@
+{ stdenv, buildGoPackage, fetchFromGitHub, systemd, makeWrapper
+, withSystemdSupport ? true }:
+
+with stdenv.lib;
+
+buildGoPackage rec {
+  name = "postfix_exporter-${version}";
+  version = "0.1.2";
+
+  goPackagePath = "github.com/kumina/postfix_exporter";
+
+  src = fetchFromGitHub {
+    owner = "kumina";
+    repo = "postfix_exporter";
+    rev = version;
+    sha256 = "1b9ib3scxni6hlw55wv6f0z1xfn27l0p29as24f71rs70pyzy4hm";
+  };
+
+  nativeBuildInputs = optional withSystemdSupport makeWrapper;
+  buildInputs = optional withSystemdSupport systemd;
+  buildFlags = optional (!withSystemdSupport) "-tags nosystemd";
+
+  goDeps = ./postfix-exporter-deps.nix;
+  extraSrcs = optionals withSystemdSupport [
+    {
+      goPackagePath = "github.com/coreos/go-systemd";
+      src = fetchFromGitHub {
+        owner = "coreos";
+        repo = "go-systemd";
+        rev = "d1b7d058aa2adfc795ad17ff4aaa2bc64ec11c78";
+        sha256 = "1nz3v1b90hnmj2vjjwq96pr6psxlndqjyd30v9sgiwygzb7db9mv";
+      };
+    }
+    {
+      goPackagePath = "github.com/coreos/pkg";
+      src = fetchFromGitHub {
+        owner = "coreos";
+        repo = "pkg";
+        rev = "97fdf19511ea361ae1c100dd393cc47f8dcfa1e1";
+        sha256 = "1srn87wih25l09f75483hnxsr8fc6rq3bk7w1x8125ym39p6mg21";
+      };
+    }
+  ];
+
+  postInstall = optionalString withSystemdSupport ''
+    wrapProgram $bin/bin/postfix_exporter \
+      --prefix LD_LIBRARY_PATH : "${systemd.lib}/lib"
+  '';
+
+  meta = {
+    inherit (src.meta) homepage;
+    description = "A Prometheus exporter for Postfix";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ willibutz ];
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/prom2json.nix b/pkgs/servers/monitoring/prometheus/prom2json.nix
new file mode 100644
index 000000000000..788fe8633967
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/prom2json.nix
@@ -0,0 +1,26 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "prom2json-${version}";
+  version = "0.1.0";
+  rev = "${version}";
+
+  goPackagePath = "github.com/prometheus/prom2json";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "prom2json";
+    sha256 = "0wwh3mz7z81fwh8n78sshvj46akcgjhxapjgfic5afc4nv926zdl";
+  };
+
+  goDeps = ./prom2json_deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Tool to scrape a Prometheus client and dump the result as JSON";
+    homepage = https://github.com/prometheus/prom2json;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/prom2json_deps.nix b/pkgs/servers/monitoring/prometheus/prom2json_deps.nix
new file mode 100644
index 000000000000..20cabe3d3857
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/prom2json_deps.nix
@@ -0,0 +1,38 @@
+[
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "59b73b37c1e45995477aae817e4a653c89a858db";
+      sha256 = "1dx22jvhvj34ivpr7gw01fncg9yyx35mbpal4mpgnqka7ajmgjsa";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "fa8ad6fec33561be4280a8f0514318c79d7f6cb6";
+      sha256 = "11a7v1fjzhhwsl128znjcf5v7v6129xjgkdpym2lial4lac1dhm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a";
+      sha256 = "0ajg41h6402big484drvm72wvid1af2sffw0qkzbmpy04lq68ahj";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "6dbab8106ed3ed77359ac85d9cf08e30290df864";
+      sha256 = "1i3g5h2ncdb8b67742kfpid7d0a1jas1pyicglbglwngfmzhpkna";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/pushgateway.nix b/pkgs/servers/monitoring/prometheus/pushgateway.nix
new file mode 100644
index 000000000000..6509f55d46ed
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/pushgateway.nix
@@ -0,0 +1,43 @@
+{ stdenv, go, buildGoPackage, go-bindata, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "pushgateway-${version}";
+  version = "0.4.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/prometheus/pushgateway";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "prometheus";
+    repo = "pushgateway";
+    sha256 = "19hsv42addcx4dsjdbh64y7ggjvaaay9gag0342gz7gyl9sr719f";
+  };
+
+  buildInputs = [ go-bindata ];
+
+  preBuild = ''
+  (
+    cd "go/src/$goPackagePath"
+    go-bindata ./resources/
+  )
+  '';
+
+  buildFlagsArray = ''
+    -ldflags=
+        -X main.buildVersion=${version}
+        -X main.buildRev=${rev}
+        -X main.buildBranch=${rev}
+        -X main.buildUser=nix@nixpkgs
+        -X main.buildDate=19700101-00:00:00
+        -X main.goVersion=${stdenv.lib.getVersion go}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Allows ephemeral and batch jobs to expose metrics to Prometheus";
+    homepage = https://github.com/prometheus/pushgateway;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley fpletz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/rabbitmq-exporter.nix b/pkgs/servers/monitoring/prometheus/rabbitmq-exporter.nix
new file mode 100644
index 000000000000..34120ad3fdae
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/rabbitmq-exporter.nix
@@ -0,0 +1,26 @@
+# This file was generated by https://github.com/kamilchm/go2nix v2.0-dev
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "rabbitmq_exporter-${version}";
+  version = "0.25.2";
+
+  goPackagePath = "github.com/kbudde/rabbitmq_exporter";
+
+  src = fetchFromGitHub {
+    owner = "kbudde";
+    repo = "rabbitmq_exporter";
+    rev = "8238c5d9ad509dab94e631cdecf3d75155fbdee4";
+    sha256 = "1zb21jms2wlmiw5vhk1wyhv0xrv5a9y08y9q6x92hv727kjqjr6w";
+  };
+
+  goDeps = ./rabbitmq-exporter_deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Prometheus exporter for RabbitMQ";
+    homepage = https://github.com/kbudde/rabbitmq_exporter;
+    license = licenses.mit;
+    maintainers = with maintainers; [ ocharles ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/rabbitmq-exporter_deps.nix b/pkgs/servers/monitoring/prometheus/rabbitmq-exporter_deps.nix
new file mode 100644
index 000000000000..7a15a6a7b68c
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/rabbitmq-exporter_deps.nix
@@ -0,0 +1,165 @@
+# This file was generated by https://github.com/kamilchm/go2nix v2.0-dev
+[
+  {
+    goPackagePath = "github.com/Sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Sirupsen/logrus";
+      rev = "95cd2b9c79aa5e72ab0bc69b7ccc2be15bf850f6";
+      sha256 = "1rkkhl68iw523bwxmp2prdrp8pk62xfp52wifzvbmqf8v1svwsqv";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/cenk/backoff";
+    fetch = {
+      type = "git";
+      url = "https://github.com/cenk/backoff";
+      rev = "61153c768f31ee5f130071d08fc82b85208528de";
+      sha256 = "08x77mgb9zsj047n74rx6c16jjx985lmy4s6fl58mdgxgxjv54y5";
+    };
+  }
+  {
+    goPackagePath = "github.com/fsouza/go-dockerclient";
+    fetch = {
+      type = "git";
+      url = "https://github.com/fsouza/go-dockerclient";
+      rev = "1d4f4ae73768d3ca16a6fb964694f58dc5eba601";
+      sha256 = "1s3m8jq8z1cm5rkn7dmjacf38n6ihkkzbdfang2aa2cgs5wl28y0";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "1e59b77b52bf8e4b449a57e6f79f21226d571845";
+      sha256 = "19bkh81wnp6njg3931wky6hsnnl2d1ig20vfjxpv450sd3k6yys8";
+    };
+  }
+  {
+    goPackagePath = "github.com/kbudde/gobert";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kbudde/gobert";
+      rev = "a6daecb9ddeb548b7cfb3f5ac9deef9ded522730";
+      sha256 = "06g036w4dny8wdjwvprjjcdh0vx851qphgrvilrn5lghv3jdr29z";
+    };
+  }
+  {
+    goPackagePath = "github.com/kylelemons/godebug";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kylelemons/godebug";
+      rev = "d65d576e9348f5982d7f6d83682b694e731a45c6";
+      sha256 = "0bc8j9kwkp0hrsz0sm7hav7cm5jp9d6ql8r2b3mz78xb1g65xhbc";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "3247c84500bff8d9fb6d579d800f20b3e091582c";
+      sha256 = "12hcych25wf725zxdkpnyx4wa0gyxl8v4m8xmhdmmaki9bbmqd0d";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/errors";
+      rev = "645ef00459ed84a119197bfb8d8205042c6df63d";
+      sha256 = "001i6n71ghp2l6kdl3qq1v2vmghcz3kicv9a5wgcihrzigm75pp5";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "c5b7fccd204277076155f10851dad72b76a49317";
+      sha256 = "1xqny3147g12n4j03kxm8s9mvdbs3ln6i56c655mybrn9jjy48kd";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "2e54d0b93cba2fd133edc32211dcc32c06ef72ca";
+      sha256 = "14kn5w7imcxxlfdqxl21fsnlf1ms7200g3ldy29hwamldv8qlm7j";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "a6e9df898b1336106c743392c48ee0b71f5c4efa";
+      sha256 = "0zyprdp9bnpywcb6b9dzwyiji60mgf0s9wnw98zndfg3xrgnkasz";
+    };
+  }
+  {
+    goPackagePath = "github.com/streadway/amqp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/streadway/amqp";
+      rev = "ff791c2d22d3f1588b4e2cc71a9fba5e1da90654";
+      sha256 = "1drridn4k1n7qy82msvw9r18w4pmrah1nip36wixz098nzalz55x";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "94eea52f7b742c7cbe0b03b22f0c4c8631ece122";
+      sha256 = "095zyvjb0m2pz382500miqadhk7w3nis8z3j941z8cq4rdafijvi";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "a8b9294777976932365dabb6640cf1468d95c70f";
+      sha256 = "112v83jfwd1brwaanjijvb7da4dx1iqk8b4bf9ahx0hvir56c2g8";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "8b4580aae2a0dd0c231a45d3ccb8434ff533b840";
+      sha256 = "1w66xqnpkskvj22a3f841qg4rgf0lzcrxp8678s6n07yw8qdh92p";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/ory-am/dockertest.v3";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/ory-am/dockertest.v3";
+      rev = "a7951f7a8442f0e70d36e499ed4d744f00af2963";
+      sha256 = "13qv0vl79m2wirhbjs0k2a3cjl6ib7sw6rg98v95xxpn8r39ijzw";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/snmp-exporter.nix b/pkgs/servers/monitoring/prometheus/snmp-exporter.nix
new file mode 100644
index 000000000000..9692354ad8a8
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/snmp-exporter.nix
@@ -0,0 +1,27 @@
+{ stdenv, lib, go, buildGoPackage, fetchFromGitHub, net_snmp }:
+
+buildGoPackage rec {
+  name = "snmp_exporter-${version}";
+  version = "0.11.0";
+
+  goPackagePath = "github.com/prometheus/snmp_exporter";
+
+  src = fetchFromGitHub {
+    owner = "prometheus";
+    repo = "snmp_exporter";
+    rev = "v${version}";
+    sha256 = "027p96jzhq9l7m3s5qxxg3rqp14pai7q66d3ppin19lg7al11c9x";
+  };
+
+  buildInputs = [ net_snmp ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "SNMP Exporter for Prometheus";
+    homepage = https://github.com/prometheus/snmp_exporter;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ oida willibutz ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/statsd-bridge.nix b/pkgs/servers/monitoring/prometheus/statsd-bridge.nix
new file mode 100644
index 000000000000..f4d9f5a85037
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/statsd-bridge.nix
@@ -0,0 +1,26 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "statsd_exporter-${version}";
+  version = "0.4.0";
+  rev = version;
+
+  goPackagePath = "github.com/prometheus/statsd_bridge";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner = "prometheus";
+    repo = "statsd_exporter";
+    sha256 = "1w11n7g663g7d7mbf6jfzcqmcm9rhaxy52bg0rqnad9v0rs5qxr6";
+  };
+
+  goDeps = ./statsd-bridge_deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Receives StatsD-style metrics and exports them to Prometheus";
+    homepage = https://github.com/prometheus/statsd_bridge;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ benley ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/statsd-bridge_deps.nix b/pkgs/servers/monitoring/prometheus/statsd-bridge_deps.nix
new file mode 100644
index 000000000000..fd11ab5a7eab
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/statsd-bridge_deps.nix
@@ -0,0 +1,74 @@
+[
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "59b73b37c1e45995477aae817e4a653c89a858db";
+      sha256 = "1dx22jvhvj34ivpr7gw01fncg9yyx35mbpal4mpgnqka7ajmgjsa";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "fa8ad6fec33561be4280a8f0514318c79d7f6cb6";
+      sha256 = "11a7v1fjzhhwsl128znjcf5v7v6129xjgkdpym2lial4lac1dhm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "b965b613227fddccbfffe13eae360ed3fa822f8d";
+      sha256 = "1p8zsj4r0g61q922khfxpwxhdma2dx4xad1m5qx43mfn28kxngqk";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a";
+      sha256 = "0ajg41h6402big484drvm72wvid1af2sffw0qkzbmpy04lq68ahj";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "6dbab8106ed3ed77359ac85d9cf08e30290df864";
+      sha256 = "1i3g5h2ncdb8b67742kfpid7d0a1jas1pyicglbglwngfmzhpkna";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "c91d8eefde16bd047416409eb56353ea84a186e4";
+      sha256 = "0pj3gzw9b58l72w0rkpn03ayssglmqfmyxghhfad6mh0b49dvj3r";
+    };
+  }
+  {
+    goPackagePath = "bitbucket.org/ww/goautoneg";
+    fetch = {
+      type = "hg";
+      url = "bitbucket.org/ww/goautoneg";
+      rev = "75cd24fc2f2c2a2088577d12123ddee5f54e0675";
+      sha256 = "19khhn5xhqv1yp7d6k987gh5w5rhrjnp4p0c6fyrd8z6lzz5h9qi";
+    };
+  }
+  {
+    goPackagePath = "github.com/howeyc/fsnotify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/fsnotify/fsnotify";
+      rev = "ea925a0a47d225b2ca7f9932b01d2ed4f3ec74f6";
+      sha256 = "15wqjpkfzsxnaxbz6y4r91hw6812g3sc4ipagxw1bya9klbnkdc9";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/prometheus/surfboard-exporter.nix b/pkgs/servers/monitoring/prometheus/surfboard-exporter.nix
new file mode 100644
index 000000000000..13e17d0b0192
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/surfboard-exporter.nix
@@ -0,0 +1,23 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "surfboard_exporter-${version}";
+  version = "2.0.0";
+
+  goPackagePath = "github.com/ipstatic/surfboard_exporter";
+
+  src = fetchFromGitHub {
+    rev = version;
+    owner = "ipstatic";
+    repo = "surfboard_exporter";
+    sha256 = "11qms26648nwlwslnaflinxcr5rnp55s908rm1qpnbz0jnxf5ipw";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Arris Surfboard signal metrics exporter";
+    homepage = https://github.com/ipstatic/surfboard_exporter;
+    license = licenses.mit;
+    maintainers = with maintainers; [ disassembler ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix b/pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix
new file mode 100644
index 000000000000..44a670b95ab4
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/unifi-exporter/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "unifi-exporter-${version}";
+  version = "0.4.0+git1";
+  rev = "9a4e69fdea91dd0033bda4842998d751b40a6130";
+
+  goPackagePath = "github.com/mdlayher/unifi_exporter";
+
+  src= fetchFromGitHub {
+    inherit rev;
+    owner = "mdlayher";
+    repo = "unifi_exporter";
+    sha256 = "08zqvwvdqnc301f8jfh7bdvc138szw6xszx884b2v8w2x38w3rmn";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Prometheus exporter that exposes metrics from a Ubiquiti UniFi Controller and UniFi devices";
+    homepage = https://github.com/mdlayher/unifi_exporter;
+    license = licenses.mit;
+    maintainers = with maintainers; [ bachp ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/varnish-exporter.nix b/pkgs/servers/monitoring/prometheus/varnish-exporter.nix
new file mode 100644
index 000000000000..d83aa5b46658
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/varnish-exporter.nix
@@ -0,0 +1,34 @@
+# This file was generated by go2nix.
+{ stdenv, lib, buildGoPackage, fetchFromGitHub, makeWrapper, varnish }:
+
+buildGoPackage rec {
+  name = "prometheus_varnish_exporter-${version}";
+  version = "1.4";
+
+  goPackagePath = "github.com/jonnenauha/prometheus_varnish_exporter";
+
+  src = fetchFromGitHub {
+    owner = "jonnenauha";
+    repo = "prometheus_varnish_exporter";
+    rev = version;
+    sha256 = "12gd09858zlhn8gkkchfwxv0ca2r72s18wrsz0agfr8pd1gxqh6j";
+  };
+
+  goDeps = ./varnish-exporter_deps.nix;
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  postInstall = ''
+    wrapProgram $bin/bin/prometheus_varnish_exporter \
+      --prefix PATH : "${varnish}/bin"
+  '';
+
+  doCheck = true;
+
+  meta = {
+    homepage = https://github.com/jonnenauha/prometheus_varnish_exporter;
+    description = "Varnish exporter for Prometheus";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ MostAwesomeDude willibutz ];
+  };
+}
diff --git a/pkgs/servers/monitoring/prometheus/varnish-exporter_deps.nix b/pkgs/servers/monitoring/prometheus/varnish-exporter_deps.nix
new file mode 100644
index 000000000000..19ff1e9aa560
--- /dev/null
+++ b/pkgs/servers/monitoring/prometheus/varnish-exporter_deps.nix
@@ -0,0 +1,65 @@
+[
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "3a771d992973f24aa725d07868b467d1ddfceafb";
+      sha256 = "1l2lns4f5jabp61201sh88zf3b0q793w4zdgp9nll7mmfcxxjif3";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "b4deda0973fb4c70b50d226b1af49f3da59f5265";
+      sha256 = "0ya4ha7m20bw048m1159ppqzlvda4x0vdprlbk5sdgmy74h3xcdq";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "82f5ff156b29e276022b1a958f7d385870fb9814";
+      sha256 = "111j329yrlgvh73dm80gawwxsh9dgjkw74254kyj5c2rfmra7znz";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c";
+      sha256 = "19y4ywsivhpxj7ikf2j0gm9k3cmyw37qcbfi78n526jxcc7kw998";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "d811d2e9bf898806ecfb6ef6296774b13ffc314c";
+      sha256 = "0r4067r4ysmljksqw3awcxx5qplqhykahc5igdzgkky7i4bvaik1";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e";
+      sha256 = "0x128p15h35mgwqxkigfkk1lfrcz9g697ahl8v6xp9kwvcqvjrrf";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/riemann-dash/Gemfile b/pkgs/servers/monitoring/riemann-dash/Gemfile
index 6b770b708185..aecd1b9508c9 100644
--- a/pkgs/servers/monitoring/riemann-dash/Gemfile
+++ b/pkgs/servers/monitoring/riemann-dash/Gemfile
@@ -1,3 +1,3 @@
 source 'https://rubygems.org'
 
-gem "riemann-dash", "0.2.11"
+gem "riemann-dash", "0.2.12"
diff --git a/pkgs/servers/monitoring/riemann-dash/Gemfile.lock b/pkgs/servers/monitoring/riemann-dash/Gemfile.lock
index a5445b953c47..1bfd80a897d3 100644
--- a/pkgs/servers/monitoring/riemann-dash/Gemfile.lock
+++ b/pkgs/servers/monitoring/riemann-dash/Gemfile.lock
@@ -3,25 +3,28 @@ GEM
   specs:
     erubis (2.7.0)
     multi_json (1.3.6)
-    rack (1.6.1)
+    rack (1.6.4)
     rack-protection (1.5.3)
       rack
-    riemann-dash (0.2.11)
+    riemann-dash (0.2.12)
       erubis (>= 2.7.0)
       multi_json (= 1.3.6)
       sass (>= 3.1.14)
       sinatra (~> 1.4.5)
       webrick (~> 1.3.1)
-    sass (3.4.14)
-    sinatra (1.4.6)
-      rack (~> 1.4)
+    sass (3.4.22)
+    sinatra (1.4.7)
+      rack (~> 1.5)
       rack-protection (~> 1.4)
       tilt (>= 1.3, < 3)
-    tilt (2.0.1)
+    tilt (2.0.5)
     webrick (1.3.1)
 
 PLATFORMS
   ruby
 
 DEPENDENCIES
-  riemann-dash (= 0.2.11)
+  riemann-dash (= 0.2.12)
+
+BUNDLED WITH
+   1.11.2
diff --git a/pkgs/servers/monitoring/riemann-dash/default.nix b/pkgs/servers/monitoring/riemann-dash/default.nix
index 1afcd81d9be0..2218edabe06b 100644
--- a/pkgs/servers/monitoring/riemann-dash/default.nix
+++ b/pkgs/servers/monitoring/riemann-dash/default.nix
@@ -1,8 +1,14 @@
-{ bundlerEnv }:
+{ bundlerEnv, lib, ruby }:
 
 bundlerEnv {
-  name = "riemann-dash-0.2.9";
-  gemfile = ./Gemfile;
-  lockfile = ./Gemfile.lock;
-  gemset = ./gemset.nix;
+  inherit ruby;
+  pname = "riemann-dash";
+  gemdir = ./.;
+
+  meta = with lib; {
+    description = "A javascript, websockets-powered dashboard for Riemann";
+    homepage = https://github.com/riemann/riemann-dash;
+    license = licenses.mit;
+    platforms = platforms.unix;
+  };
 }
diff --git a/pkgs/servers/monitoring/riemann-dash/gemset.nix b/pkgs/servers/monitoring/riemann-dash/gemset.nix
index b98fd452f1af..8a4d3ba58cb1 100644
--- a/pkgs/servers/monitoring/riemann-dash/gemset.nix
+++ b/pkgs/servers/monitoring/riemann-dash/gemset.nix
@@ -1,80 +1,71 @@
 {
-  "erubis" = {
-    version = "2.7.0";
+  erubis = {
     source = {
-      type = "gem";
       sha256 = "1fj827xqjs91yqsydf0zmfyw9p4l2jz5yikg3mppz6d7fi8kyrb3";
+      type = "gem";
     };
+    version = "2.7.0";
   };
-  "multi_json" = {
-    version = "1.3.6";
+  multi_json = {
     source = {
-      type = "gem";
       sha256 = "0q2zjfvd2ibds9g9nzf2p1b47fc1wqliwfywv5pw85w15lmy91yr";
+      type = "gem";
     };
+    version = "1.3.6";
   };
-  "rack" = {
-    version = "1.6.1";
+  rack = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "09bs295yq6csjnkzj7ncj50i6chfxrhmzg1pk6p0vd2lb9ac8pj5";
       type = "gem";
-      sha256 = "0f73v6phkwczl1sfv0wgdwsnlsg364bhialbnfkg2dnxhh57l0gl";
     };
+    version = "1.6.4";
   };
-  "rack-protection" = {
-    version = "1.5.3";
+  rack-protection = {
+    dependencies = ["rack"];
     source = {
-      type = "gem";
       sha256 = "0cvb21zz7p9wy23wdav63z5qzfn4nialik22yqp6gihkgfqqrh5r";
+      type = "gem";
     };
-    dependencies = [
-      "rack"
-    ];
+    version = "1.5.3";
   };
-  "riemann-dash" = {
-    version = "0.2.11";
+  riemann-dash = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1y2vh9vcl21b6k2wqgz1y8bbcrl07r43s6q2vkgp35z1b28xcszy";
       type = "gem";
-      sha256 = "1vzb75hf1xy7ssil7fp9z7z51vh79ba22x56ific7f1kcb21lzk7";
     };
-    dependencies = [
-      "erubis"
-      "multi_json"
-      "sass"
-      "sinatra"
-      "webrick"
-    ];
+    version = "0.2.12";
   };
-  "sass" = {
-    version = "3.4.14";
+  sass = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0dkj6v26fkg1g0majqswwmhxva7cd6p3psrhdlx93qal72dssywy";
       type = "gem";
-      sha256 = "0x2mg6pid87s4ddvv6xnxfzwgy72pjmkm461pav92ngqnngx2ggk";
     };
+    version = "3.4.22";
   };
-  "sinatra" = {
-    version = "1.4.6";
+  sinatra = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1b81kbr65mmcl9cdq2r6yc16wklyp798rxkgmm5pr9fvsj7jwmxp";
       type = "gem";
-      sha256 = "1hhmwqc81ram7lfwwziv0z70jh92sj1m7h7s9fr0cn2xq8mmn8l7";
     };
-    dependencies = [
-      "rack"
-      "rack-protection"
-      "tilt"
-    ];
+    version = "1.4.7";
   };
-  "tilt" = {
-    version = "2.0.1";
+  tilt = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0lgk8bfx24959yq1cn55php3321wddw947mgj07bxfnwyipy9hqf";
       type = "gem";
-      sha256 = "1qc1k2r6whnb006m10751dyz3168cq72vj8mgp5m2hpys8n6xp3k";
     };
+    version = "2.0.5";
   };
-  "webrick" = {
-    version = "1.3.1";
+  webrick = {
     source = {
-      type = "gem";
       sha256 = "0s42mxihcl2bx0h9q0v2syl70qndydfkl39a06h9il17p895ya8g";
+      type = "gem";
     };
+    version = "1.3.1";
   };
 }
\ No newline at end of file
diff --git a/pkgs/servers/monitoring/riemann/default.nix b/pkgs/servers/monitoring/riemann/default.nix
index 132275a56e09..6eb4a3dfe9af 100644
--- a/pkgs/servers/monitoring/riemann/default.nix
+++ b/pkgs/servers/monitoring/riemann/default.nix
@@ -1,19 +1,27 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, makeWrapper, jre }:
 
 stdenv.mkDerivation rec {
   name = "riemann-${version}";
-  version = "0.2.9";
+  version = "0.3.1";
 
   src = fetchurl {
-    url = "http://aphyr.com/riemann/${name}.tar.bz2";
-    sha256 = "10zz92sg9ak8g7xsfc05p4kic6hzwj7nqpkjgsd8f7f3slvfjqw3";
+    url = "https://github.com/riemann/riemann/releases/download/${version}/${name}.tar.bz2";
+    sha256 = "0lc3qmwb33jjw2g64j8inqpr7krjmpjwfdmypdssvjy84acpkyal";
   };
 
+  nativeBuildInputs = [ makeWrapper ];
+
   phases = [ "unpackPhase" "installPhase" ];
 
   installPhase = ''
-    mkdir -p $out/share/java
+    substituteInPlace bin/riemann --replace '$top/lib/riemann.jar' "$out/share/java/riemann.jar"
+
+    mkdir -p $out/share/java $out/bin $out/etc
     mv lib/riemann.jar $out/share/java/
+    mv bin/riemann $out/bin/
+    mv etc/riemann.config $out/etc/
+
+    wrapProgram "$out/bin/riemann" --prefix PATH : "${jre}/bin"
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/servers/monitoring/sensu/Gemfile b/pkgs/servers/monitoring/sensu/Gemfile
index ebee9f257219..3f570024febb 100644
--- a/pkgs/servers/monitoring/sensu/Gemfile
+++ b/pkgs/servers/monitoring/sensu/Gemfile
@@ -1,2 +1,13 @@
 source 'https://rubygems.org'
+
 gem 'sensu'
+
+# integration
+gem 'sensu-plugins-influxdb'
+
+# checks
+gem 'sensu-plugins-http'
+gem 'sensu-plugins-disk-checks'
+gem 'sensu-plugins-logs'
+gem 'sensu-plugins-systemd'
+# gem 'sensu-plugins-process-checks'
diff --git a/pkgs/servers/monitoring/sensu/Gemfile.lock b/pkgs/servers/monitoring/sensu/Gemfile.lock
index 9f58be03b621..d12e17130b08 100644
--- a/pkgs/servers/monitoring/sensu/Gemfile.lock
+++ b/pkgs/servers/monitoring/sensu/Gemfile.lock
@@ -1,75 +1,142 @@
 GEM
   remote: https://rubygems.org/
   specs:
-    amq-protocol (1.9.2)
-    amqp (1.5.0)
-      amq-protocol (>= 1.9.2)
+    amq-protocol (2.0.1)
+    amqp (1.6.0)
+      amq-protocol (>= 2.0.1)
       eventmachine
-    async_sinatra (1.0.0)
-      rack (>= 1.4.1)
-      sinatra (>= 1.3.2)
-    childprocess (0.5.3)
+    aws-sdk (2.10.34)
+      aws-sdk-resources (= 2.10.34)
+    aws-sdk-core (2.10.34)
+      aws-sigv4 (~> 1.0)
+      jmespath (~> 1.0)
+    aws-sdk-resources (2.10.34)
+      aws-sdk-core (= 2.10.34)
+    aws-sigv4 (1.0.1)
+    cause (0.1)
+    childprocess (0.5.8)
       ffi (~> 1.0, >= 1.0.11)
-    daemons (1.2.2)
-    em-redis-unified (0.6.0)
-      eventmachine (>= 0.12.10)
+    dentaku (2.0.9)
+    domain_name (0.5.20170404)
+      unf (>= 0.0.5, < 1.0.0)
+    em-http-server (0.1.8)
+      eventmachine
     em-worker (0.0.2)
       eventmachine
-    eventmachine (1.0.3)
-    ffi (1.9.8)
-    multi_json (1.11.0)
-    rack (1.6.0)
-    rack-protection (1.5.3)
-      rack
-    sensu (0.17.1)
-      async_sinatra (= 1.0.0)
-      em-redis-unified (= 0.6.0)
-      eventmachine (= 1.0.3)
-      multi_json (= 1.11.0)
-      sensu-em (= 2.4.1)
-      sensu-extension (= 1.1.2)
-      sensu-extensions (= 1.2.0)
-      sensu-logger (= 1.0.0)
-      sensu-settings (= 1.3.0)
-      sensu-spawn (= 1.1.0)
-      sensu-transport (= 2.4.0)
-      sinatra (= 1.3.5)
-      thin (= 1.5.0)
-      uuidtools (= 2.1.4)
-    sensu-em (2.4.1)
-    sensu-extension (1.1.2)
-      sensu-em
-    sensu-extensions (1.2.0)
+    eventmachine (1.2.5)
+    ffi (1.9.18)
+    http-cookie (1.0.3)
+      domain_name (~> 0.5)
+    influxdb (0.3.13)
+      cause
+      json
+    jmespath (1.3.1)
+    json (1.8.6)
+    jsonpath (0.5.8)
       multi_json
-      sensu-em
+    mime-types (3.1)
+      mime-types-data (~> 3.2015)
+    mime-types-data (3.2016.0521)
+    mixlib-cli (1.7.0)
+    multi_json (1.12.1)
+    netrc (0.11.0)
+    oj (2.18.1)
+    parse-cron (0.1.4)
+    rest-client (2.0.2)
+      http-cookie (>= 1.0.2, < 2.0)
+      mime-types (>= 1.16, < 4.0)
+      netrc (~> 0.8)
+    sensu (1.0.3)
+      em-http-server (= 0.1.8)
+      eventmachine (= 1.2.5)
+      parse-cron (= 0.1.4)
+      sensu-extension (= 1.5.1)
+      sensu-extensions (= 1.9.0)
+      sensu-json (= 2.1.0)
+      sensu-logger (= 1.2.1)
+      sensu-redis (= 2.2.0)
+      sensu-settings (= 10.3.0)
+      sensu-spawn (= 2.2.1)
+      sensu-transport (= 7.0.2)
+    sensu-extension (1.5.1)
+      eventmachine
+    sensu-extensions (1.9.0)
       sensu-extension
+      sensu-extensions-check-dependencies (= 1.0.1)
+      sensu-extensions-debug (= 1.0.0)
+      sensu-extensions-json (= 1.0.0)
+      sensu-extensions-occurrences (= 1.2.0)
+      sensu-extensions-only-check-output (= 1.0.0)
+      sensu-extensions-ruby-hash (= 1.0.0)
+      sensu-json (>= 1.1.0)
       sensu-logger
       sensu-settings
-    sensu-logger (1.0.0)
-      multi_json
-      sensu-em
-    sensu-settings (1.3.0)
-      multi_json
-    sensu-spawn (1.1.0)
-      childprocess (= 0.5.3)
+    sensu-extensions-check-dependencies (1.0.1)
+      sensu-extension
+    sensu-extensions-debug (1.0.0)
+      sensu-extension
+    sensu-extensions-json (1.0.0)
+      sensu-extension
+    sensu-extensions-occurrences (1.2.0)
+      sensu-extension
+    sensu-extensions-only-check-output (1.0.0)
+      sensu-extension
+    sensu-extensions-ruby-hash (1.0.0)
+      sensu-extension
+    sensu-json (2.1.0)
+      oj (= 2.18.1)
+    sensu-logger (1.2.1)
+      eventmachine
+      sensu-json
+    sensu-plugin (1.4.5)
+      json (< 2.0.0)
+      mixlib-cli (>= 1.5.0)
+    sensu-plugins-disk-checks (2.4.2)
+      sensu-plugin (~> 1.2)
+      sys-filesystem (= 1.1.7)
+    sensu-plugins-http (2.6.0)
+      aws-sdk (~> 2.3)
+      rest-client (~> 2.0.2)
+      sensu-plugin (~> 1.2)
+    sensu-plugins-influxdb (1.2.0)
+      dentaku (= 2.0.9)
+      influxdb (= 0.3.13)
+      jsonpath (= 0.5.8)
+      sensu-plugin (~> 1.3)
+    sensu-plugins-logs (1.2.0)
+      sensu-plugin (~> 1.2)
+    sensu-plugins-systemd (0.0.5)
+      sensu-plugin (~> 1.2)
+    sensu-redis (2.2.0)
+      eventmachine
+    sensu-settings (10.3.0)
+      parse-cron
+      sensu-json (>= 1.1.0)
+    sensu-spawn (2.2.1)
+      childprocess (= 0.5.8)
       em-worker (= 0.0.2)
-      sensu-em
-    sensu-transport (2.4.0)
-      amqp (= 1.5.0)
-      sensu-em
-    sinatra (1.3.5)
-      rack (~> 1.4)
-      rack-protection (~> 1.3)
-      tilt (~> 1.3, >= 1.3.3)
-    thin (1.5.0)
-      daemons (>= 1.0.9)
-      eventmachine (>= 0.12.6)
-      rack (>= 1.0.0)
-    tilt (1.4.1)
-    uuidtools (2.1.4)
+      eventmachine
+    sensu-transport (7.0.2)
+      amq-protocol (= 2.0.1)
+      amqp (= 1.6.0)
+      eventmachine
+      sensu-redis (>= 1.0.0)
+    sys-filesystem (1.1.7)
+      ffi
+    unf (0.1.4)
+      unf_ext
+    unf_ext (0.0.7.4)
 
 PLATFORMS
   ruby
 
 DEPENDENCIES
   sensu
+  sensu-plugins-disk-checks
+  sensu-plugins-http
+  sensu-plugins-influxdb
+  sensu-plugins-logs
+  sensu-plugins-systemd
+
+BUNDLED WITH
+   1.15.3
diff --git a/pkgs/servers/monitoring/sensu/default.nix b/pkgs/servers/monitoring/sensu/default.nix
index 2bb81d833372..dba0c32b353b 100644
--- a/pkgs/servers/monitoring/sensu/default.nix
+++ b/pkgs/servers/monitoring/sensu/default.nix
@@ -1,18 +1,17 @@
-  { lib, bundlerEnv, ruby }:
+{ lib, bundlerEnv, ruby }:
 
-  bundlerEnv {
-    name = "sensu-0.17.1";
+bundlerEnv rec {
+  name = "sensu-${version}";
+  version = (import ./gemset.nix).sensu.version;
 
-    inherit ruby;
-    gemfile = ./Gemfile;
-    lockfile = ./Gemfile.lock;
-    gemset = ./gemset.nix;
+  inherit ruby;
+  gemdir = ./.;
 
-    meta = with lib; {
-      description = "A monitoring framework that aims to be simple, malleable, and scalable";
-      homepage    = http://sensuapp.org/;
-      license     = licenses.mit;
-      maintainers = with maintainers; [ theuni ];
-      platforms   = platforms.unix;
-    };
-  }
+  meta = with lib; {
+    description = "A monitoring framework that aims to be simple, malleable, and scalable";
+    homepage    = https://sensuapp.org/;
+    license     = licenses.mit;
+    maintainers = with maintainers; [ theuni peterhoeg ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/sensu/gemset.nix b/pkgs/servers/monitoring/sensu/gemset.nix
index 116bce9c4b53..cce9a45e9ed8 100644
--- a/pkgs/servers/monitoring/sensu/gemset.nix
+++ b/pkgs/servers/monitoring/sensu/gemset.nix
@@ -1,242 +1,446 @@
 {
-  "amq-protocol" = {
-    version = "1.9.2";
+  amq-protocol = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1rpn9vgh7y037aqhhp04smihzr73vp5i5g6xlqlha10wy3q0wp7x";
       type = "gem";
-      sha256 = "1gl479j003vixfph5jmdskl20il8816y0flp4msrc8im3b5iiq3r";
     };
+    version = "2.0.1";
   };
-  "amqp" = {
-    version = "1.5.0";
+  amqp = {
+    dependencies = ["amq-protocol" "eventmachine"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0kbrqnpjgj9v0722p3n5rw589l4g26ry8mcghwc5yr20ggkpdaz9";
       type = "gem";
-      sha256 = "0jlcwyvjz0b28wxdabkyhdqyqp5ji56ckfywsy9mgp0m4wfbrh8c";
     };
-    dependencies = [
-      "amq-protocol"
-      "eventmachine"
-    ];
+    version = "1.6.0";
   };
-  "async_sinatra" = {
-    version = "1.0.0";
+  aws-sdk = {
+    dependencies = ["aws-sdk-resources"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "09k367vs9gb640cr1afphxjfmlykw7knnb9xz0kl2x5f9yr3zz23";
       type = "gem";
-      sha256 = "02yi9qfsi8kk4a4p1c4sx4pgism05m18kwlc9dd23zzdy9jdgq1a";
     };
-    dependencies = [
-      "rack"
-      "sinatra"
-    ];
+    version = "2.10.34";
   };
-  "childprocess" = {
-    version = "0.5.3";
+  aws-sdk-core = {
+    dependencies = ["aws-sigv4" "jmespath"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0gfsph8kr59jdpvycq8qh0c0ah64k0n96ag5qbvy7mzq9292085w";
       type = "gem";
-      sha256 = "12djpdr487fddq55sav8gw1pjglcbb0ab0s6npga0ywgsqdyvsww";
     };
-    dependencies = [
-      "ffi"
-    ];
+    version = "2.10.34";
   };
-  "daemons" = {
-    version = "1.2.2";
+  aws-sdk-resources = {
+    dependencies = ["aws-sdk-core"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0knip45mhx0dm8llp1akhhar2z007r7kjg3i3xbws7lhvms8fbjc";
       type = "gem";
-      sha256 = "121c7vkimg3baxga69xvdkwxiq8wkmxqvdbyqi5i82vhih5d3cn3";
     };
+    version = "2.10.34";
   };
-  "em-redis-unified" = {
-    version = "0.6.0";
+  aws-sigv4 = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0cxl0yvmyl8d0yj4cx3p75iki4fqk8ckb6ajfj7mr3g4ihp5mryp";
       type = "gem";
-      sha256 = "1hf7dv6qmxfilpd7crcqlyqk6jp5z8md76bpg3n0163ps4ra73p0";
     };
-    dependencies = [
-      "eventmachine"
-    ];
+    version = "1.0.1";
   };
-  "em-worker" = {
-    version = "0.0.2";
+  cause = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0digirxqlwdg79mkbn70yc7i9i1qnclm2wjbrc47kqv6236bpj00";
+      type = "gem";
+    };
+    version = "0.1";
+  };
+  childprocess = {
+    dependencies = ["ffi"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1lv7axi1fhascm9njxh3lx1rbrnsm8wgvib0g7j26v4h1fcphqg0";
+      type = "gem";
+    };
+    version = "0.5.8";
+  };
+  dentaku = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11z4cw4lspx3rgmmd2hd4l1iikk6p17icxwn7xym92v1j825zpnr";
+      type = "gem";
+    };
+    version = "2.0.9";
+  };
+  domain_name = {
+    dependencies = ["unf"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "12hs8yijhak7p2hf1xkh98g0mnp5phq3mrrhywzaxpwz1gw5r3kf";
       type = "gem";
+    };
+    version = "0.5.20170404";
+  };
+  em-http-server = {
+    dependencies = ["eventmachine"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0y8l4gymy9dzjjchjav90ck6has2i2zdjihlhcyrg3jgq6kjzyq5";
+      type = "gem";
+    };
+    version = "0.1.8";
+  };
+  em-worker = {
+    dependencies = ["eventmachine"];
+    source = {
+      remotes = ["https://rubygems.org"];
       sha256 = "0z4jx9z2q5hxvdvik4yp0ahwfk69qsmdnyp72ln22p3qlkq2z5wk";
+      type = "gem";
+    };
+    version = "0.0.2";
+  };
+  eventmachine = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "075hdw0fgzldgss3xaqm2dk545736khcvv1fmzbf1sgdlkyh1v8z";
+      type = "gem";
+    };
+    version = "1.2.5";
+  };
+  ffi = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "034f52xf7zcqgbvwbl20jwdyjwznvqnwpbaps9nk18v9lgb1dpx0";
+      type = "gem";
     };
-    dependencies = [
-      "eventmachine"
-    ];
+    version = "1.9.18";
   };
-  "eventmachine" = {
+  http-cookie = {
+    dependencies = ["domain_name"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "004cgs4xg5n6byjs7qld0xhsjq3n6ydfh897myr2mibvh6fjc49g";
+      type = "gem";
+    };
     version = "1.0.3";
+  };
+  influxdb = {
+    dependencies = ["cause" "json"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0jikl3iylbffsdmb4vr09ysqvpwxk133y6m9ylwcd0931ngsf0ks";
       type = "gem";
-      sha256 = "09sqlsb6x9ddlgfw5gsw7z0yjg5m2qfjiqkz2fx70zsizj3lqhil";
     };
+    version = "0.3.13";
   };
-  "ffi" = {
-    version = "1.9.8";
+  jmespath = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "07w8ipjg59qavijq59hl82zs74jf3jsp7vxl9q3a2d0wpv5akz3y";
       type = "gem";
-      sha256 = "0ph098bv92rn5wl6rn2hwb4ng24v4187sz8pa0bpi9jfh50im879";
     };
+    version = "1.3.1";
   };
-  "multi_json" = {
-    version = "1.11.0";
+  json = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0qmj7fypgb9vag723w1a49qihxrcf5shzars106ynw2zk352gbv5";
       type = "gem";
-      sha256 = "1mg3hp17ch8bkf3ndj40s50yjs0vrqbfh3aq5r02jkpjkh23wgxl";
     };
+    version = "1.8.6";
   };
-  "rack" = {
-    version = "1.6.0";
+  jsonpath = {
+    dependencies = ["multi_json"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1gwhrd7xlysq537yy8ma69jc83lblwiccajl5zvyqpnwyjjc93df";
+      type = "gem";
+    };
+    version = "0.5.8";
+  };
+  mime-types = {
+    dependencies = ["mime-types-data"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0087z9kbnlqhci7fxh9f6il63hj1k02icq2rs0c6cppmqchr753m";
+      type = "gem";
+    };
+    version = "3.1";
+  };
+  mime-types-data = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "04my3746hwa4yvbx1ranhfaqkgf6vavi1kyijjnw8w3dy37vqhkm";
       type = "gem";
-      sha256 = "1f57f8xmrgfgd76s6mq7vx6i266zm4330igw71an1g0kh3a42sbb";
     };
+    version = "3.2016.0521";
   };
-  "rack-protection" = {
-    version = "1.5.3";
+  mixlib-cli = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0647msh7kp7lzyf6m72g6snpirvhimjm22qb8xgv9pdhbcrmcccp";
       type = "gem";
-      sha256 = "0cvb21zz7p9wy23wdav63z5qzfn4nialik22yqp6gihkgfqqrh5r";
     };
-    dependencies = [
-      "rack"
-    ];
+    version = "1.7.0";
   };
-  "sensu" = {
-    version = "0.17.1";
+  multi_json = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1wpc23ls6v2xbk3l1qncsbz16npvmw8p0b38l8czdzri18mp51xk";
       type = "gem";
-      sha256 = "1fqpypins1zhind0in0ax0y97a6pf3z85gwjz4bjm6cjrkarb5zj";
     };
-    dependencies = [
-      "async_sinatra"
-      "em-redis-unified"
-      "eventmachine"
-      "multi_json"
-      "sensu-em"
-      "sensu-extension"
-      "sensu-extensions"
-      "sensu-logger"
-      "sensu-settings"
-      "sensu-spawn"
-      "sensu-transport"
-      "sinatra"
-      "thin"
-      "uuidtools"
-    ];
+    version = "1.12.1";
   };
-  "sensu-em" = {
-    version = "2.4.1";
+  netrc = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0gzfmcywp1da8nzfqsql2zqi648mfnx6qwkig3cv36n9m0yy676y";
       type = "gem";
-      sha256 = "08jz47lfnv55c9yl2dhyv1si6zl8h4xj8y1sjy2h2fqy48prfgmy";
     };
+    version = "0.11.0";
   };
-  "sensu-extension" = {
-    version = "1.1.2";
+  oj = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "147whmq8h2n04chskl3v4a132xhz5i6kk6vhnz83jwng4vihin5f";
       type = "gem";
-      sha256 = "19qz22fcb3xjz9p5npghlcvxkf8h1rsfws3j988ybnimmmmiqm24";
     };
-    dependencies = [
-      "sensu-em"
-    ];
+    version = "2.18.1";
   };
-  "sensu-extensions" = {
+  parse-cron = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "02fj9i21brm88nb91ikxwxbwv9y7mb7jsz6yydh82rifwq7357hg";
+      type = "gem";
+    };
+    version = "0.1.4";
+  };
+  rest-client = {
+    dependencies = ["http-cookie" "mime-types" "netrc"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1hzcs2r7b5bjkf2x2z3n8z6082maz0j8vqjiciwgg3hzb63f958j";
+      type = "gem";
+    };
+    version = "2.0.2";
+  };
+  sensu = {
+    dependencies = ["em-http-server" "eventmachine" "parse-cron" "sensu-extension" "sensu-extensions" "sensu-json" "sensu-logger" "sensu-redis" "sensu-settings" "sensu-spawn" "sensu-transport"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "07fa9rv7hdj2n58a0cm1i5nis309w7xbs9lmgckmrpj190q1gvdm";
+      type = "gem";
+    };
+    version = "1.0.3";
+  };
+  sensu-extension = {
+    dependencies = ["eventmachine"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1lgmjxfbq11v4yi3qanf1qxv0sgm1a8a7wj7qyn1nkva6zmimss3";
+      type = "gem";
+    };
+    version = "1.5.1";
+  };
+  sensu-extensions = {
+    dependencies = ["sensu-extension" "sensu-extensions-check-dependencies" "sensu-extensions-debug" "sensu-extensions-json" "sensu-extensions-occurrences" "sensu-extensions-only-check-output" "sensu-extensions-ruby-hash" "sensu-json" "sensu-logger" "sensu-settings"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1r09mdbbnh5cg9yvqw78sxbhlb8xqld1vwbr4hsjw6k3x1xpnnr9";
+      type = "gem";
+    };
+    version = "1.9.0";
+  };
+  sensu-extensions-check-dependencies = {
+    dependencies = ["sensu-extension"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0clgvf2abvwz549f28ny3zd6q7z6y7m49i8pp91ll10jp1vsy4b2";
+      type = "gem";
+    };
+    version = "1.0.1";
+  };
+  sensu-extensions-debug = {
+    dependencies = ["sensu-extension"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11abdgn2kkkbvxq4692yg6a27qnxz4349gfiq7d35biy7vrw34lp";
+      type = "gem";
+    };
+    version = "1.0.0";
+  };
+  sensu-extensions-json = {
+    dependencies = ["sensu-extension"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1wnbn9sycdqdh9m0fhszaqkv0jijs3fkdbvcv8kdspx6irbv3m6g";
+      type = "gem";
+    };
+    version = "1.0.0";
+  };
+  sensu-extensions-occurrences = {
+    dependencies = ["sensu-extension"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0lx5wsbblfs0rvkxfg09bsz0g2mwmckrhga7idnarsnm8m565v1v";
+      type = "gem";
+    };
     version = "1.2.0";
+  };
+  sensu-extensions-only-check-output = {
+    dependencies = ["sensu-extension"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0ds2i8wd4ji9ifig2zzr4jpxinvk5dm7j10pvaqy4snykxa3rqh3";
       type = "gem";
-      sha256 = "1b8978g1ww7vdrsw7zvba6qvc56s4vfm1hw3szw3j1gsk6j0vb81";
     };
-    dependencies = [
-      "multi_json"
-      "sensu-em"
-      "sensu-extension"
-      "sensu-logger"
-      "sensu-settings"
-    ];
+    version = "1.0.0";
   };
-  "sensu-logger" = {
+  sensu-extensions-ruby-hash = {
+    dependencies = ["sensu-extension"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1xyrj3gbmslbivcd5qcmyclgapn7qf7f5jwfvfpw53bxzib0h7s3";
+      type = "gem";
+    };
     version = "1.0.0";
+  };
+  sensu-json = {
+    dependencies = ["oj"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "02qkh86jddv7gha39vjx6g9hi7vkq7r433dr86bwmm9c7lqkgyl9";
+      type = "gem";
+    };
+    version = "2.1.0";
+  };
+  sensu-logger = {
+    dependencies = ["eventmachine" "sensu-json"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "03kicjqz8a594bxnwyg6bcd4fipy2vxjl1gbaip4gpixxki32dx0";
+      type = "gem";
+    };
+    version = "1.2.1";
+  };
+  sensu-plugin = {
+    dependencies = ["json" "mixlib-cli"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0z18zk04l9klbjmqvjg6cpv3k4w5hi1by8wnpkiwdwa2jdv61jyb";
+      type = "gem";
+    };
+    version = "1.4.5";
+  };
+  sensu-plugins-disk-checks = {
+    dependencies = ["sensu-plugin" "sys-filesystem"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1m5pygdaf8xqrby61vcsq6ynhzcvjr2xgahwmkkcai8a4xqrpq9x";
+      type = "gem";
+    };
+    version = "2.4.2";
+  };
+  sensu-plugins-http = {
+    dependencies = ["aws-sdk" "rest-client" "sensu-plugin"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1yg05x9dl4xwqi7lvglyv374a3hbp7ag0z9325jmc9bazm6i2q2d";
+      type = "gem";
+    };
+    version = "2.6.0";
+  };
+  sensu-plugins-influxdb = {
+    dependencies = ["dentaku" "influxdb" "jsonpath" "sensu-plugin"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "18nk7c451df46xcjk97r3h8yhaj8bz138ih5y0z26sdiha58brv7";
+      type = "gem";
+    };
+    version = "1.2.0";
+  };
+  sensu-plugins-logs = {
+    dependencies = ["sensu-plugin"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0ycrf3967v5kavm58fj9db16l9wgyzac4h3r0f9hm32jy9qsxwq6";
+      type = "gem";
+    };
+    version = "1.2.0";
+  };
+  sensu-plugins-systemd = {
+    dependencies = ["sensu-plugin"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1r7prvkf33j6qvvqq78186rn5g6wf0g3dqni34vnj8v1z287wkfh";
       type = "gem";
-      sha256 = "0vwa2b5wa9xqzb9lmhma49171iabwbnnnyhhhaii8n6j4axvar93";
     };
-    dependencies = [
-      "multi_json"
-      "sensu-em"
-    ];
+    version = "0.0.5";
   };
-  "sensu-settings" = {
-    version = "1.3.0";
+  sensu-redis = {
+    dependencies = ["eventmachine"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1drmychc04fg2gs7zsxx6aidfyxf7cn7k8k1jy7dnfbnlr5aln3n";
       type = "gem";
-      sha256 = "0s9fyqhq5vf9m9937n3wczlr4z62rn1ydc6m53vn4156fpim6yga";
     };
-    dependencies = [
-      "multi_json"
-    ];
+    version = "2.2.0";
   };
-  "sensu-spawn" = {
-    version = "1.1.0";
+  sensu-settings = {
+    dependencies = ["parse-cron" "sensu-json"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0y55bqvps06gk94zllamqr0fa5bc27q0k1b5sp5gxh1bkf4w8gb3";
       type = "gem";
-      sha256 = "0w9z6hpr27lq02y6c2mnrdl9xpsjfg77kzsfsp2f2w4swdwmiv0v";
     };
-    dependencies = [
-      "childprocess"
-      "em-worker"
-      "sensu-em"
-    ];
+    version = "10.3.0";
   };
-  "sensu-transport" = {
-    version = "2.4.0";
+  sensu-spawn = {
+    dependencies = ["childprocess" "em-worker" "eventmachine"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1vz5kbqk3ld0s16zjl8m38l1m1xwcvjlfc1g4nfm45qxdyfn7la7";
       type = "gem";
-      sha256 = "0gh8rcl22daax7qng93kj2jydql1jhhskd37kj7sgz0rr8wy2x06";
     };
-    dependencies = [
-      "amqp"
-      "sensu-em"
-    ];
+    version = "2.2.1";
   };
-  "sinatra" = {
-    version = "1.3.5";
+  sensu-transport = {
+    dependencies = ["amq-protocol" "amqp" "eventmachine" "sensu-redis"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "15yib92hwyd8v04wcc0kaw0p8w2c2mwvi4ldya2jh3dqgs31mvhr";
       type = "gem";
-      sha256 = "1mn6nzfyirfqr7prhsn4nr3k481c6nzsad2p9s1xnsbvxa1vkqwr";
     };
-    dependencies = [
-      "rack"
-      "rack-protection"
-      "tilt"
-    ];
+    version = "7.0.2";
   };
-  "thin" = {
-    version = "1.5.0";
+  sys-filesystem = {
+    dependencies = ["ffi"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "10didky52nfapmybj6ipda18i8fcwf8bs9bbfbk5i7v1shzd36rf";
       type = "gem";
-      sha256 = "14sd2qbbk6y108z6v723mh3f1mk8s4fwxmmn9f8dk4xkhk4rwvq1";
     };
-    dependencies = [
-      "daemons"
-      "eventmachine"
-      "rack"
-    ];
+    version = "1.1.7";
   };
-  "tilt" = {
-    version = "1.4.1";
+  unf = {
+    dependencies = ["unf_ext"];
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0bh2cf73i2ffh4fcpdn9ir4mhq8zi50ik0zqa1braahzadx536a9";
       type = "gem";
-      sha256 = "00sr3yy7sbqaq7cb2d2kpycajxqf1b1wr1yy33z4bnzmqii0b0ir";
     };
+    version = "0.1.4";
   };
-  "uuidtools" = {
-    version = "2.1.4";
+  unf_ext = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "14hr2dzqh33kqc0xchs8l05pf3kjcayvad4z1ip5rdjxrkfk8glb";
       type = "gem";
-      sha256 = "1w0bhnkp5515f3yx5fakfrfkawxjpb4fjm1r2c6lk691xlr696s3";
     };
+    version = "0.0.7.4";
   };
 }
\ No newline at end of file
diff --git a/pkgs/servers/monitoring/telegraf/default.nix b/pkgs/servers/monitoring/telegraf/default.nix
new file mode 100644
index 000000000000..b7879cc763aa
--- /dev/null
+++ b/pkgs/servers/monitoring/telegraf/default.nix
@@ -0,0 +1,31 @@
+{ lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "telegraf-${version}";
+  version = "1.6.1";
+
+  goPackagePath = "github.com/influxdata/telegraf";
+
+  excludedPackages = "test";
+
+  src = fetchFromGitHub {
+    owner = "influxdata";
+    repo = "telegraf";
+    rev = "${version}";
+    sha256 = "0zc3bgs1ad392lqv72rkppxmk33b404b8jfx3wbzll7fklwxa8g2";
+  };
+
+  buildFlagsArray = [ ''-ldflags=
+    -X main.version=${version}
+  '' ];
+
+  goDeps = ./. + builtins.toPath "/deps-${version}.nix";
+
+  meta = with lib; {
+    description = "The plugin-driven server agent for collecting & reporting metrics.";
+    license = licenses.mit;
+    homepage = https://www.influxdata.com/time-series-platform/telegraf/;
+    maintainers = with maintainers; [ mic92 roblabla ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/monitoring/telegraf/deps-1.6.1.nix b/pkgs/servers/monitoring/telegraf/deps-1.6.1.nix
new file mode 100644
index 000000000000..fb98b8686cc2
--- /dev/null
+++ b/pkgs/servers/monitoring/telegraf/deps-1.6.1.nix
@@ -0,0 +1,723 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "collectd.org";
+    fetch = {
+      type = "git";
+      url = "https://github.com/collectd/go-collectd";
+      rev = "2ce144541b8903101fb8f1483cc0497a68798122";
+      sha256 = "0rr9rnc777jk27a7yxhdb7vgkj493158a8k6q44x51s30dkp78x3";
+    };
+  }
+  {
+    goPackagePath = "github.com/Shopify/sarama";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Shopify/sarama";
+      rev = "3b1b38866a79f06deddf0487d5c27ba0697ccd65";
+      sha256 = "02qwlqd1kdgwlv39fimpbzjhgw8shzkkad82kfwdy8lppscb20br";
+    };
+  }
+  {
+    goPackagePath = "github.com/Sirupsen/logrus";
+    fetch = {
+      type = "git";
+      url = "https://github.com/Sirupsen/logrus";
+      rev = "61e43dc76f7ee59a82bdf3d71033dc12bea4c77d";
+      sha256 = "08kr7zvdgwv8vsakjzq1bla6cc6dlxlg1brlga69y69xw7cz5l9p";
+    };
+  }
+  {
+    goPackagePath = "github.com/aerospike/aerospike-client-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/aerospike/aerospike-client-go";
+      rev = "95e1ad7791bdbca44707fedbb29be42024900d9c";
+      sha256 = "034pirm1dzdblwadcd829qk2jqkr8hg9gpfph8ax7z0b3h2ah8xf";
+    };
+  }
+  {
+    goPackagePath = "github.com/amir/raidman";
+    fetch = {
+      type = "git";
+      url = "https://github.com/amir/raidman";
+      rev = "c74861fe6a7bb8ede0a010ce4485bdbb4fc4c985";
+      sha256 = "10lmpz5vf2ysw8gnl0z8ravl4vvy48nbh8xpk2zzgifb6yn3x192";
+    };
+  }
+  {
+    goPackagePath = "github.com/apache/thrift";
+    fetch = {
+      type = "git";
+      url = "https://github.com/apache/thrift";
+      rev = "4aaa92ece8503a6da9bc6701604f69acf2b99d07";
+      sha256 = "1my582c0ln1byxid5acdd6dk7lvi7lwd6gka10s4bp4w3xrd55x8";
+    };
+  }
+  {
+    goPackagePath = "github.com/aws/aws-sdk-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/aws/aws-sdk-go";
+      rev = "c861d27d0304a79f727e9a8a4e2ac1e74602fdc0";
+      sha256 = "023cyg551dvm2l50dx1qsikkj77lk2dhiya7by8in7h65av6hjgl";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9";
+      sha256 = "1hrybsql68xw57brzj805xx2mghydpdiysv3gbhr7f5wlxj2514y";
+    };
+  }
+  {
+    goPackagePath = "github.com/bsm/sarama-cluster";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bsm/sarama-cluster";
+      rev = "abf039439f66c1ce78017f560b490612552f6472";
+      sha256 = "16013ac7jv72mdiv84vhk4av1vb5q8xq3fhv253fz2a17h9ld78q";
+    };
+  }
+  {
+    goPackagePath = "github.com/cenkalti/backoff";
+    fetch = {
+      type = "git";
+      url = "https://github.com/cenkalti/backoff";
+      rev = "b02f2bbce11d7ea6b97f282ef1771b0fe2f65ef3";
+      sha256 = "0lhcll9pzcxbbm9sdsijvcvdqc4lrsgbyw0q1xly0pnz556v6pyc";
+    };
+  }
+  {
+    goPackagePath = "github.com/couchbase/go-couchbase";
+    fetch = {
+      type = "git";
+      url = "https://github.com/couchbase/go-couchbase";
+      rev = "bfe555a140d53dc1adf390f1a1d4b0fd4ceadb28";
+      sha256 = "0h59zzxcz3i8nd4ln89fi946ii8kscnqam67h3mxvjwvpnmcax9k";
+    };
+  }
+  {
+    goPackagePath = "github.com/couchbase/gomemcached";
+    fetch = {
+      type = "git";
+      url = "https://github.com/couchbase/gomemcached";
+      rev = "4a25d2f4e1dea9ea7dd76dfd943407abf9b07d29";
+      sha256 = "12h0wsimwmr0f398538g9ngasik4gisnac9vpn0ldy8hqdpa334d";
+    };
+  }
+  {
+    goPackagePath = "github.com/couchbase/goutils";
+    fetch = {
+      type = "git";
+      url = "https://github.com/couchbase/goutils";
+      rev = "5823a0cbaaa9008406021dc5daf80125ea30bba6";
+      sha256 = "15v5ps2i2y2hczwxs2ci4c2w4p3pn3bl7vc5wlaqnc7i14f9285c";
+    };
+  }
+  {
+    goPackagePath = "github.com/davecgh/go-spew";
+    fetch = {
+      type = "git";
+      url = "https://github.com/davecgh/go-spew";
+      rev = "346938d642f2ec3594ed81d874461961cd0faa76";
+      sha256 = "0d4jfmak5p6lb7n2r6yvf5p1zcw0l8j74kn55ghvr7zr7b7axm6c";
+    };
+  }
+  {
+    goPackagePath = "github.com/dgrijalva/jwt-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dgrijalva/jwt-go";
+      rev = "dbeaa9332f19a944acb5736b4456cfcc02140e29";
+      sha256 = "0zk6l6kzsjdijfn7c4h0aywdjx5j2hjwi67vy1k6wr46hc8ks2hs";
+    };
+  }
+  {
+    goPackagePath = "github.com/docker/docker";
+    fetch = {
+      type = "git";
+      url = "https://github.com/docker/docker";
+      rev = "f5ec1e2936dcbe7b5001c2b817188b095c700c27";
+      sha256 = "1y3rkzgg8vpjq61y473lnh0qyc6msl4ixw7ci2p56fyqrhkmhf96";
+    };
+  }
+  {
+    goPackagePath = "github.com/docker/go-connections";
+    fetch = {
+      type = "git";
+      url = "https://github.com/docker/go-connections";
+      rev = "990a1a1a70b0da4c4cb70e117971a4f0babfbf1a";
+      sha256 = "16lcf485a7gl0kzkc5n0qq9frjkfinxhcr3j4874qqkr8ghghwbb";
+    };
+  }
+  {
+    goPackagePath = "github.com/eapache/go-resiliency";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eapache/go-resiliency";
+      rev = "b86b1ec0dd4209a588dc1285cdd471e73525c0b3";
+      sha256 = "1kzv95bh3nidm2cr7iv9lk3s2qiw1i17n8gyl2x6xk6qv8b0bc21";
+    };
+  }
+  {
+    goPackagePath = "github.com/eapache/go-xerial-snappy";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eapache/go-xerial-snappy";
+      rev = "bb955e01b9346ac19dc29eb16586c90ded99a98c";
+      sha256 = "1zhxcil8hn88hvxr2d6rmj4cls5zgss1scj0ikwiqq89f8vcgwn4";
+    };
+  }
+  {
+    goPackagePath = "github.com/eapache/queue";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eapache/queue";
+      rev = "44cc805cf13205b55f69e14bcb69867d1ae92f98";
+      sha256 = "07dp54n94gn3gsvdcki56yqh7py7wqqigxbamhxwgbr05n61fqyg";
+    };
+  }
+  {
+    goPackagePath = "github.com/eclipse/paho.mqtt.golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/eclipse/paho.mqtt.golang";
+      rev = "aff15770515e3c57fc6109da73d42b0d46f7f483";
+      sha256 = "1blfvrp1d5jqxxqdw7xd0ns1qiml45k0nch9jwpi0ddg7hckii2d";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-redis/redis";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-redis/redis";
+      rev = "73b70592cdaa9e6abdfcfbf97b4a90d80728c836";
+      sha256 = "0b6xwajnk65bdq98czv137gvypwnznkjnm2ksnxm87nyj2vyddm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-sql-driver/mysql";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-sql-driver/mysql";
+      rev = "2e00b5cd70399450106cec6431c2e2ce3cae5034";
+      sha256 = "085g48jq9hzmlcxg122n0c4pi41sc1nn2qpx1vrl2jfa8crsppa5";
+    };
+  }
+  {
+    goPackagePath = "github.com/gobwas/glob";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gobwas/glob";
+      rev = "bea32b9cd2d6f55753d94a28e959b13f0244797a";
+      sha256 = "0dx0f293v1a0d8qi7ik5hdl26dapd8xm0hj9a9gc620vhj7khi9q";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "8ee79997227bf9b34611aee7946ae64735e6fd93";
+      sha256 = "0qm1lpdhf97k2hxgivq2cpjgawhlmmz39y230kgxijhm96xijxb8";
+    };
+  }
+  {
+    goPackagePath = "github.com/golang/snappy";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/snappy";
+      rev = "7db9049039a047d955fe8c19b83c8ff5abd765c7";
+      sha256 = "09l3sc9z2fqnj5b040q320gwb4gqig6lnysxcayhwckrdp5bm8hs";
+    };
+  }
+  {
+    goPackagePath = "github.com/gorilla/mux";
+    fetch = {
+      type = "git";
+      url = "https://github.com/gorilla/mux";
+      rev = "392c28fe23e1c45ddba891b0320b3b5df220beea";
+      sha256 = "0dmihkq34ls23by08r8p92qpf77imibjd9m9qvw344j4r2z7bd4d";
+    };
+  }
+  {
+    goPackagePath = "github.com/hailocab/go-hostpool";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hailocab/go-hostpool";
+      rev = "e80d13ce29ede4452c43dea11e79b9bc8a15b478";
+      sha256 = "05ld4wp3illkbgl043yf8jq9y1ld0zzvrcg8jdij129j50xgfxny";
+    };
+  }
+  {
+    goPackagePath = "github.com/hashicorp/consul";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hashicorp/consul";
+      rev = "63d2fc68239b996096a1c55a0d4b400ea4c2583f";
+      sha256 = "0vx7jpi2a9374mlhn37b33780n7g950zh482z2sd4lsf29n4c580";
+    };
+  }
+  {
+    goPackagePath = "github.com/influxdata/tail";
+    fetch = {
+      type = "git";
+      url = "https://github.com/influxdata/tail";
+      rev = "c43482518d410361b6c383d7aebce33d0471d7bc";
+      sha256 = "0kf155nz9wvwawsbgaa76q4r975l7945nlvnh4ig60xm0jv8580b";
+    };
+  }
+  {
+    goPackagePath = "github.com/influxdata/toml";
+    fetch = {
+      type = "git";
+      url = "https://github.com/influxdata/toml";
+      rev = "5d1d907f22ead1cd47adde17ceec5bda9cacaf8f";
+      sha256 = "1faf51s89sk1z41qfsazmddgwll7jq9xna67k3h3vry86c4vs2j4";
+    };
+  }
+  {
+    goPackagePath = "github.com/influxdata/wlog";
+    fetch = {
+      type = "git";
+      url = "https://github.com/influxdata/wlog";
+      rev = "7c63b0a71ef8300adc255344d275e10e5c3a71ec";
+      sha256 = "04kw4kivxvr3kkmghj3427b1xyhzbhnfr971qfn3lv2vvhs8kpfl";
+    };
+  }
+  {
+    goPackagePath = "github.com/jackc/pgx";
+    fetch = {
+      type = "git";
+      url = "https://github.com/jackc/pgx";
+      rev = "63f58fd32edb5684b9e9f4cfaac847c6b42b3917";
+      sha256 = "1n9cbdwzpagnrisxwq0frqdnkmyfg2qlxsr890527d32633hp0h2";
+    };
+  }
+  {
+    goPackagePath = "github.com/kardianos/osext";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kardianos/osext";
+      rev = "c2c54e542fb797ad986b31721e1baedf214ca413";
+      sha256 = "02vmjhkx90601l5fym7c3r4d44b88h3cign86nz4yy6j8qqxvz3h";
+    };
+  }
+  {
+    goPackagePath = "github.com/kardianos/service";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kardianos/service";
+      rev = "6d3a0ee7d3425d9d835debc51a0ca1ffa28f4893";
+      sha256 = "1cgqg6zbwwsn6lz2ms094q4w37x84vd9ixs50wsh3037q4sfhyll";
+    };
+  }
+  {
+    goPackagePath = "github.com/kballard/go-shellquote";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kballard/go-shellquote";
+      rev = "d8ec1a69a250a17bb0e419c386eac1f3711dc142";
+      sha256 = "1a57hm0zwyi70am670s0pkglnkk1ilddnmfxz1ba7innpkf5z6s7";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "c12348ce28de40eed0136aa2b644d0ee0650e56c";
+      sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
+    };
+  }
+  {
+    goPackagePath = "github.com/miekg/dns";
+    fetch = {
+      type = "git";
+      url = "https://github.com/miekg/dns";
+      rev = "99f84ae56e75126dd77e5de4fae2ea034a468ca1";
+      sha256 = "1v7rccng7mbzqh5qf8d8gqfppm127v32s8i1n3k50q3flv227byf";
+    };
+  }
+  {
+    goPackagePath = "github.com/mitchellh/mapstructure";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mitchellh/mapstructure";
+      rev = "d0303fe809921458f417bcf828397a65db30a7e4";
+      sha256 = "1fjwi5ghc1ibyx93apz31n4hj6gcq1hzismpdfbg2qxwshyg0ya8";
+    };
+  }
+  {
+    goPackagePath = "github.com/multiplay/go-ts3";
+    fetch = {
+      type = "git";
+      url = "https://github.com/multiplay/go-ts3";
+      rev = "07477f49b8dfa3ada231afc7b7b17617d42afe8e";
+      sha256 = "1z2cfqhm6g48vzscargw6vl9idfppdcm3wq1xfwy73l1s77q4n9n";
+    };
+  }
+  {
+    goPackagePath = "github.com/naoina/go-stringutil";
+    fetch = {
+      type = "git";
+      url = "https://github.com/naoina/go-stringutil";
+      rev = "6b638e95a32d0c1131db0e7fe83775cbea4a0d0b";
+      sha256 = "00831p1wn3rimybk1z8l30787kn1akv5jax5wx743nn76qcmkmc6";
+    };
+  }
+  {
+    goPackagePath = "github.com/nats-io/gnatsd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nats-io/gnatsd";
+      rev = "393bbb7c031433e68707c8810fda0bfcfbe6ab9b";
+      sha256 = "1hnn4p24gm90siixdvj97csrxnr78svxmypglcjska474adhhnzz";
+    };
+  }
+  {
+    goPackagePath = "github.com/nats-io/go-nats";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nats-io/go-nats";
+      rev = "ea9585611a4ab58a205b9b125ebd74c389a6b898";
+      sha256 = "0i2whh6c8grzi9slrk2clh3dhykxzid4zn395wgysg6gfjrbd5i5";
+    };
+  }
+  {
+    goPackagePath = "github.com/nats-io/nats";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nats-io/nats";
+      rev = "ea9585611a4ab58a205b9b125ebd74c389a6b898";
+      sha256 = "0i2whh6c8grzi9slrk2clh3dhykxzid4zn395wgysg6gfjrbd5i5";
+    };
+  }
+  {
+    goPackagePath = "github.com/nats-io/nuid";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nats-io/nuid";
+      rev = "289cccf02c178dc782430d534e3c1f5b72af807f";
+      sha256 = "1dpk8qzl43gfdaj2nbw52a0xyrmpmq26a9v9dfl27vkijssb20p4";
+    };
+  }
+  {
+    goPackagePath = "github.com/nsqio/go-nsq";
+    fetch = {
+      type = "git";
+      url = "https://github.com/nsqio/go-nsq";
+      rev = "eee57a3ac4174c55924125bb15eeeda8cffb6e6f";
+      sha256 = "194wdmgsc0qhdjx95ka7blly58r9bj2vc0bgls7jawzszfpsbx8x";
+    };
+  }
+  {
+    goPackagePath = "github.com/opencontainers/runc";
+    fetch = {
+      type = "git";
+      url = "https://github.com/opencontainers/runc";
+      rev = "89ab7f2ccc1e45ddf6485eaa802c35dcf321dfc8";
+      sha256 = "1rnaqcsww7plr430r4ksv9si4l91l25li0bwa1b03g3sn2shirk1";
+    };
+  }
+  {
+    goPackagePath = "github.com/openzipkin/zipkin-go-opentracing";
+    fetch = {
+      type = "git";
+      url = "https://github.com/openzipkin/zipkin-go-opentracing";
+      rev = "1cafbdfde94fbf2b373534764e0863aa3bd0bf7b";
+      sha256 = "1vpl3mpvhljzpnll67ip3m9aazy3dvgi57n7w3pn8kg3b7kr4rwj";
+    };
+  }
+  {
+    goPackagePath = "github.com/pierrec/lz4";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pierrec/lz4";
+      rev = "5c9560bfa9ace2bf86080bf40d46b34ae44604df";
+      sha256 = "0j74a3xc48ispj8sb9c2sd1h53q99ws0f2x827b5p86xlpam8xyj";
+    };
+  }
+  {
+    goPackagePath = "github.com/pierrec/xxHash";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pierrec/xxHash";
+      rev = "5a004441f897722c627870a981d02b29924215fa";
+      sha256 = "146ibrgvgh61jhbbv9wks0mabkci3s0m68sg6shmlv1yixkw6gja";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/errors";
+      rev = "645ef00459ed84a119197bfb8d8205042c6df63d";
+      sha256 = "001i6n71ghp2l6kdl3qq1v2vmghcz3kicv9a5wgcihrzigm75pp5";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "c317fb74746eac4fc65fe3909195f4cf67c5562a";
+      sha256 = "1c3rqwkajkmhk5wh6agc5jnjbbfvpfxbiy8cprpw89khch428khp";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "fa8ad6fec33561be4280a8f0514318c79d7f6cb6";
+      sha256 = "11a7v1fjzhhwsl128znjcf5v7v6129xjgkdpym2lial4lac1dhm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "dd2f054febf4a6c00f2343686efb775948a8bff4";
+      sha256 = "0rhbgj51r105ax544mfg6wp4rsqpzn3776z1k82b21xwb3b51zr1";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "1878d9fbb537119d24b21ca07effd591627cd160";
+      sha256 = "0jqn5l31szmc0dv5invp5mdhndx3fcsda7zpy49zd7k95c1y20m7";
+    };
+  }
+  {
+    goPackagePath = "github.com/rcrowley/go-metrics";
+    fetch = {
+      type = "git";
+      url = "https://github.com/rcrowley/go-metrics";
+      rev = "1f30fe9094a513ce4c700b9a54458bbb0c96996c";
+      sha256 = "1hvbiaq4b6dqgjz6jkkxglfh9gf71zin6qsg508sh0r0ixfavrzj";
+    };
+  }
+  {
+    goPackagePath = "github.com/samuel/go-zookeeper";
+    fetch = {
+      type = "git";
+      url = "https://github.com/samuel/go-zookeeper";
+      rev = "1d7be4effb13d2d908342d349d71a284a7542693";
+      sha256 = "002s19109spms9ndfwykf3ryy3fnk7b56frxlqmmv37mlqgrd5v9";
+    };
+  }
+  {
+    goPackagePath = "github.com/satori/go.uuid";
+    fetch = {
+      type = "git";
+      url = "https://github.com/satori/go.uuid";
+      rev = "5bf94b69c6b68ee1b541973bb8e1144db23a194b";
+      sha256 = "0l782l4srv36pj8pfgn61996d0vjifld4a569rbjwq5h14pd0c07";
+    };
+  }
+  {
+    goPackagePath = "github.com/shirou/gopsutil";
+    fetch = {
+      type = "git";
+      url = "https://github.com/shirou/gopsutil";
+      rev = "a5c2888e464b14fa882c2a059e0f95716bd45cf1";
+      sha256 = "1czzl00lxcyhmf6x7wmw3dxmnyqij8lcahn5mv325csgyym4vm4w";
+    };
+  }
+  {
+    goPackagePath = "github.com/soniah/gosnmp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/soniah/gosnmp";
+      rev = "f15472a4cd6f6ea7929e4c7d9f163c49f059924f";
+      sha256 = "1blhxq9sayfg7zih5rj0dg2qj9h10m6sbri57hxya9iz3jfgcx11";
+    };
+  }
+  {
+    goPackagePath = "github.com/streadway/amqp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/streadway/amqp";
+      rev = "63795daa9a446c920826655f26ba31c81c860fd6";
+      sha256 = "1v6xwskb4dqyy2q1r7k12f9wky7v6cfb4f1mx94sr3qvx37zg2yj";
+    };
+  }
+  {
+    goPackagePath = "github.com/stretchr/testify";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stretchr/testify";
+      rev = "12b6f73e6084dad08a7c6e575284b177ecafbc71";
+      sha256 = "01f80s0q64pw5drfgqwwk1wfwwkvd2lhbs56lhhkff4ni83k73fd";
+    };
+  }
+  {
+    goPackagePath = "github.com/tidwall/gjson";
+    fetch = {
+      type = "git";
+      url = "https://github.com/tidwall/gjson";
+      rev = "0623bd8fbdbf97cc62b98d15108832851a658e59";
+      sha256 = "0g6rhilcmqpdvjdds7ykzhrlsjx234chf73l8sjah0rsd03207k0";
+    };
+  }
+  {
+    goPackagePath = "github.com/tidwall/match";
+    fetch = {
+      type = "git";
+      url = "https://github.com/tidwall/match";
+      rev = "173748da739a410c5b0b813b956f89ff94730b4c";
+      sha256 = "0a4hp323gnjam3nfxfljq7d24m7rgk5vxbscjmi3ik3ph78r5avg";
+    };
+  }
+  {
+    goPackagePath = "github.com/vjeantet/grok";
+    fetch = {
+      type = "git";
+      url = "https://github.com/vjeantet/grok";
+      rev = "d73e972b60935c7fec0b4ffbc904ed39ecaf7efe";
+      sha256 = "09p70h5inycwrw3dmn6c7lhx4m11fvw7449wzq1k5w2jcws7amd5";
+    };
+  }
+  {
+    goPackagePath = "github.com/wvanbergen/kafka";
+    fetch = {
+      type = "git";
+      url = "https://github.com/wvanbergen/kafka";
+      rev = "bc265fedb9ff5b5c5d3c0fdcef4a819b3523d3ee";
+      sha256 = "0x86gnkpsr6gsc6mk2312ay8yqrzscvvdra2knhvwgaws6rzvj2l";
+    };
+  }
+  {
+    goPackagePath = "github.com/wvanbergen/kazoo-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/wvanbergen/kazoo-go";
+      rev = "968957352185472eacb69215fa3dbfcfdbac1096";
+      sha256 = "07q37lmlc3vx620bklp93r368r73kgm2s9x7qcgcxk9701lqq7dc";
+    };
+  }
+  {
+    goPackagePath = "github.com/yuin/gopher-lua";
+    fetch = {
+      type = "git";
+      url = "https://github.com/yuin/gopher-lua";
+      rev = "66c871e454fcf10251c61bf8eff02d0978cae75a";
+      sha256 = "1srcibhsl29cy8qih132iqigl4ss303nfmglrgc583nj9kz9sf8j";
+    };
+  }
+  {
+    goPackagePath = "github.com/zensqlmonitor/go-mssqldb";
+    fetch = {
+      type = "git";
+      url = "https://github.com/zensqlmonitor/go-mssqldb";
+      rev = "ffe5510c6fa5e15e6d983210ab501c815b56b363";
+      sha256 = "079x8ms8lv5p6253ppaxva37k6w04xnd38y8763rr2giswxqzlkl";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "dc137beb6cce2043eb6b5f223ab8bf51c32459f4";
+      sha256 = "0kia3rd0g0vkb9pf102kbg1agr1xq27bi2shkpxy9l718yvy9jwd";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "f2499483f923065a842d38eb4c7f1927e6fc6e6d";
+      sha256 = "0q1ps8igfczfafk39hkp8gs57s6qxjvf2c48hiq00p873agz0x7s";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "739734461d1c916b6c72a63d7efda2b27edb369f";
+      sha256 = "0b0yh28ap1q0b8myg0gw4p9d6m71ry0d3n4hiycvd8sgk327379a";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "506f9d5c962f284575e88337e7d9296d27e729d3";
+      sha256 = "1ghx5vv4zlkjzlx2gslvcwpvxjggpl6wz5n49nqxiz777psx218s";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/asn1-ber.v1";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/asn1-ber.v1";
+      rev = "4e86f4367175e39f69d9358a5f17b4dda270378d";
+      sha256 = "13p8s74kzklb5lklfpxwxb78rknihawv1civ4s9bfqx565010fwk";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/fatih/pool.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/fatih/pool.v2";
+      rev = "6e328e67893eb46323ad06f0e92cb9536babbabc";
+      sha256 = "1p1sljfpbg2bp4qv7ghvz1wcmmsbcfclsninxa97kr0v7na7jw5p";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/gorethink/gorethink.v3";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/gorethink/gorethink.v3";
+      rev = "7ab832f7b65573104a555d84a27992ae9ea1f659";
+      sha256 = "1pri52ac45aqf5a2kmsd4mfhyfbkd1snkjbvanrdgipikysxi696";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/ldap.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/ldap.v2";
+      rev = "8168ee085ee43257585e50c6441aadf54ecb2c9f";
+      sha256 = "1w0993i8bl8sap01gwm1v6hjp0rsanj2mbpyabwcwnns2g79n895";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/mgo.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/mgo.v2";
+      rev = "3f83fa5005286a7fe593b055f0d7771a7dce4655";
+      sha256 = "19vwb6qlcyh3nh6pkk0bynwmr5cmi6mm4hdz01lwb4ybnkzxryc7";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/olivere/elastic.v5";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/olivere/elastic.v5";
+      rev = "3113f9b9ad37509fe5f8a0e5e91c96fdc4435e26";
+      sha256 = "1zkwprs68q1r7pigb59n8zbw8610z9r1pi6r0s28kzdgiv30sfdm";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/yaml.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/yaml.v2";
+      rev = "4c78c975fe7c825c6d1466c42be594d1d6f3aba6";
+      sha256 = "1ddwvmsfijgl09pbqrcx73fy5kh8y3888dd29lh7i50ds5a088cx";
+    };
+  }
+]
diff --git a/pkgs/servers/monitoring/uchiwa/bower-packages.nix b/pkgs/servers/monitoring/uchiwa/bower-packages.nix
new file mode 100644
index 000000000000..f18ea3875516
--- /dev/null
+++ b/pkgs/servers/monitoring/uchiwa/bower-packages.nix
@@ -0,0 +1,25 @@
+# Generated by bower2nix v3.2.0 (https://github.com/rvl/bower2nix)
+{ fetchbower, buildEnv }:
+buildEnv { name = "bower-env"; ignoreCollisions = true; paths = [
+  (fetchbower "uchiwa-web" "1.2.0" "1.2.0" "0733ha6bahzg9qlvhz75agi8hwwqdk99hfx9j8dhpdf1v5xkj2fz")
+  (fetchbower "angular" "1.6.10" "~1.6.3" "0ag8xddsgxx5yka4wjq4ala4y6z3x2g1vc3x7a1n291fzz26p7ws")
+  (fetchbower "angular-bootstrap" "2.2.0" "~2.2.0" "11r2nlwp6xrim2y6lnrr8v064mx3bmlxchqpg1i803v9zxz3q53d")
+  (fetchbower "angular-cookies" "1.6.10" "~1.6.3" "0bjgmz5jnw06dfxhq9sajj62fk0b3v4j9p7nb45x8bl8rzkf25pn")
+  (fetchbower "angular-gravatar" "0.4.2" "~0.4.2" "14jrzvjwx64awh9z95054manp8qd57fvinqhmakipz5x12i7qrwi")
+  (fetchbower "angular-moment" "1.0.1" "~1.0.1" "0zkn52s9l15d6b5zfx52g5jpib23rpb637m0p1hzc429w5bbl0rj")
+  (fetchbower "angular-resource" "1.6.10" "~1.6.3" "1gplq8kd49qakk7ardg5xr5amwvspaz9n71kf8x49xfllda61rm0")
+  (fetchbower "angular-route" "1.6.10" "~1.6.3" "0vwbn7i45yvsn8c469nj141ahrn7iw85j7hy3vvhh2r373j94mai")
+  (fetchbower "angular-sanitize" "1.6.10" "~1.6.3" "066gsdl19s27w00wafg2skf5abdsdrlzhkcagkk1ma39dyqyl4i3")
+  (fetchbower "angular-toastr" "1.6.0" "1.6.0" "1szigf1m28bgpfyg8hbm5rffr5zi7wr9n73nc1fqhk0yqh7gzysh")
+  (fetchbower "angular-tools/ng-jsoneditor" "ea138469f157d8f2b54ec5b8dcf4b08a55b61459" "ea138469f157d8f2b54ec5b8dcf4b08a55b61459" "1j3vysr01niabc9fxcpixhcq1lyx2fr4q4wpmxhmiqki431h9hq8")
+  (fetchbower "angular-ua-parser" "0.0.2" "0.0.2" "0gb0vmwksnydlm6hklfq1n4ak2967wcmnx3cx9cgiv7v7vk3w2m9")
+  (fetchbower "bootstrap" "3.1.1" "3.1.1" "1a06mx1rw5h4wq89kqpa8g2pbiddm3p21dxq50jyi29sywd01ny4")
+  (fetchbower "bootstrap-sass-official" "3.1.1" "3.1.1" "1k6hhvsd75hdfrz8qcjzmb12c17fdn0h3l3l5k9wgd0rfhhfkyvd")
+  (fetchbower "fontawesome" "4.4.0" "~4.4.0" "09mrbik8i3skjwchn7ns2020bqmb51kbd3mqi59vh444s4az2sc7")
+  (fetchbower "highlightjs" "9.1.0" "~9.1.0" "0ld1da3h416a5j8v3v50rrpm4xwvvq8k8y2vwncvaqm9cqddz4s3")
+  (fetchbower "moment" "2.16.0" "~2.16.0" "1mji892i60f2aw3vhl6878acrcgh0ycn3r4af0ivnjf8az2b9n71")
+  (fetchbower "moment-picker" "0.9.11" "~0.9.7" "0p2g6rp2kcixydrga9lfihg4bxb598rvpi8n8l59mp549diy7vsb")
+  (fetchbower "ua-parser-js" "0.7.17" "~0.7.12" "1dx46rm9han9fj409rjxrlnrk9zxmaqbnn62ljnh32ihngd4yxh0")
+  (fetchbower "jsoneditor" "5.5.11" "~5.5.10" "1gfsf8jqnd3hb3r9s9246mg40iqxk2ix8k4bjnrsbfmg6cd3xw6x")
+  (fetchbower "jquery" "3.3.1" ">= 1.9.0" "1l891s3vgnpi1g8ksplid9jvrvnnv6lci8vraix4ssy50i264rkx")
+]; }
diff --git a/pkgs/servers/monitoring/uchiwa/default.nix b/pkgs/servers/monitoring/uchiwa/default.nix
new file mode 100644
index 000000000000..e7cf3e8f70e4
--- /dev/null
+++ b/pkgs/servers/monitoring/uchiwa/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchFromGitHub, buildBowerComponents, buildGoPackage, makeWrapper }:
+
+let
+  inherit (import ./src.nix) version sha256;
+  owner = "sensu";
+  repo = "uchiwa";
+
+  src = fetchFromGitHub {
+    inherit owner repo sha256;
+    rev    = "${version}";
+  };
+
+  backend = buildGoPackage {
+    name = "uchiwa-backend-${version}";
+    goPackagePath = "github.com/${owner}/${repo}";
+    inherit src;
+    postInstall = ''
+      cp go/src/github.com/sensu/uchiwa/public/index.html $out/
+    '';
+  };
+
+  frontend = buildBowerComponents {
+    name = "uchiwa-frontend-${version}";
+    generated = ./bower-packages.nix;
+    inherit src;
+  };
+
+in stdenv.mkDerivation rec {
+  name = "uchiwa-${version}";
+
+  inherit src;
+
+  buildInputs = [ makeWrapper ];
+
+  buildCommand = ''
+    mkdir -p $out/bin $out/public
+    makeWrapper ${backend.bin}/bin/uchiwa $out/bin/uchiwa \
+      --add-flags "-p $out/public"
+    ln -s ${backend.out}/index.html $out/public/index.html
+    ln -s ${frontend.out}/bower_components $out/public/bower_components
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A Dashboard for the sensu monitoring framework";
+    homepage    = http://sensuapp.org/;
+    license     = licenses.mit;
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/monitoring/uchiwa/src.nix b/pkgs/servers/monitoring/uchiwa/src.nix
new file mode 100644
index 000000000000..0cf6815fbe5d
--- /dev/null
+++ b/pkgs/servers/monitoring/uchiwa/src.nix
@@ -0,0 +1,4 @@
+{
+    version = "1.2.0-1";
+    sha256  = "1gj9cr0gkiivxdlq7ha6gxq9s8s26j79crijkrlrsqpg59jz063p";
+}
diff --git a/pkgs/servers/monitoring/uchiwa/update.sh b/pkgs/servers/monitoring/uchiwa/update.sh
new file mode 100755
index 000000000000..10da7f8adbf9
--- /dev/null
+++ b/pkgs/servers/monitoring/uchiwa/update.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl.bin git.out nix jq.out nodePackages.bower2nix
+
+set -euo pipefail
+IFS=$'\n\t'
+
+# set -x
+
+REPO=sensu/uchiwa
+VERSION=0.0.1
+SHA="1111111111111111111111111111111111111111111111111111"
+DIR=$(pwd)
+
+write_src() {
+  cat <<_EOF > $DIR/src.nix
+{
+    version = "${VERSION}";
+    sha256  = "${SHA}";
+}
+_EOF
+}
+
+LATEST_VERSION=$(curl https://api.github.com/repos/${REPO}/tags -s | jq '.[0]' -r | jq .name -r)
+echo "Latest version: ${LATEST_VERSION}"
+
+VERSION=${1:-${LATEST_VERSION}}
+echo "Updating to: ${VERSION}"
+
+TOP=$(git rev-parse --show-toplevel)
+
+cd $(dirname $0)
+
+write_src
+pushd $TOP >/dev/null
+SHA=$(nix-prefetch-url -A uchiwa.src)
+popd >/dev/null
+write_src
+
+curl https://raw.githubusercontent.com/${REPO}/${VERSION}/bower.json -s > bower.json
+rm -f bower-packages.nix
+bower2nix bower.json $DIR/bower-packages.nix
+rm -f bower.json
diff --git a/pkgs/servers/monitoring/zabbix/2.0.nix b/pkgs/servers/monitoring/zabbix/2.0.nix
index 0aa32a66f0a5..da2d1388c469 100644
--- a/pkgs/servers/monitoring/zabbix/2.0.nix
+++ b/pkgs/servers/monitoring/zabbix/2.0.nix
@@ -5,12 +5,12 @@ assert enableJabber -> minmay != null;
 
 let
 
-  version = "2.0.11";
+  version = "2.0.21";
   branch = "2.0";
 
   src = fetchurl {
     url = "mirror://sourceforge/zabbix/zabbix-${version}.tar.gz";
-    sha256 = "1vqxlqwhnz02wrca08vrqbq8k19qp84hbdplmqk7d9699njim46i";
+    sha256 = "14g22x2zy5xqnh2xg23xy5gjd49d1i8pks7pkidwdwa9acwgfx71";
   };
 
   preConfigure =
@@ -18,7 +18,7 @@ let
       substituteInPlace ./configure \
         --replace " -static" "" \
         ${stdenv.lib.optionalString (stdenv.cc.libc != null) ''
-          --replace /usr/include/iconv.h ${stdenv.cc.libc}/include/iconv.h
+          --replace /usr/include/iconv.h ${stdenv.lib.getDev stdenv.cc.libc}/include/iconv.h
         ''}
     '';
 
@@ -48,7 +48,8 @@ in
         -e 's/iks/mmay/g' -e 's/IKS/MMAY/g' src/libs/zbxmedia/jabber.c
     '';
 
-    buildInputs = [ pkgconfig postgresql curl openssl zlib ];
+  nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ postgresql curl openssl zlib ];
 
     postInstall =
       ''
@@ -84,7 +85,7 @@ in
       homepage = http://www.zabbix.com/;
       license = licenses.gpl2;
       maintainers = [ maintainers.eelco ];
-      platforms = platforms.linux ++ platforms.darwin;
+      platforms = platforms.linux;
     };
   };
 
diff --git a/pkgs/servers/monitoring/zabbix/2.2.nix b/pkgs/servers/monitoring/zabbix/2.2.nix
index 139786ba59d0..1cc604f6491b 100644
--- a/pkgs/servers/monitoring/zabbix/2.2.nix
+++ b/pkgs/servers/monitoring/zabbix/2.2.nix
@@ -10,12 +10,12 @@ assert enableJabber -> minmay != null;
 
 let
 
-  version = "2.2.2";
+  version = "2.2.20";
   branch = "2.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/zabbix/zabbix-${version}.tar.gz";
-    sha256 = "1gmjbjmajdllzd7akihb5kg4l2gf0ii9c16fq8mlla37sshzj3p0";
+    sha256 = "00pfpyj3vydwx9dn0bklh1p5j0bp2awi4hvv4kgliyav8l0416hk";
   };
 
   preConfigure =
@@ -23,7 +23,7 @@ let
       substituteInPlace ./configure \
         --replace " -static" "" \
         ${stdenv.lib.optionalString (stdenv.cc.libc != null) ''
-          --replace /usr/include/iconv.h ${stdenv.cc.libc}/include/iconv.h
+          --replace /usr/include/iconv.h ${stdenv.lib.getDev stdenv.cc.libc}/include/iconv.h
         ''}
     '';
 
@@ -46,8 +46,8 @@ in
     ]
     ++ stdenv.lib.optional enableJabber "--with-jabber=${minmay}"
     ++ stdenv.lib.optional enableSnmp "--with-net-snmp"
-    ++ stdenv.lib.optional enableSsh "--with-ssh2=${libssh2}"
-    ++ stdenv.lib.optional enableLdap "--with-ldap=${openldap}";
+    ++ stdenv.lib.optional enableSsh "--with-ssh2=${libssh2.dev}"
+    ++ stdenv.lib.optional enableLdap "--with-ldap=${openldap.dev}";
 
     postPatch = ''
       sed -i -e 's/iksemel/minmay/g' configure src/libs/zbxmedia/jabber.c
@@ -57,7 +57,8 @@ in
         -e 's/iks/mmay/g' -e 's/IKS/MMAY/g' src/libs/zbxmedia/jabber.c
     '';
 
-    buildInputs = [ pkgconfig postgresql curl openssl zlib ]
+  nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ postgresql curl openssl zlib ]
       ++ stdenv.lib.optional enableSnmp net_snmp
       ++ stdenv.lib.optional enableSsh libssh2
       ++ stdenv.lib.optional enableLdap openldap;
@@ -96,7 +97,7 @@ in
       homepage = http://www.zabbix.com/;
       license = licenses.gpl2;
       maintainers = [ maintainers.eelco ];
-      platforms = platforms.linux ++ platforms.darwin;
+      platforms = platforms.linux;
     };
   };
 
diff --git a/pkgs/servers/monitoring/zabbix/3.4.nix b/pkgs/servers/monitoring/zabbix/3.4.nix
new file mode 100644
index 000000000000..332e139f4283
--- /dev/null
+++ b/pkgs/servers/monitoring/zabbix/3.4.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, pkgconfig, postgresql, curl, openssl, zlib, pcre, libevent, libiconv }:
+
+
+let
+
+  version = "3.4.8";
+  branch = "3.4";
+
+  src = fetchurl {
+    url = "https://netix.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/${version}/zabbix-${version}.tar.gz";
+    sha256 = "cec14993d1ec2c9d8c51f6608c9408620f27174db92edc2347bafa7b841ccc07";
+  };
+
+in
+
+{
+  agent = stdenv.mkDerivation {
+    name = "zabbix-agent-${version}";
+
+    inherit src;
+
+     configureFlags = [
+      "--enable-agent"
+      "--with-libpcre=${pcre.dev}"
+      "--with-iconv=${libiconv}"
+    ];
+    buildInputs = [ pcre libiconv ];
+
+    meta = with stdenv.lib; {
+      inherit branch;
+      description = "An enterprise-class open source distributed monitoring solution (client-side agent)";
+      homepage = http://www.zabbix.com/;
+      license = licenses.gpl2;
+      maintainers = [ maintainers.eelco ];
+      platforms = platforms.linux;
+    };
+  };
+
+}
+
diff --git a/pkgs/servers/monitoring/zabbix/default.nix b/pkgs/servers/monitoring/zabbix/default.nix
index 0aa74599c3a4..be52698ed839 100644
--- a/pkgs/servers/monitoring/zabbix/default.nix
+++ b/pkgs/servers/monitoring/zabbix/default.nix
@@ -14,7 +14,7 @@ let
       substituteInPlace ./configure \
         --replace " -static" "" \
         ${stdenv.lib.optionalString (stdenv.cc.libc != null) ''
-          --replace /usr/include/iconv.h ${stdenv.cc.libc}/include/iconv.h
+          --replace /usr/include/iconv.h ${stdenv.lib.getDev stdenv.cc.libc}/include/iconv.h
         ''}
     '';
 
@@ -29,7 +29,8 @@ in
 
     configureFlags = "--enable-agent --enable-server --with-pgsql --with-libcurl";
 
-    buildInputs = [ pkgconfig postgresql curl openssl zlib ];
+  nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ postgresql curl openssl zlib ];
 
     postInstall =
       ''
@@ -43,7 +44,7 @@ in
 
     meta = {
       description = "An enterprise-class open source distributed monitoring solution";
-      homepage = http://www.zabbix.com/;
+      homepage = https://www.zabbix.com/;
       license = "GPL";
       maintainers = [ stdenv.lib.maintainers.eelco ];
       platforms = stdenv.lib.platforms.linux;
@@ -59,10 +60,10 @@ in
 
     meta = with stdenv.lib; {
       description = "An enterprise-class open source distributed monitoring solution (client-side agent)";
-      homepage = http://www.zabbix.com/;
+      homepage = https://www.zabbix.com/;
       license = licenses.gpl2;
       maintainers = [ maintainers.eelco ];
-      platforms = platforms.linux ++ platforms.darwin;
+      platforms = platforms.linux;
     };
   };
 
diff --git a/pkgs/servers/monitoring/zipkin/default.nix b/pkgs/servers/monitoring/zipkin/default.nix
new file mode 100644
index 000000000000..2925a8f2dc53
--- /dev/null
+++ b/pkgs/servers/monitoring/zipkin/default.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchurl, makeWrapper, jre}:
+stdenv.mkDerivation rec {
+  version = "1.28.1";
+  name = "zipkin-server-${version}";
+  src = fetchurl {
+    url = "https://search.maven.org/remotecontent?filepath=io/zipkin/java/zipkin-server/${version}/zipkin-server-${version}-exec.jar";
+    sha256 = "02369fkv0kbl1isq6y26fh2zj5wxv3zck522m5wypsjlcfcw2apa";
+  };
+  buildInputs = [ makeWrapper ];
+
+  buildCommand =
+  ''
+    mkdir -p $out/share/java
+    cp ${src} $out/share/java/zipkin-server-${version}-exec.jar
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/zipkin-server \
+      --add-flags "-cp $out/share/java/zipkin-server-${version}-exec.jar org.springframework.boot.loader.JarLauncher"
+  '';
+  meta = with stdenv.lib; {
+    description = "Zipkin distributed tracing system";
+    homepage = "http://zipkin.io/";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.hectorj ];
+  };
+}
diff --git a/pkgs/servers/mpd/clientlib.nix b/pkgs/servers/mpd/clientlib.nix
index 41e3b547f70e..478d43722679 100644
--- a/pkgs/servers/mpd/clientlib.nix
+++ b/pkgs/servers/mpd/clientlib.nix
@@ -1,26 +1,24 @@
-{ stdenv, fetchurl, doxygen }:
+{ stdenv, fetchFromGitHub, meson, ninja, fixDarwinDylibNames }:
 
 stdenv.mkDerivation rec {
-  version = "${passthru.majorVersion}.${passthru.minorVersion}";
+  version = "2.14";
   name = "libmpdclient-${version}";
 
-  src = fetchurl {
-    url = "http://www.musicpd.org/download/libmpdclient/2/${name}.tar.xz";
-    sha256 = "10pzs9z815a8hgbbbiliapyiw82bnplsccj5irgqjw5f5plcs22g";
+  src = fetchFromGitHub {
+    owner  = "MusicPlayerDaemon";
+    repo   = "libmpdclient";
+    rev    = "v${version}";
+    sha256 = "15vn9m4qcsccff5rg7jkzy5503skz6bmqqk6qc2smgvjgwn533sm";
   };
 
-  buildInputs = [ doxygen ];
-
-  passthru = {
-    majorVersion = "2";
-    minorVersion = "10";
-  };
+  nativeBuildInputs = [ meson ninja ]
+  ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   meta = with stdenv.lib; {
     description = "Client library for MPD (music player daemon)";
-    homepage = http://www.musicpd.org/libs/libmpdclient/;
+    homepage = https://www.musicpd.org/libs/libmpdclient/;
     license = licenses.gpl2;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ mornfall emery ];
+    maintainers = with maintainers; [ ehmry ];
   };
 }
diff --git a/pkgs/servers/mpd/default.nix b/pkgs/servers/mpd/default.nix
index c7380b023067..fde66a71e2e6 100644
--- a/pkgs/servers/mpd/default.nix
+++ b/pkgs/servers/mpd/default.nix
@@ -1,5 +1,6 @@
-{ stdenv, fetchurl, pkgconfig, glib, systemd, boost
+{ stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, pkgconfig, glib, systemd, boost, darwin
 , alsaSupport ? true, alsaLib
+, avahiSupport ? true, avahi, dbus
 , flacSupport ? true, flac
 , vorbisSupport ? true, libvorbis
 , madSupport ? true, libmad
@@ -17,30 +18,43 @@
 , mmsSupport ? true, libmms
 , mpg123Support ? true, mpg123
 , aacSupport ? true, faad2
+, lameSupport ? true, lame
 , pulseaudioSupport ? true, libpulseaudio
 , jackSupport ? true, libjack2
 , gmeSupport ? true, game-music-emu
 , icuSupport ? true, icu
-, clientSupport ? false, mpd_clientlib
+, clientSupport ? true, mpd_clientlib
 , opusSupport ? true, libopus
+, soundcloudSupport ? true, yajl
 }:
 
+assert avahiSupport -> avahi != null && dbus != null;
+
 let
   opt = stdenv.lib.optional;
   mkFlag = c: f: if c then "--enable-${f}" else "--disable-${f}";
-  major = "0.19";
-  minor = "9";
+  major = "0.20";
+  minor = "18";
 
 in stdenv.mkDerivation rec {
-  name = "mpd-${major}.${minor}";
-  src = fetchurl {
-    url    = "http://www.musicpd.org/download/mpd/${major}/${name}.tar.xz";
-    sha256 = "0vzj365s4j0pw5w37lfhx3dmpkdp85driravsvx8rlrw0lii91a7";
+  name = "mpd-${version}";
+  version = "${major}${if minor == "" then "" else "." + minor}";
+
+  src = fetchFromGitHub {
+    owner  = "MusicPlayerDaemon";
+    repo   = "MPD";
+    rev    = "v${version}";
+    sha256 = "020vdn94fwjbldnkgr2h3dk9sm6f5k59qic568mw88yi7cr3mjsh";
   };
 
-  buildInputs = [ pkgconfig glib boost ]
+  patches = [ ./x86.patch ];
+
+  buildInputs = [ glib boost ]
+    ++ opt stdenv.isDarwin darwin.apple_sdk.frameworks.CoreAudioKit
     ++ opt stdenv.isLinux systemd
     ++ opt (stdenv.isLinux && alsaSupport) alsaLib
+    ++ opt avahiSupport avahi
+    ++ opt avahiSupport dbus
     ++ opt flacSupport flac
     ++ opt vorbisSupport libvorbis
     # using libmad to decode mp3 files on darwin is causing a segfault -- there
@@ -59,13 +73,19 @@ in stdenv.mkDerivation rec {
     ++ opt mmsSupport libmms
     ++ opt mpg123Support mpg123
     ++ opt aacSupport faad2
+    ++ opt lameSupport lame
     ++ opt zipSupport zziplib
-    ++ opt pulseaudioSupport libpulseaudio
-    ++ opt jackSupport libjack2
+    ++ opt (!stdenv.isDarwin && pulseaudioSupport) libpulseaudio
+    ++ opt (!stdenv.isDarwin && jackSupport) libjack2
     ++ opt gmeSupport game-music-emu
     ++ opt icuSupport icu
     ++ opt clientSupport mpd_clientlib
-    ++ opt opusSupport libopus;
+    ++ opt opusSupport libopus
+    ++ opt soundcloudSupport yajl;
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  enableParallelBuilding = true;
 
   configureFlags =
     [ (mkFlag (!stdenv.isDarwin && alsaSupport) "alsa")
@@ -87,14 +107,17 @@ in stdenv.mkDerivation rec {
       (mkFlag mmsSupport "mms")
       (mkFlag mpg123Support "mpg123")
       (mkFlag aacSupport "aac")
-      (mkFlag pulseaudioSupport "pulse")
-      (mkFlag jackSupport "jack")
+      (mkFlag lameSupport "lame-encoder")
+      (mkFlag (!stdenv.isDarwin && pulseaudioSupport) "pulse")
+      (mkFlag (!stdenv.isDarwin && jackSupport) "jack")
       (mkFlag stdenv.isDarwin "osx")
       (mkFlag icuSupport "icu")
       (mkFlag gmeSupport "gme")
       (mkFlag clientSupport "libmpdclient")
       (mkFlag opusSupport "opus")
+      (mkFlag soundcloudSupport "soundcloud")
       "--enable-debug"
+      "--with-zeroconf=avahi"
     ]
     ++ opt stdenv.isLinux
       "--with-systemdsystemunitdir=$(out)/etc/systemd/system";
@@ -107,7 +130,7 @@ in stdenv.mkDerivation rec {
     description = "A flexible, powerful daemon for playing music";
     homepage    = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki;
     license     = licenses.gpl2;
-    maintainers = with maintainers; [ astsmtl fuuzetsu emery ];
+    maintainers = with maintainers; [ astsmtl fuuzetsu ehmry fpletz ];
     platforms   = platforms.unix;
 
     longDescription = ''
diff --git a/pkgs/servers/mpd/x86.patch b/pkgs/servers/mpd/x86.patch
new file mode 100644
index 000000000000..3e4c036418d2
--- /dev/null
+++ b/pkgs/servers/mpd/x86.patch
@@ -0,0 +1,12 @@
+--- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx
++++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
+@@ -20,8 +20,8 @@
+ /* necessary because libavutil/common.h uses UINT64_C */
+ #define __STDC_CONSTANT_MACROS
+ 
+-#include "lib/ffmpeg/Time.hxx"
+ #include "config.h"
++#include "lib/ffmpeg/Time.hxx"
+ #include "FfmpegDecoderPlugin.hxx"
+ #include "lib/ffmpeg/Domain.hxx"
+ #include "lib/ffmpeg/Error.hxx"
diff --git a/pkgs/servers/mqtt/mosquitto/default.nix b/pkgs/servers/mqtt/mosquitto/default.nix
index 4fdb475d89b8..bce69370d2bd 100644
--- a/pkgs/servers/mqtt/mosquitto/default.nix
+++ b/pkgs/servers/mqtt/mosquitto/default.nix
@@ -1,23 +1,29 @@
-{ stdenv, fetchurl, openssl, libuuid }:
+{ stdenv, fetchurl, openssl, libuuid, cmake, libwebsockets, c-ares, libuv }:
 
 stdenv.mkDerivation rec {
   pname = "mosquitto";
-  version = "1.4";
+  version = "1.4.15";
 
   name = "${pname}-${version}";
 
   src = fetchurl {
-    url = http://mosquitto.org/files/source/mosquitto-1.4.tar.gz;
-    sha256 = "1imw5ps0cqda41b574k8hgz9gdr8yy58f76fg8gw14pdnvf3l7sr";
+    url = "http://mosquitto.org/files/source/mosquitto-${version}.tar.gz";
+    sha256 = "10wsm1n4y61nz45zwk4zjhvrfd86r2cq33370m5wjkivb8j3wfvx";
   };
 
-  buildInputs = [ openssl libuuid ];
+  buildInputs = [ openssl libuuid libwebsockets c-ares libuv ]
+    ++ stdenv.lib.optional stdenv.isDarwin cmake;
 
-  buildFlags = "mosquitto";
+  makeFlags = stdenv.lib.optionals stdenv.isLinux [
+    "DESTDIR=$(out)"
+    "PREFIX="
+  ];
 
-  installPhase = ''
-    mkdir -p $out/bin
-    cp src/mosquitto $out/bin/
+  postPatch = ''
+    substituteInPlace config.mk \
+      --replace "/usr/local" ""
+    substituteInPlace config.mk \
+      --replace "WITH_WEBSOCKETS:=no" "WITH_WEBSOCKETS:=yes"
   '';
 
   meta = {
diff --git a/pkgs/servers/nas/default.nix b/pkgs/servers/nas/default.nix
new file mode 100644
index 000000000000..1dba428e0ae9
--- /dev/null
+++ b/pkgs/servers/nas/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchurl, imake, bison, flex_2_6_1, gccmakedep
+, xproto, libXau, libXt, libXext, libXaw, libXpm, xorgcffiles }:
+
+let
+  pname = "nas";
+  version = "1.9.4";
+in stdenv.mkDerivation {
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${pname}-${version}.src.tar.gz";
+    sha256 = "17dk0ckm6mp1ajc0cd6bwyi638ynw2f6bhbn7gynrs0wfmiyldng";
+  };
+
+  nativeBuildInputs = [ imake bison flex_2_6_1 gccmakedep ];
+
+  buildInputs = [ xproto libXau libXt libXext libXaw libXpm ];
+
+  buildPhase = ''
+    xmkmf
+    make WORLDOPTS="" World
+  '';
+
+  installFlags = "LDLIBS=-lfl DESTDIR=\${out}";
+
+  postInstall = ''
+    mv $out/${xorgcffiles}/* $out
+    rm -r $out/nix
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A network transparent, client/server audio transport system";
+    homepage = http://radscan.com/nas.html;
+    license = licenses.mit;
+    maintainers = [ maintainers.gnidorah ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/neard/default.nix b/pkgs/servers/neard/default.nix
index 995ffc41c60e..de317ada6e45 100644
--- a/pkgs/servers/neard/default.nix
+++ b/pkgs/servers/neard/default.nix
@@ -1,15 +1,16 @@
-{ stdenv, fetchgit, autoreconfHook, pkgconfig, systemd, glib, dbus, libnl, pythonPackages }:
+{ stdenv, fetchurl, autoreconfHook, pkgconfig, systemd, glib, dbus, libnl, pythonPackages }:
 
 stdenv.mkDerivation rec {
-  name = "neard-0.15-post-git-20510929";
+  name = "neard-0.16";
 
-  src = fetchgit {
-    url    = "https://git.kernel.org/pub/scm/network/nfc/neard.git";
-    sha256 = "08327b536ad8460a08bdceeec48c561e75ca56e5e0ee034c40d02cd1545906c0";
+  src = fetchurl {
+    url = "https://git.kernel.org/pub/scm/network/nfc/neard.git/snapshot/${name}.tar.gz";
+    sha256 = "0bpdmyxvd3z54p95apz4bjb5jp8hbc04sicjapcryjwa8mh6pbil";
   };
 
-  buildInputs = [ autoreconfHook pkgconfig systemd glib dbus libnl pythonPackages.python pythonPackages.wrapPython ];
-  pythonPath = [ pythonPackages.pygobject pythonPackages.dbus pythonPackages.pygtk ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ systemd glib dbus libnl pythonPackages.python pythonPackages.wrapPython ];
+  pythonPath = [ pythonPackages.pygobject2 pythonPackages.dbus-python pythonPackages.pygtk ];
 
   configureFlags = [ "--disable-debug" "--enable-tools" "--enable-ese" "--with-systemdsystemunitdir=$out/lib/systemd/system" ];
 
diff --git a/pkgs/servers/news/leafnode/default.nix b/pkgs/servers/news/leafnode/default.nix
index a3579aa83099..6d2bb9b9e949 100644
--- a/pkgs/servers/news/leafnode/default.nix
+++ b/pkgs/servers/news/leafnode/default.nix
@@ -10,6 +10,10 @@ stdenv.mkDerivation rec {
 
   configureFlags = "--enable-runas-user=nobody";
 
+  prePatch = ''
+    substituteInPlace Makefile.in --replace 02770 0770
+  '';
+
   preConfigure = ''
     # configure uses id to check environment; we don't want this check
     sed -re 's/^ID[=].*/ID="echo whatever"/' -i configure
@@ -25,7 +29,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ pcre];
 
   meta = {
-    homepage = "http://leafnode.sourceforge.net/";
+    homepage = http://leafnode.sourceforge.net/;
     description = "Leafnode implements a store & forward NNTP proxy";
     license = stdenv.lib.licenses.mit;
     platforms = stdenv.lib.platforms.unix;
diff --git a/pkgs/servers/nextcloud/default.nix b/pkgs/servers/nextcloud/default.nix
new file mode 100644
index 000000000000..0121d748129b
--- /dev/null
+++ b/pkgs/servers/nextcloud/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  name= "nextcloud-${version}";
+  version = "13.0.4";
+
+  src = fetchurl {
+    url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
+    sha256 = "18d514145fcddc86f48d0a5fa4a0d4b07617135a1b23107137a6ea3ed519bd54";
+  };
+
+  installPhase = ''
+    mkdir -p $out/
+    cp -R . $out/
+  '';
+
+  meta = {
+    description = "Sharing solution for files, calendars, contacts and more";
+    homepage = https://nextcloud.com;
+    maintainers = with stdenv.lib.maintainers; [ schneefux bachp ];
+    license = stdenv.lib.licenses.agpl3Plus;
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/pkgs/servers/nextcloud/news-updater.nix b/pkgs/servers/nextcloud/news-updater.nix
new file mode 100644
index 000000000000..0fcb5047549d
--- /dev/null
+++ b/pkgs/servers/nextcloud/news-updater.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, python3Packages, php }:
+
+python3Packages.buildPythonApplication rec {
+  name = "nextcloud-news-updater-${version}";
+  version = "10.0.1";
+
+  src = fetchurl {
+    url = "mirror://pypi/n/nextcloud_news_updater/nextcloud_news_updater-${version}.tar.gz";
+    sha256 = "14jj3w417wfsm1ki34d980b0s6vfn8i29g4c66qb2fizdq1d0z6q";
+  };
+
+  doCheck = false;
+
+  propagatedBuildInputs = [ php ];
+
+  meta = {
+    description = "Fast parallel feed updater for the Nextcloud news app";
+    homepage = https://github.com/nextcloud/news-updater;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ schneefux ];
+  };
+}
diff --git a/pkgs/servers/nosql/apache-jena/binary.nix b/pkgs/servers/nosql/apache-jena/binary.nix
index 9b4e19b32708..f3d5d121c387 100644
--- a/pkgs/servers/nosql/apache-jena/binary.nix
+++ b/pkgs/servers/nosql/apache-jena/binary.nix
@@ -3,10 +3,10 @@ let
   s = # Generated upstream information
   rec {
     baseName="apache-jena";
-    version = "3.0.0";
+    version = "3.7.0";
     name="${baseName}-${version}";
     url="http://archive.apache.org/dist/jena/binaries/apache-jena-${version}.tar.gz";
-    sha256 = "1pqg27m295v7v456pidb0fq5120blkc466pdzksqxqcjrwivq4kb";
+    sha256 = "12w125hlhcib23cckk77cx7p9rzs57dbmmn90f7v8107d437j4mq";
   };
   buildInputs = [
     makeWrapper
@@ -30,9 +30,9 @@ stdenv.mkDerivation {
     license = stdenv.lib.licenses.asl20;
     maintainers = [stdenv.lib.maintainers.raskin];
     platforms = stdenv.lib.platforms.linux;
-    homepage = "http://jena.apache.org";
+    homepage = http://jena.apache.org;
     downloadPage = "http://archive.apache.org/dist/jena/binaries/";
     updateWalker = true;
-    downloadURLRegex = "apache-jena-.*[.]tar[.]gz\$";
+    downloadURLRegexp = "apache-jena-.*[.]tar[.]gz\$";
   };
 }
diff --git a/pkgs/servers/nosql/apache-jena/fuseki-binary.nix b/pkgs/servers/nosql/apache-jena/fuseki-binary.nix
new file mode 100644
index 000000000000..bd291356b436
--- /dev/null
+++ b/pkgs/servers/nosql/apache-jena/fuseki-binary.nix
@@ -0,0 +1,41 @@
+{stdenv, fetchurl, java, makeWrapper}:
+let
+  s = # Generated upstream information
+  rec {
+    baseName="apache-jena-fuseki";
+    version = "3.7.0";
+    name="${baseName}-${version}";
+    url="http://archive.apache.org/dist/jena/binaries/apache-jena-fuseki-${version}.tar.gz";
+    sha256 = "1824rvdrs9yhjinac2vkvkxvns8bfdvy91k5ghzzk0nrdcj31pmr";
+  };
+  buildInputs = [
+    makeWrapper
+  ];
+in
+stdenv.mkDerivation {
+  inherit (s) name version;
+  inherit buildInputs;
+  src = fetchurl {
+    inherit (s) url sha256;
+  };
+  installPhase = ''
+    cp -r . "$out"
+    ln -s "$out"/{fuseki-server,fuseki} "$out/bin"
+    for i in "$out"/bin/*; do
+      wrapProgram "$i" \
+        --prefix "PATH" : "${java}/bin/" \
+        --set-default "FUSEKI_HOME" "$out" \
+        ;
+    done
+  '';
+  meta = {
+    inherit (s) version;
+    description = ''SPARQL server'';
+    license = stdenv.lib.licenses.asl20;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = http://jena.apache.org;
+    downloadPage = "http://archive.apache.org/dist/jena/binaries/";
+    downloadURLRegexp = "apache-jena-fuseki-.*[.]tar[.]gz\$";
+  };
+}
diff --git a/pkgs/servers/nosql/apache-jena/fuseki-binary.upstream b/pkgs/servers/nosql/apache-jena/fuseki-binary.upstream
new file mode 100644
index 000000000000..a18675347d58
--- /dev/null
+++ b/pkgs/servers/nosql/apache-jena/fuseki-binary.upstream
@@ -0,0 +1,4 @@
+name apache-jena-fuseki
+attribute apache-jena-fuseki
+target fuseki-binary.nix
+minimize_overwrite
diff --git a/pkgs/servers/nosql/arangodb/default.nix b/pkgs/servers/nosql/arangodb/default.nix
index 4ff12f630c9b..5d1723274cb4 100644
--- a/pkgs/servers/nosql/arangodb/default.nix
+++ b/pkgs/servers/nosql/arangodb/default.nix
@@ -1,31 +1,36 @@
-{ stdenv, fetchFromGitHub, openssl, zlib, python, gyp, bash, go, readline }:
+{ stdenv, fetchFromGitHub
+, openssl, zlib, python2Packages, readline, cmake, python }:
 
-stdenv.mkDerivation rec {
-  version = "2.5.3";
+let
+in stdenv.mkDerivation rec {
+  version = "3.3.9";
   name    = "arangodb-${version}";
 
   src = fetchFromGitHub {
     repo = "arangodb";
     owner = "arangodb";
-    rev = "67d995aa22ea341129398326fa10c5f6c14e94e9";
-    sha256 = "1v07fghf2jd2mvkfqhag0xblf6sxw7kx9kmhs2xpyrpns58lirvc";
+    rev = "v${version}";
+    sha256 = "1zr9byxlqd7s3rnmvdgv85mmk5xxjz0va1pj2gn6y28k569prcbs";
   };
 
   buildInputs = [
-    openssl zlib python gyp go readline
+    openssl zlib readline python
   ];
 
-  configureFlagsArray = [ "--with-openssl-lib=${openssl}/lib" ];
+  nativeBuildInputs = [ cmake ];
 
-  patchPhase = ''
-    substituteInPlace 3rdParty/V8-3.31.74.1/build/gyp/gyp --replace /bin/bash ${bash}/bin/bash
-    substituteInPlace 3rdParty/etcd/build --replace /bin/bash ${bash}/bin/bash
-    '';
+  postPatch = ''
+    sed -ie 's!/bin/echo!echo!' 3rdParty/V8/v*/gypfiles/*.gypi
+  '';
+
+  configureFlagsArray = [ "--with-openssl-lib=${openssl.out}/lib" ];
+
+  NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow";
 
   enableParallelBuilding = true;
 
   meta = with stdenv.lib; {
-    homepage = "https://github.com/arangodb/arangodb";
+    homepage = https://github.com/arangodb/arangodb;
     description = "A native multi-model database with flexible data models for documents, graphs, and key-values";
     license = licenses.asl20;
     platforms = platforms.linux;
diff --git a/pkgs/servers/nosql/cassandra/1.2.nix b/pkgs/servers/nosql/cassandra/1.2.nix
deleted file mode 100644
index 1507787ae003..000000000000
--- a/pkgs/servers/nosql/cassandra/1.2.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ stdenv
-, fetchurl
-, jre
-, python
-, makeWrapper
-, gawk
-, bash
-, getopt
-, procps
-}:
-
-let
-
-  version = "1.2.19";
-  sha256 = "0zkq3ggpk8ra2siar43vmrn6lmvn902p1g2lrgb46ak1vii6w30w";
-
-in
-
-stdenv.mkDerivation rec {
-  name = "cassandra-${version}";
-
-  src = fetchurl {
-    inherit sha256;
-    url = "mirror://apache/cassandra/${version}/apache-${name}-bin.tar.gz";
-  };
-
-  nativeBuildInputs = [ makeWrapper ];
-
-  installPhase = ''
-    mkdir $out
-    mv * $out
-
-    for cmd in cassandra nodetool sstablekeys sstableloader sstableupgrade
-      do wrapProgram $out/bin/$cmd \
-        --set JAVA_HOME ${jre} \
-        --prefix PATH : ${bash}/bin \
-        --prefix PATH : ${getopt}/bin \
-        --prefix PATH : ${gawk}/bin \
-        --prefix PATH : ${procps}/bin
-    done
-
-    wrapProgram $out/bin/cqlsh --prefix PATH : ${python}/bin
-    '';
-
-  meta = with stdenv.lib; {
-    homepage = http://cassandra.apache.org/;
-    description = "A massively scalable open source NoSQL database";
-    platforms = with platforms; all;
-    license = licenses.asl20;
-    maintainers = with maintainers; [ bcarrell ];
-  };
-}
diff --git a/pkgs/servers/nosql/cassandra/2.0.nix b/pkgs/servers/nosql/cassandra/2.0.nix
deleted file mode 100644
index d1c76c83a7ee..000000000000
--- a/pkgs/servers/nosql/cassandra/2.0.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ stdenv
-, fetchurl
-, jre
-, python
-, makeWrapper
-, gawk
-, bash
-, getopt
-, procps
-}:
-
-let
-
-  version = "2.0.16";
-  sha256 = "1fpvgmakmxy1lnygccpc32q53pa36bwy0lqdvb6hsifkxymdw8y5";
-
-in
-
-stdenv.mkDerivation rec {
-  name = "cassandra-${version}";
-
-  src = fetchurl {
-    inherit sha256;
-    url = "mirror://apache/cassandra/${version}/apache-${name}-bin.tar.gz";
-  };
-
-  nativeBuildInputs = [ makeWrapper ];
-
-  installPhase = ''
-    mkdir $out
-    mv * $out
-
-    for cmd in cassandra nodetool sstablekeys sstableloader sstableupgrade
-      do wrapProgram $out/bin/$cmd \
-        --set JAVA_HOME ${jre} \
-        --prefix PATH : ${bash}/bin \
-        --prefix PATH : ${getopt}/bin \
-        --prefix PATH : ${gawk}/bin \
-        --prefix PATH : ${procps}/bin
-    done
-
-    wrapProgram $out/bin/cqlsh --prefix PATH : ${python}/bin
-    '';
-
-  meta = with stdenv.lib; {
-    homepage = http://cassandra.apache.org/;
-    description = "A massively scalable open source NoSQL database";
-    platforms = with platforms; all;
-    license = licenses.asl20;
-    maintainers = with maintainers; [ nckx rushmorem ];
-  };
-}
diff --git a/pkgs/servers/nosql/cassandra/2.1.nix b/pkgs/servers/nosql/cassandra/2.1.nix
index fe580189583e..fd3b2d3aa286 100644
--- a/pkgs/servers/nosql/cassandra/2.1.nix
+++ b/pkgs/servers/nosql/cassandra/2.1.nix
@@ -1,52 +1,6 @@
-{ stdenv
-, fetchurl
-, jre
-, python
-, makeWrapper
-, gawk
-, bash
-, getopt
-, procps
-}:
+{ callPackage, ... } @ args:
 
-let
-
-  version = "2.1.10";
-  sha256 = "0cpb16206dkpiza8cp0adsv87sw0crglm9b4dbz2cka1mmqvs28h";
-
-in
-
-stdenv.mkDerivation rec {
-  name = "cassandra-${version}";
-
-  src = fetchurl {
-    inherit sha256;
-    url = "mirror://apache/cassandra/${version}/apache-${name}-bin.tar.gz";
-  };
-
-  nativeBuildInputs = [ makeWrapper ];
-
-  installPhase = ''
-    mkdir $out
-    mv * $out
-
-    for cmd in cassandra nodetool sstablekeys sstableloader sstableupgrade
-      do wrapProgram $out/bin/$cmd \
-        --set JAVA_HOME ${jre} \
-        --prefix PATH : ${bash}/bin \
-        --prefix PATH : ${getopt}/bin \
-        --prefix PATH : ${gawk}/bin \
-        --prefix PATH : ${procps}/bin
-    done
-
-    wrapProgram $out/bin/cqlsh --prefix PATH : ${python}/bin
-    '';
-
-  meta = with stdenv.lib; {
-    homepage = http://cassandra.apache.org/;
-    description = "A massively scalable open source NoSQL database";
-    platforms = with platforms; all;
-    license = licenses.asl20;
-    maintainers = with maintainers; [ nckx rushmorem ];
-  };
-}
+callPackage ./generic.nix (args // {
+  version = "2.1.19";
+  sha256 = "1qlc62j3hf5831yrrbydn3z19zrn6bpirarinys6bmhshr7mhpyr";
+})
diff --git a/pkgs/servers/nosql/cassandra/2.2.nix b/pkgs/servers/nosql/cassandra/2.2.nix
new file mode 100644
index 000000000000..3d276128c00d
--- /dev/null
+++ b/pkgs/servers/nosql/cassandra/2.2.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix (args // {
+  version = "2.2.11";
+  sha256 = "0r39mm5ibdn9dqv11n4x33vcb5247r6fl6r07l6frqp6i36ilvl6";
+})
diff --git a/pkgs/servers/nosql/cassandra/3.0.nix b/pkgs/servers/nosql/cassandra/3.0.nix
new file mode 100644
index 000000000000..b6621ec95485
--- /dev/null
+++ b/pkgs/servers/nosql/cassandra/3.0.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix (args // {
+  version = "3.0.15";
+  sha256 = "1n92wpp5gm41r4agjwjw9ymnnn114pmaqf04c1dx3fksk100wd5g";
+})
diff --git a/pkgs/servers/nosql/cassandra/3.11.nix b/pkgs/servers/nosql/cassandra/3.11.nix
new file mode 100644
index 000000000000..f18b6256d3f0
--- /dev/null
+++ b/pkgs/servers/nosql/cassandra/3.11.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix (args // {
+  version = "3.11.2";
+  sha256 = "0867i3irsji3qkjpp2s171xmjf2r8yhwzhs24ka8hljxv457f8p9";
+})
diff --git a/pkgs/servers/nosql/cassandra/generic.nix b/pkgs/servers/nosql/cassandra/generic.nix
new file mode 100644
index 000000000000..48875b093a8d
--- /dev/null
+++ b/pkgs/servers/nosql/cassandra/generic.nix
@@ -0,0 +1,71 @@
+{ stdenv, fetchurl, python, makeWrapper, gawk, bash, getopt, procps
+, which, jre, version, sha256, ...
+}:
+
+let
+  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc ];
+  binPath = with stdenv.lib; makeBinPath ([
+    bash
+    getopt
+    gawk
+    which
+    jre
+    procps
+  ]);
+in
+
+stdenv.mkDerivation rec {
+  name = "cassandra-${version}";
+
+  src = fetchurl {
+    inherit sha256;
+    url = "mirror://apache/cassandra/${version}/apache-${name}-bin.tar.gz";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir $out
+    mv * $out
+
+    # Clean up documentation.
+    mkdir -p $out/share/doc/${name}
+    mv $out/CHANGES.txt \
+       $out/LICENSE.txt \
+       $out/NEWS.txt \
+       $out/NOTICE.txt \
+       $out/javadoc \
+       $out/share/doc/${name}
+
+    if [[ -d $out/doc ]]; then
+      mv "$out/doc/"* $out/share/doc/${name}
+      rmdir $out/doc
+    fi
+
+    for cmd in bin/cassandra bin/nodetool bin/sstablekeys \
+      bin/sstableloader bin/sstableupgrade \
+      tools/bin/cassandra-stress tools/bin/cassandra-stressd \
+      tools/bin/sstablemetadata tools/bin/sstableofflinerelevel \
+      tools/bin/token-generator tools/bin/sstablelevelreset; do
+
+      # check if file exists because some bin tools don't exist across all
+      # cassandra versions
+      if [ -f $out/$cmd ]; then
+        wrapProgram $out/$cmd \
+          --suffix-each LD_LIBRARY_PATH : ${libPath} \
+          --prefix PATH : ${binPath} \
+          --set JAVA_HOME ${jre}
+      fi
+    done
+
+    wrapProgram $out/bin/cqlsh --prefix PATH : ${python}/bin
+    '';
+
+  meta = with stdenv.lib; {
+    homepage = http://cassandra.apache.org/;
+    description = "A massively scalable open source NoSQL database";
+    platforms = platforms.unix;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ cransom ];
+  };
+}
diff --git a/pkgs/servers/nosql/eventstore/default.nix b/pkgs/servers/nosql/eventstore/default.nix
index 9cb5dd41c1c3..f97a3a5c1842 100644
--- a/pkgs/servers/nosql/eventstore/default.nix
+++ b/pkgs/servers/nosql/eventstore/default.nix
@@ -1,48 +1,42 @@
-{ stdenv, fetchgit, fetchpatch, git, mono, v8, icu }:
+{ stdenv, fetchFromGitHub, fetchpatch, git, mono, v8 }:
 
 # There are some similarities with the pinta derivation. We should
 # have a helper to make it easy to package these Mono apps.
 
 stdenv.mkDerivation rec {
   name = "EventStore-${version}";
-  version = "3.0.3";
-  src = fetchgit {
-    url = "https://github.com/EventStore/EventStore.git";
-    rev = "a1382252dd1ed0554ddb04015cdb2cbc1b0a65c1";
-    sha256 = "07ir6jlli2q1yvsnyw8r8dfril6h1wmfj98yf7a6k81585v2mc6g";
-    leaveDotGit = true;
+  version = "4.1.1";
+  src = fetchFromGitHub {
+    owner  = "EventStore";
+    repo   = "EventStore";
+    rev    = "oss-v${version}";
+    sha256 = "1069ncb9ps1wi71yw1fzkfd9rfsavccw8xj3a3miwd9x72w8636f";
   };
 
-  patches = [
-    # see: https://github.com/EventStore/EventStore/issues/461
-    (fetchpatch {
-      url = https://github.com/EventStore/EventStore/commit/9a0987f19935178df143a3cf876becaa1b11ffae.patch;
-      sha256 = "04qw0rb1pypa8dqvj94j2mwkc1y6b40zrpkn1d3zfci3k8cam79y";
-    })
-  ];
-
   buildPhase = ''
-    ln -s ${v8}/lib/libv8.so src/libs/libv8.so
-    ln -s ${icu}/lib/libicui18n.so src/libs/libicui18n.so
-    ln -s ${icu}/lib/libicuuc.so src/libs/libicuuc.so
+    mkdir -p src/libs/x64/nixos
+    pushd src/EventStore.Projections.v8Integration
+    cc -o ../libs/x64/nixos/libjs1.so -fPIC -lv8 -shared -std=c++0x *.cpp
+    popd
 
     patchShebangs build.sh
-    ./build.sh js1
-    ./build.sh quick ${version}
+    ./build.sh ${version} release nixos
   '';
 
   installPhase = ''
     mkdir -p $out/{bin,lib/eventstore/clusternode}
     cp -r bin/clusternode/* $out/lib/eventstore/clusternode/
     cat > $out/bin/clusternode << EOF
-    #!/bin/sh
+    #!${stdenv.shell}
     exec ${mono}/bin/mono $out/lib/eventstore/clusternode/EventStore.ClusterNode.exe "\$@"
     EOF
     chmod +x $out/bin/clusternode
   '';
 
-  buildInputs = [ git v8 mono ];
+  nativeBuildInputs = [ git ];
+  buildInputs = [ v8 mono ];
 
+  phases = [ "unpackPhase" "buildPhase" "installPhase" ];
   dontStrip = true;
 
   meta = {
@@ -50,6 +44,6 @@ stdenv.mkDerivation rec {
     description = "Event sourcing database with processing logic in JavaScript";
     license = stdenv.lib.licenses.bsd3;
     maintainers = with stdenv.lib.maintainers; [ puffnfresh ];
-    platforms = with stdenv.lib.platforms; linux;
+    platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/servers/nosql/hyperdex/busybee.nix b/pkgs/servers/nosql/hyperdex/busybee.nix
deleted file mode 100644
index 9fdbbf064b05..000000000000
--- a/pkgs/servers/nosql/hyperdex/busybee.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ stdenv, fetchurl, unzip, autoconf, automake, libtool,
-  libpo6, libe, pkgconfig }:
-
-stdenv.mkDerivation rec {
-  name = "busybee-${version}";
-  version = "0.5.2";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/busybee/archive/releases/${version}.zip";
-    sha256 = "0gr5h2j9rzwarblgcgddnxj39i282rvgn9vqlrcd60dx8c4dkm29";
-  };
-  buildInputs = [
-    autoconf
-    automake
-    libe
-    libpo6
-    libtool
-    pkgconfig
-    unzip
-  ];
-  preConfigure = "autoreconf -i";
-
-  meta = with stdenv.lib; {
-    description = "A high-performance messaging layer";
-    homepage = https://github.com/rescrv/busybee;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/hyperdex/default.nix b/pkgs/servers/nosql/hyperdex/default.nix
deleted file mode 100644
index 659081281ef0..000000000000
--- a/pkgs/servers/nosql/hyperdex/default.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-{ stdenv, fetchurl, makeWrapper, unzip, autoconf, automake, libtool,
-  python, libsodium, pkgconfig, popt, glog, xz, json_c, gperf, yacc,
-  flex, pandoc, help2man, autoconf-archive, callPackage }:
-
-assert stdenv.isLinux;
-
-let
-hyperleveldb = callPackage ./hyperleveldb.nix {};
-libpo6 = callPackage ./libpo6.nix {};
-libe = callPackage ./libe.nix { inherit libpo6; };
-busybee = callPackage ./busybee.nix { inherit libpo6 libe; };
-replicant = callPackage ./replicant.nix {
-  inherit libpo6 libe busybee hyperleveldb;
-};
-libmacaroons = callPackage ./libmacaroons.nix { };
-
-in
-stdenv.mkDerivation rec {
-  name = "hyperdex-${version}";
-  version = "1.5.0";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/HyperDex/archive/releases/${version}.zip";
-    sha256 = "0s1capy2hj45f5rmdb4fk0wxy7vz69krplhba57f6wrkpcz1zb57";
-  };
-
-  buildInputs = [
-    autoconf
-    autoconf-archive
-    automake
-    busybee
-    glog
-    hyperleveldb
-    json_c
-    libe
-    libmacaroons
-    libpo6
-    libtool
-    pkgconfig
-    popt
-    python
-    replicant
-    unzip
-    gperf
-    yacc
-    flex
-    help2man
-    pandoc
-  ];
-  preConfigure = "autoreconf -fi";
-
-  meta = with stdenv.lib; {
-    description = "A scalable, searchable key-value store";
-    homepage = http://hyperdex.org;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/hyperdex/hyperleveldb.nix b/pkgs/servers/nosql/hyperdex/hyperleveldb.nix
deleted file mode 100644
index c39f618f6cb1..000000000000
--- a/pkgs/servers/nosql/hyperdex/hyperleveldb.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ stdenv, fetchurl, unzip, autoconf, automake, libtool }:
-
-stdenv.mkDerivation rec {
-  name = "hyperleveldb-${version}";
-  version = "1.2.1";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/HyperLevelDB/archive/releases/${version}.zip";
-    sha256 = "0xrzhwkrm7f2wz3jn4iqn1dim2pmgjhmpb1fy23fwa06v0q18hw8";
-  };
-  buildInputs = [ unzip autoconf automake libtool ];
-  preConfigure = "autoreconf -i";
-
-  meta = with stdenv.lib; {
-    description = ''A fork of LevelDB intended to meet the needs of
-        HyperDex while remaining compatible with LevelDB.'';
-    homepage = https://github.com/rescrv/HyperLevelDB;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/hyperdex/libe.nix b/pkgs/servers/nosql/hyperdex/libe.nix
deleted file mode 100644
index cc5232e13f22..000000000000
--- a/pkgs/servers/nosql/hyperdex/libe.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-{ stdenv, fetchurl, unzip, autoconf, automake, libtool, libpo6, pkgconfig }:
-
-stdenv.mkDerivation rec {
-  name = "libe-${version}";
-  version = "0.8.1";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/e/archive/releases/0.8.1.zip";
-    sha256 = "1l13axsi52j2qaxbdnszdvfxksi7rwm2j1rrf0nlh990m6a3yg3s";
-  };
-  buildInputs = [ unzip autoconf automake libtool libpo6 pkgconfig ];
-  preConfigure = "autoreconf -i";
-
-  meta = with stdenv.lib; {
-    description = "Library containing high-performance datastructures and utilities for C++";
-    homepage = https://github.com/rescrv/e;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/hyperdex/libmacaroons.nix b/pkgs/servers/nosql/hyperdex/libmacaroons.nix
deleted file mode 100644
index 5d91a82a8ec6..000000000000
--- a/pkgs/servers/nosql/hyperdex/libmacaroons.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ stdenv, fetchurl, unzip, autoconf, automake, libtool, 
-  pkgconfig, libsodium, python }:
-stdenv.mkDerivation rec {
-  name = "libmacaroons-${version}";
-  version = "HEAD";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/libmacaroons/archive/6febf3ce6c4c77a46d24b40ed29b03ffbfb175a7.zip";
-    sha256 = "0b4qgim87398chvc3qhxfqv2l1cyl65rhyknln8lk0gq9y00p1ik";
-  };
-  buildInputs = [ unzip autoconf automake libtool python libsodium pkgconfig ];
-  preConfigure = "autoreconf -i";
-  
-  meta = with stdenv.lib; {
-    description = ''Macaroons are flexible authorization credentials that
-        support decentralized delegation, attenuation, and verification.'';
-    homepage = https://github.com/rescrv/libmacaroons;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/hyperdex/libpo6.nix b/pkgs/servers/nosql/hyperdex/libpo6.nix
deleted file mode 100644
index 166a5e21c6b9..000000000000
--- a/pkgs/servers/nosql/hyperdex/libpo6.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-{ stdenv, fetchurl, unzip, autoconf, automake, libtool }:
-
-stdenv.mkDerivation rec {
-  name = "libpo6-${version}";
-  version = "0.5.2";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/po6/archive/releases/${version}.zip";
-    sha256 = "14g3ichshnc4wd0iq3q3ymgaq84gjsbqcyn6lri7c7djgkhqijjx";
-  };
-  buildInputs = [ unzip autoconf automake libtool ];
-  preConfigure = "autoreconf -i";
-
-  meta = with stdenv.lib; {
-    description = "POSIX wrappers for C++";
-    homepage = https://github.com/rescrv/po6;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/hyperdex/replicant.nix b/pkgs/servers/nosql/hyperdex/replicant.nix
deleted file mode 100644
index 69146b586723..000000000000
--- a/pkgs/servers/nosql/hyperdex/replicant.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{ stdenv, fetchurl, unzip, autoconf, automake, libtool, glog,
-  hyperleveldb, libe, pkgconfig, popt, libpo6, busybee }:
-
-stdenv.mkDerivation rec {
-  name = "replicant-${version}";
-  version = "0.5.2";
-
-  src = fetchurl {
-    url = "https://github.com/rescrv/Replicant/archive/releases/0.6.3.zip";
-    sha256 = "1fbagz0nbvinkqr5iw5y187dm4klkswrxnl5ysq8waglg2nj8zzi";
-  };
-  buildInputs = [
-    autoconf
-    automake
-    busybee
-    glog
-    hyperleveldb
-    libe
-    libpo6
-    libtool
-    pkgconfig
-    popt
-    unzip
-  ];
-  preConfigure = "autoreconf -i";
-  
-  meta = with stdenv.lib; {
-    description = "A system for maintaining replicated state machines";
-    homepage = https://github.com/rescrv/Replicant;
-    license = licenses.bsd3;
-  };
-}
diff --git a/pkgs/servers/nosql/influxdb/default.nix b/pkgs/servers/nosql/influxdb/default.nix
index 92b1b73d0a0f..972bd53d95ee 100644
--- a/pkgs/servers/nosql/influxdb/default.nix
+++ b/pkgs/servers/nosql/influxdb/default.nix
@@ -1,37 +1,32 @@
-{ stdenv, fetchurl, makeWrapper, zlib, bzip2 }:
+{ lib, buildGoPackage, fetchFromGitHub, }:
 
-assert stdenv.isLinux;
-
-stdenv.mkDerivation rec {
+buildGoPackage rec {
   name = "influxdb-${version}";
-  version = "0.8.3";
-  arch = if stdenv.system == "x86_64-linux" then "amd64" else "386";
+  version = "1.4.1";
 
-  src = fetchurl {
-    url = "http://s3.amazonaws.com/influxdb/${name}.${arch}.tar.gz";
-    sha256 = if arch == "amd64" then
-        "e625902d403434c799f9d9ffc2592a3880f82d435423fde7174e5e4fe0f41148" else
-        "5abe9f432553e66c8aff86c4311eba16b874678d04b52bfe9e2019c01059ec78";
+  src = fetchFromGitHub {
+    owner = "influxdata";
+    repo = "influxdb";
+    rev = "v${version}";
+    sha256 = "048ap70hdfkxhy0y8q1jsb0lql1i99jnf3cqaqar6qs2ynzsw9hd";
   };
 
-  buildInputs = [ makeWrapper ];
+  buildFlagsArray = [ ''-ldflags=
+    -X main.version=${version}
+  '' ];
 
-  installPhase = ''
-    install -D influxdb $out/bin/influxdb
-    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/bin/influxdb
-    wrapProgram "$out/bin/influxdb" \
-        --prefix LD_LIBRARY_PATH : "${stdenv.cc.cc}/lib:${stdenv.cc.cc}/lib64:${zlib}/lib:${bzip2}/lib"
+  goPackagePath = "github.com/influxdata/influxdb";
 
-    mkdir -p $out/share/influxdb
-    cp -R admin scripts config.toml $out/share/influxdb
-  '';
+  excludedPackages = "test";
 
-  meta = with stdenv.lib; {
-    description = "Scalable datastore for metrics, events, and real-time analytics";
-    homepage = http://influxdb.com/;
-    license = licenses.mit;
+  # Generated with the nix2go
+  goDeps = ./. + builtins.toPath "/deps-${version}.nix";
 
-    maintainers = [ maintainers.offline ];
-    platforms = ["i686-linux" "x86_64-linux"];
+  meta = with lib; {
+    description = "An open-source distributed time series database";
+    license = licenses.mit;
+    homepage = https://influxdb.com/;
+    maintainers = with maintainers; [ offline zimbatm ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/servers/nosql/influxdb/deps-1.4.1.nix b/pkgs/servers/nosql/influxdb/deps-1.4.1.nix
new file mode 100644
index 000000000000..edda6ff7c7dc
--- /dev/null
+++ b/pkgs/servers/nosql/influxdb/deps-1.4.1.nix
@@ -0,0 +1,227 @@
+[
+    {
+        goPackagePath = "collectd.org";
+        fetch = {
+            type = "git";
+            url = "https://github.com/collectd/go-collectd";
+            rev = "e84e8af5356e7f47485bbc95c96da6dd7984a67e";
+            sha256 = "0cfxg8iz7bdy3d74cqjns7x7lyrma5lkrqqpqk79a2gk0g2bhmnd";
+        };
+    }
+    {
+        goPackagePath = "github.com/bmizerany/pat";
+        fetch = {
+            type = "git";
+            url = "https://github.com/bmizerany/pat";
+            rev = "c068ca2f0aacee5ac3681d68e4d0a003b7d1fd2c";
+            sha256 = "02ayddkp2b22rixw5jldw3kb6762zzkg5zhxwcv9v9yp0x39qw6r";
+        };
+    }
+    {
+        goPackagePath = "github.com/boltdb/bolt";
+        fetch = {
+            type = "git";
+            url = "https://github.com/boltdb/bolt";
+            rev = "4b1ebc1869ad66568b313d0dc410e2be72670dda";
+            sha256 = "1narpch9fc2f4yj8asb981gyq7b3z6p41xb635xh2k75yv5g024w";
+        };
+    }
+    {
+        goPackagePath = "github.com/BurntSushi/toml";
+        fetch = {
+            type = "git";
+            url = "https://github.com/BurntSushi/toml";
+            rev = "a368813c5e648fee92e5f6c30e3944ff9d5e8895";
+            sha256 = "1sjxs2lwc8jpln80s4rlzp7nprbcljhy5mz4rf9995gq93wqnym5";
+        };
+    }
+    {
+        goPackagePath = "github.com/cespare/xxhash";
+        fetch = {
+            type = "git";
+            url = "https://github.com/cespare/xxhash";
+            rev = "1b6d2e40c16ba0dfce5c8eac2480ad6e7394819b";
+            sha256 = "1h7dym9fmk7rwrrc26lcwi7wmf4y4rxgg7byivg55yia9wlhy00m";
+        };
+    }
+    {
+        goPackagePath = "github.com/dgrijalva/jwt-go";
+        fetch = {
+            type = "git";
+            url = "https://github.com/dgrijalva/jwt-go";
+            rev = "24c63f56522a87ec5339cc3567883f1039378fdb";
+            sha256 = "1xjb3cj9qa66dk6sfrlggfm4a66qirqrp4qds90xzjj5sx51j4zk";
+        };
+    }
+  {
+        goPackagePath = "github.com/dgryski/go-bits";
+        fetch = {
+            type = "git";
+            url = "https://github.com/dgryski/go-bits";
+            rev = "2ad8d707cc05b1815ce6ff2543bb5e8d8f9298ef";
+            sha256 = "08mxwa4c77dgpvz2ygwd0pc929qxwff95y680mjjgbvj8yifiag2";
+        };
+    }
+    {
+        goPackagePath = "github.com/dgryski/go-bitstream";
+        fetch = {
+            type = "git";
+            url = "https://github.com/dgryski/go-bitstream";
+            rev = "7d46cd22db7004f0cceb6f7975824b560cf0e486";
+            sha256 = "1k9l16y7l2mkfvnp2ydv9cqly8179wqd20am4zy0q77qcsawkksx";
+        };
+    }
+    {
+        goPackagePath = "github.com/gogo/protobuf";
+        fetch = {
+            type = "git";
+            url = "https://github.com/gogo/protobuf";
+            rev = "1c2b16bc280d6635de6c52fc1471ab962dc36ec9";
+            sha256 = "0h9vkfy3ydz0d6x72853yg49r9k54cgjnlv6a7v12gzqw47p941i";
+        };
+    }
+    {
+        goPackagePath = "github.com/golang/snappy";
+        fetch = {
+            type = "git";
+            url = "https://github.com/golang/snappy";
+            rev = "d9eb7a3d35ec988b8585d4a0068e462c27d28380";
+            sha256 = "0wynarlr1y8sm9y9l29pm9dgflxriiialpwn01066snzjxnpmbyn";
+        };
+    }
+    {
+        goPackagePath = "github.com/influxdata/influxql";
+        fetch = {
+            type = "git";
+            url = "https://github.com/influxdata/influxql";
+            rev = "3921ab7858b6af8443fe0bef06b52608be72852c";
+            sha256 = "182ja5a9njlklavh5hzf7p06913pznp7j3chkrp0qwxj3jxysi2d";
+        };
+    }
+    {
+        goPackagePath = "github.com/influxdata/usage-client";
+        fetch = {
+            type = "git";
+            url = "https://github.com/influxdata/usage-client";
+            rev = "6d3895376368aa52a3a81d2a16e90f0f52371967";
+            sha256 = "0a5adnid42f9vpckgcpkj7v60fh147j7zlg1rhxcpq5vkw698ifl";
+        };
+    }
+    {
+        goPackagePath = "github.com/influxdata/yamux";
+        fetch = {
+            type = "git";
+            url = "https://github.com/influxdata/yamux";
+            rev = "1f58ded512de5feabbe30b60c7d33a7a896c5f16";
+            sha256 = "08y1lgcyyaa8zrg24ck64b5dfassgb2pp1fb9x5lw9q16fb170bx";
+        };
+    }
+    {
+        goPackagePath = "github.com/influxdata/yarpc";
+        fetch = {
+            type = "git";
+            url = "https://github.com/influxdata/yarpc";
+            rev = "036268cdec22b7074cd6d50cc6d7315c667063c7";
+            sha256 = "12xxwr451ya5h7kv7lg6lnwk04xazyxzv2g7bcgx9zifafxlhpxf";
+        };
+    }
+    {
+        goPackagePath = "github.com/jwilder/encoding";
+        fetch = {
+            type = "git";
+            url = "https://github.com/jwilder/encoding";
+            rev = "27894731927e49b0a9023f00312be26733744815";
+            sha256 = "0g4sdc5wj50js2hhrdcb7iik3wpd87gc0ivy4gwn49m8nxlpl7w3";
+        };
+    }
+    {
+        goPackagePath = "github.com/peterh/liner";
+        fetch = {
+            type = "git";
+            url = "https://github.com/peterh/liner";
+            rev = "88609521dc4b6c858fd4c98b628147da928ce4ac";
+            sha256 = "0jacb2fqgiccb98v1875j5xvj01l1z2laga1kgr8lhd0nl22r96k";
+        };
+    }
+    {
+        goPackagePath = "github.com/philhofer/fwd";
+        fetch = {
+            type = "git";
+            url = "https://github.com/philhofer/fwd";
+            rev = "1612a298117663d7bc9a760ae20d383413859798";
+            sha256 = "155l0nvvblpx0fy683q6bzins7csh8fw7yf64hbia8hc7wh0gjdl";
+        };
+    }
+    {
+        goPackagePath = "github.com/retailnext/hllpp";
+        fetch = {
+            type = "git";
+            url = "https://github.com/retailnext/hllpp";
+            rev = "38a7bb71b483e855d35010808143beaf05b67f9d";
+            sha256 = "0zpq5yjqprzdw9ll6g9sqp8nzwkhjh4ngzhx5mxahmpajgnzz7a8";
+        };
+    }
+    {
+        goPackagePath = "github.com/tinylib/msgp";
+        fetch = {
+            type = "git";
+            url = "https://github.com/tinylib/msgp";
+            rev = "ad0ff2e232ad2e37faf67087fb24bf8d04a8ce20";
+            sha256 = "1j3sqsmq8v40dp1qcv2dsy3aq3yl088hpd4fnrrnnl53g3a18p4d";
+        };
+    }
+    {
+        goPackagePath = "github.com/uber-go/atomic";
+        fetch = {
+            type = "git";
+            url = "https://github.com/uber-go/atomic";
+            rev = "74ca5ec650841aee9f289dce76e928313a37cbc6";
+            sha256 = "14a4k5z4p2iig6sf7as5ps1frdyzcr67b9bff0by4z1vg4nrxi7h";
+        };
+    }
+    {
+        goPackagePath = "github.com/uber-go/zap";
+        fetch = {
+            type = "git";
+            url = "https://github.com/uber-go/zap";
+            rev = "fbae0281ffd546fa6d1959fec6075ac5da7fb577";
+            sha256 = "0ys6cb2h3r0vbly36v8zqkqsfc5y7fjsw2qmvx5fvjh35ih4w738";
+        };
+    }
+    {
+        goPackagePath = "github.com/xlab/treeprint";
+        fetch = {
+            type = "git";
+            url = "https://github.com/xlab/treeprint";
+            rev = "06dfc6fa17cdde904617990a0c2d89e3e332dbb3";
+            sha256 = "04v2glr8wsgs8gr5qbcxyqn9s6569lmgqb7rcs6bkmdnr79xpwl5";
+        };
+    }
+    {
+        goPackagePath = "golang.org/x/crypto";
+        fetch = {
+            type = "git";
+            url = "https://go.googlesource.com/crypto";
+            rev = "9477e0b78b9ac3d0b03822fd95422e2fe07627cd";
+            sha256 = "1qcqai6nf1q50z9ga7r4ljnrh1qz49kwlcqpri4bknx732lqq0v5";
+        };
+    }
+    {
+        goPackagePath = "golang.org/x/sys";
+        fetch = {
+            type = "git";
+            url = "https://go.googlesource.com/sys";
+            rev = "1e2299c37cc91a509f1b12369872d27be0ce98a6";
+            sha256 = "1nh8v330pcwgk3h6nvfi12rlydl16v9ajv4s1giyx8wnfq8h6fm1";
+        };
+    }
+    {
+        goPackagePath = "golang.org/x/text";
+        fetch = {
+            type = "git";
+            url = "https://go.googlesource.com/text";
+            rev = "a71fd10341b064c10f4a81ceac72bcf70f26ea34";
+            sha256 = "1igxqrgnnb6983fl0yck0xal2hwnkcgbslr7cxyrg7a65vawd0q1";
+        };
+    }
+]
diff --git a/pkgs/servers/nosql/mongodb/default.nix b/pkgs/servers/nosql/mongodb/default.nix
index 09465edbd292..b9e850e8dfd4 100644
--- a/pkgs/servers/nosql/mongodb/default.nix
+++ b/pkgs/servers/nosql/mongodb/default.nix
@@ -1,52 +1,68 @@
-{ stdenv, fetchurl, scons, boost, gperftools, pcre, snappy
-, zlib, libyamlcpp, sasl, openssl, libpcap, wiredtiger
+{ stdenv, fetchurl, fetchpatch, scons, boost, gperftools, pcre-cpp, snappy
+, zlib, libyamlcpp, sasl, openssl, libpcap, wiredtiger, Security
 }:
 
+# Note:
+# The command line tools are written in Go as part of a different package (mongodb-tools)
+
 with stdenv.lib;
 
-let version = "3.0.6";
+let version = "3.4.10";
     system-libraries = [
       "pcre"
-      "wiredtiger"
+      #"asio" -- XXX use package?
+      #"wiredtiger"
       "boost"
       "snappy"
       "zlib"
-      # "v8"
-      # "stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs)
+      #"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
+      #"stemmer"  -- not nice to package yet (no versioning, no makefile, no shared libs).
       "yaml"
     ] ++ optionals stdenv.isLinux [ "tcmalloc" ];
+
     buildInputs = [
-      sasl boost gperftools pcre snappy
-      zlib libyamlcpp sasl openssl libpcap
-    ] ++ optional stdenv.is64bit wiredtiger;
+      sasl boost gperftools pcre-cpp snappy
+      zlib libyamlcpp sasl openssl.dev openssl.out libpcap
+    ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security ];
 
     other-args = concatStringsSep " " ([
-      # these are opt-in, lol
-      "--cc-use-shell-environment"
-      "--cxx-use-shell-environment"
-
-      "--c++11=on"
       "--ssl"
       #"--rocksdb" # Don't have this packaged yet
       "--wiredtiger=${if stdenv.is64bit then "on" else "off"}"
-      "--js-engine=v8-3.25"
+      "--js-engine=mozjs"
       "--use-sasl-client"
       "--disable-warnings-as-errors"
-      "--variant-dir=nixos" # Needed so we don't produce argument lists that are too long for gcc / ld
-      "--extrapath=${concatStringsSep "," buildInputs}"
+      "VARIANT_DIR=nixos" # Needed so we don't produce argument lists that are too long for gcc / ld
+      "CC=$CC"
+      "CXX=$CXX"
+      "CCFLAGS=\"${concatStringsSep " " (map (input: "-I${input}/include") buildInputs)}\""
+      "LINKFLAGS=\"${concatStringsSep " " (map (input: "-L${input}/lib") buildInputs)}\""
     ] ++ map (lib: "--use-system-${lib}") system-libraries);
 
 in stdenv.mkDerivation rec {
   name = "mongodb-${version}";
 
   src = fetchurl {
-    url = "http://downloads.mongodb.org/src/mongodb-src-r${version}.tar.gz";
-    sha256 = "0bc2khi36ck0y7dhppvjp8wy479hzyw34qs0965qj4gd2va6p7v0";
+    url = "https://fastdl.mongodb.org/src/mongodb-src-r${version}.tar.gz";
+    sha256 = "1wz2mhl9z0b1bdkg6m8v8mvw9k60mdv5ybq554xn3yjj9z500f24";
   };
 
   nativeBuildInputs = [ scons ];
   inherit buildInputs;
 
+  patches =
+    [
+      # MongoDB keeps track of its build parameters, which tricks nix into
+      # keeping dependencies to build inputs in the final output.
+      # We remove the build flags from buildInfo data.
+      ./forget-build-dependencies.patch
+      (fetchpatch {
+        url = https://projects.archlinux.org/svntogit/community.git/plain/trunk/boost160.patch?h=packages/mongodb;
+        name = "boost160.patch";
+        sha256 = "0bvsf3499zj55pzamwjmsssr6x63w434944w76273fr5rxwzcmh8";
+      })
+    ];
+
   postPatch = ''
     # fix environment variable reading
     substituteInPlace SConstruct \
@@ -58,8 +74,15 @@ in stdenv.mkDerivation rec {
     substituteInPlace src/third_party/s2/s2cap.cc --replace drem remainder
     substituteInPlace src/third_party/s2/s2latlng.cc --replace drem remainder
     substituteInPlace src/third_party/s2/s2latlngrect.cc --replace drem remainder
+  '' + stdenv.lib.optionalString stdenv.isi686 ''
+
+    # don't fail by default on i686
+    substituteInPlace src/mongo/db/storage/storage_options.h \
+      --replace 'engine("wiredTiger")' 'engine("mmapv1")'
   '';
 
+  NIX_CFLAGS_COMPILE = stdenv.lib.optional stdenv.cc.isClang "-Wno-unused-command-line-argument";
+
   buildPhase = ''
     scons -j $NIX_BUILD_CORES core --release ${other-args}
   '';
@@ -71,12 +94,14 @@ in stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  hardeningEnable = [ "pie" ];
+
   meta = {
-    description = "a scalable, high-performance, open source NoSQL database";
+    description = "A scalable, high-performance, open source NoSQL database";
     homepage = http://www.mongodb.org;
     license = licenses.agpl3;
 
-    maintainers = with maintainers; [ bluescreen303 offline wkennington ];
+    maintainers = with maintainers; [ bluescreen303 offline wkennington cstrahan ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/servers/nosql/mongodb/forget-build-dependencies.patch b/pkgs/servers/nosql/mongodb/forget-build-dependencies.patch
new file mode 100644
index 000000000000..ca2c043deb2d
--- /dev/null
+++ b/pkgs/servers/nosql/mongodb/forget-build-dependencies.patch
@@ -0,0 +1,17 @@
+--- a/site_scons/mongo_scons_utils.py
++++ b/site_scons/mongo_scons_utils.py
+@@ -84,14 +84,11 @@
+ def default_buildinfo_environment_data():
+     return (
+         ('distmod', '$MONGO_DISTMOD', True, True,),
+         ('distarch', '$MONGO_DISTARCH', True, True,),
+         ('cc', '$CC_VERSION', True, False,),
+-        ('ccflags', '$CCFLAGS', True, False,),
+         ('cxx', '$CXX_VERSION', True, False,),
+-        ('cxxflags', '$CXXFLAGS', True, False,),
+-        ('linkflags', '$LINKFLAGS', True, False,),
+         ('target_arch', '$TARGET_ARCH', True, True,),
+         ('target_os', '$TARGET_OS', True, False,),
+     )
+ 
+ # If you want buildInfo and --version to be relatively empty, set
diff --git a/pkgs/servers/nosql/neo4j/default.nix b/pkgs/servers/nosql/neo4j/default.nix
index 91c4472e0492..022a1a9ba10f 100644
--- a/pkgs/servers/nosql/neo4j/default.nix
+++ b/pkgs/servers/nosql/neo4j/default.nix
@@ -1,36 +1,35 @@
-{ stdenv, fetchurl, makeWrapper, jre, which, gnused }:
+{ stdenv, fetchurl, makeWrapper, jre8, which, gawk }:
 
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "neo4j-${version}";
-  version = "2.1.3";
+  version = "3.4.0";
 
   src = fetchurl {
-    url = "http://dist.neo4j.org/neo4j-community-${version}-unix.tar.gz";
-    sha256 = "0gcyy6ayn8qvxj6za5463lgy320mn4rq7q5qysc26fxjd73drrrk";
+    url = "https://neo4j.com/artifact.php?name=neo4j-community-${version}-unix.tar.gz";
+    sha256 = "1pccw3av72qqpyfsdyz72ab1lvc7fqraw14vi3hq67n96rsj017a";
   };
 
-  buildInputs = [ makeWrapper jre which gnused ];
-
-  patchPhase = ''
-    substituteInPlace "bin/neo4j" --replace "NEO4J_INSTANCE=\$NEO4J_HOME" ""
-  '';
+  buildInputs = [ makeWrapper jre8 which gawk ];
 
   installPhase = ''
     mkdir -p "$out/share/neo4j"
     cp -R * "$out/share/neo4j"
 
     mkdir -p "$out/bin"
-    makeWrapper "$out/share/neo4j/bin/neo4j" "$out/bin/neo4j" \
-        --prefix PATH : "${jre}/bin:${which}/bin:${gnused}/bin"
-    makeWrapper "$out/share/neo4j/bin/neo4j-shell" "$out/bin/neo4j-shell" \
-        --prefix PATH : "${jre}/bin:${which}/bin:${gnused}/bin"
+    for NEO4J_SCRIPT in neo4j neo4j-admin neo4j-import neo4j-shell cypher-shell
+    do
+        makeWrapper "$out/share/neo4j/bin/$NEO4J_SCRIPT" \
+            "$out/bin/$NEO4J_SCRIPT" \
+            --prefix PATH : "${stdenv.lib.makeBinPath [ jre8 which gawk ]}" \
+            --set JAVA_HOME "$jre8"
+    done
   '';
 
   meta = with stdenv.lib; {
-    description = "a highly scalable, robust (fully ACID) native graph database";
-    homepage = "http://www.neo4j.org/";
+    description = "A highly scalable, robust (fully ACID) native graph database";
+    homepage = http://www.neo4j.org/;
     license = licenses.gpl3;
 
     maintainers = [ maintainers.offline ];
diff --git a/pkgs/servers/nosql/redis/default.nix b/pkgs/servers/nosql/redis/default.nix
index 6da7ec11e7c6..07489b627288 100644
--- a/pkgs/servers/nosql/redis/default.nix
+++ b/pkgs/servers/nosql/redis/default.nix
@@ -1,14 +1,15 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, lua }:
 
 stdenv.mkDerivation rec {
-  version = "3.0.2";
+  version = "4.0.9";
   name = "redis-${version}";
 
   src = fetchurl {
     url = "http://download.redis.io/releases/${name}.tar.gz";
-    sha256 = "93e422c0d584623601f89b956045be158889ebe594478a2c24e1bf218495633f";
+    sha256 = "0465bv6yxnwmas3wzg07vmrprv2pxhnr56hn5pxrybwf66y76kyz";
   };
 
+  buildInputs = [ lua ];
   makeFlags = "PREFIX=$(out)";
 
   enableParallelBuilding = true;
diff --git a/pkgs/servers/nosql/rethinkdb/default.nix b/pkgs/servers/nosql/rethinkdb/default.nix
index 55f77ce0b5dd..e935b5d09879 100644
--- a/pkgs/servers/nosql/rethinkdb/default.nix
+++ b/pkgs/servers/nosql/rethinkdb/default.nix
@@ -1,32 +1,54 @@
 { stdenv, fetchurl, which, m4, python
-, protobuf, boost, zlib, curl, openssl, icu, jemalloc
+, protobuf, boost, zlib, curl, openssl, icu, jemalloc, libtool
+, python2Packages, makeWrapper
 }:
 
 stdenv.mkDerivation rec {
   name = "rethinkdb-${version}";
-  version = "2.1.3";
+  version = "2.3.6";
 
   src = fetchurl {
-    url = "http://download.rethinkdb.com/dist/${name}.tgz";
-    sha256 = "03w9fq3wcvwy04b3x6zb3hvwar7b9jfbpq77rmxdlgh5w64vvgwd";
+    url = "https://download.rethinkdb.com/dist/${name}.tgz";
+    sha256 = "0a6wlgqa2flf87jrp4fq4y9aihwyhgwclmss56z03b8hd5k5j8f4";
   };
 
+  patches = [
+    (fetchurl {
+        url = "https://github.com/rethinkdb/rethinkdb/commit/871bd3705a1f29c4ab07a096d562a4b06231a97c.patch";
+        sha256 = "05nagixlwnq3x7441fhll5vs70pxppbsciw8qjqp660bdb5m4jm1";
+    })
+  ];
+
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' external/v8_3.30.33.16/build/gyp/pylib/gyp/xcode_emulation.py
+
+    # very meta
+    substituteInPlace mk/support/pkg/re2.sh --replace "-i '''" "-i"
+  '';
+
   preConfigure = ''
     export ALLOW_WARNINGS=1
     patchShebangs .
   '';
 
-  configureFlags = [
+  configureFlags = stdenv.lib.optionals (!stdenv.isDarwin) [
     "--with-jemalloc"
     "--lib-path=${jemalloc}/lib"
   ];
 
-  buildInputs = [ protobuf boost zlib curl openssl icu jemalloc ];
+  buildInputs = [ protobuf boost zlib curl openssl icu makeWrapper ]
+    ++ stdenv.lib.optional (!stdenv.isDarwin) jemalloc
+    ++ stdenv.lib.optional stdenv.isDarwin libtool;
 
-  nativeBuildInputs = [ which m4 python ];
+  nativeBuildInputs = [ which m4 python2Packages.python ];
 
   enableParallelBuilding = true;
 
+  postInstall = ''
+    wrapProgram $out/bin/rethinkdb \
+      --prefix PATH ":" "${python2Packages.rethinkdb}/bin"
+  '';
+
   meta = {
     description = "An open-source distributed database built with love";
     longDescription = ''
diff --git a/pkgs/servers/nosql/riak-cs/2.1.1.nix b/pkgs/servers/nosql/riak-cs/2.1.1.nix
new file mode 100644
index 000000000000..4d0bb6c687db
--- /dev/null
+++ b/pkgs/servers/nosql/riak-cs/2.1.1.nix
@@ -0,0 +1,69 @@
+{ stdenv, lib, fetchurl, unzip, erlang, git, wget, which, pam, coreutils, riak
+, Carbon ? null, Cocoa ? null }:
+
+stdenv.mkDerivation rec {
+  name = "riak_cs-2.1.1";
+
+  buildInputs = [
+    which unzip erlang git wget
+  ] ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ]
+    ++ lib.optional stdenv.isLinux [ pam ];
+
+  src = fetchurl {
+    url = "http://s3.amazonaws.com/downloads.basho.com/riak-cs/2.1/2.1.1/riak-cs-2.1.1.tar.gz";
+    sha256 = "115cac127aac6d759c1b429a52e0d18e491c0719a6530b1b88aa52c4efdbedd5";
+  };
+
+
+  postPatch = ''
+    sed -i deps/node_package/priv/base/env.sh \
+      -e 's@{{platform_data_dir}}@''${RIAK_DATA_DIR:-/var/db/riak-cs}@' \
+      -e 's@^RUNNER_SCRIPT_DIR=.*@RUNNER_SCRIPT_DIR='$out'/bin@' \
+      -e 's@^RUNNER_BASE_DIR=.*@RUNNER_BASE_DIR='$out'@' \
+      -e 's@^RUNNER_ETC_DIR=.*@RUNNER_ETC_DIR=''${RIAK_ETC_DIR:-/etc/riak-cs}@' \
+      -e 's@^RUNNER_LOG_DIR=.*@RUNNER_LOG_DIR=''${RIAK_LOG_DIR:-/var/log}@'
+
+    sed -i ./Makefile \
+      -e 's@rel: deps compile@rel: deps compile-src@'
+  '';
+
+  preBuild = ''
+    patchShebangs .
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+
+    make locked-deps
+    make rel
+
+    runHook postBuild
+  '';
+
+  doCheck = false;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir $out
+    mv rel/riak-cs/etc rel/riak-cs/riak-etc
+    mkdir -p rel/riak-cs/etc
+    mv rel/riak-cs/riak-etc rel/riak-cs/etc/riak-cs
+    mv rel/riak-cs/* $out
+
+    for prog in $out/bin/*; do
+      substituteInPlace $prog \
+        --replace '. "`cd \`dirname $0\` && /bin/pwd`/../lib/env.sh"' \
+                  ". $out/lib/env.sh"
+    done
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Dynamo inspired NoSQL DB by Basho with S3 compatibility";
+    platforms   = [ "x86_64-linux" "x86_64-darwin" ];
+    license     = licenses.asl20;
+    maintainers = with maintainers; [ mdaiter ];
+  };
+}
diff --git a/pkgs/servers/nosql/riak-cs/stanchion.nix b/pkgs/servers/nosql/riak-cs/stanchion.nix
new file mode 100644
index 000000000000..8ea71d611ebb
--- /dev/null
+++ b/pkgs/servers/nosql/riak-cs/stanchion.nix
@@ -0,0 +1,65 @@
+{ stdenv, lib, fetchurl, unzip, erlang, git, wget, which, pam, coreutils, riak 
+, Carbon ? null, Cocoa ? null }:
+
+stdenv.mkDerivation rec {
+  name = "stanchion-2.1.1";
+
+  buildInputs = [
+    which unzip erlang git wget
+  ] ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ]
+    ++ lib.optional stdenv.isLinux [ pam ];
+
+  src = fetchurl {
+    url = "http://s3.amazonaws.com/downloads.basho.com/stanchion/2.1/2.1.1/stanchion-2.1.1.tar.gz";
+    sha256 = "1443arwgg7qvlx3msyg99qvvhck7qxphdjslcp494i60fhr2g8ja";
+  };
+
+
+  postPatch = ''
+    sed -i deps/node_package/priv/base/env.sh \
+      -e 's@{{platform_data_dir}}@''${RIAK_DATA_DIR:-/var/db/stanchion}@' \
+      -e 's@^RUNNER_SCRIPT_DIR=.*@RUNNER_SCRIPT_DIR='$out'/bin@' \
+      -e 's@^RUNNER_BASE_DIR=.*@RUNNER_BASE_DIR='$out'@' \
+      -e 's@^RUNNER_ETC_DIR=.*@RUNNER_ETC_DIR=''${RIAK_ETC_DIR:-/etc/stanchion}@' \
+      -e 's@^RUNNER_LOG_DIR=.*@RUNNER_LOG_DIR=''${RIAK_LOG_DIR:-/var/log}@'
+  '';
+
+  preBuild = ''
+    patchShebangs .
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+
+    make rel
+
+    runHook postBuild
+  '';
+
+  doCheck = false;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir $out
+    mv rel/stanchion/etc rel/stanchion/riak-etc
+    mkdir -p rel/stanchion/etc
+    mv rel/stanchion/riak-etc rel/stanchion/etc/stanchion
+    mv rel/stanchion/* $out
+
+    for prog in $out/bin/*; do
+      substituteInPlace $prog \
+        --replace '. "`cd \`dirname $0\` && /bin/pwd`/../lib/env.sh"' \
+                  ". $out/lib/env.sh"
+    done
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    maintainers = with maintainers; [ mdaiter ];
+    description = "Manager for Riak CS";
+    platforms   = [ "x86_64-linux" "x86_64-darwin" ];
+    license = licenses.asl20;
+  };
+}
diff --git a/pkgs/servers/nosql/riak/1.3.1.nix b/pkgs/servers/nosql/riak/1.3.1.nix
deleted file mode 100644
index e773f6ddcc36..000000000000
--- a/pkgs/servers/nosql/riak/1.3.1.nix
+++ /dev/null
@@ -1,64 +0,0 @@
-{ stdenv, fetchurl, unzip, erlangR15}:
-
-let
-  srcs = {
-     riak = fetchurl {
-      url = "http://s3.amazonaws.com/downloads.basho.com/riak/1.3/1.3.1/riak-1.3.1.tar.gz";
-      sha256 = "a69093fc5df1b79f58645048b9571c755e00c3ca14dfd27f9f1cae2c6e628f01";
-    };
-     leveldb = fetchurl {
-      url = "https://github.com/basho/leveldb/archive/1.3.1.zip";
-      sha256 = "dc48ba2b44fca11888ea90695d385c494e1a3abd84a6b266b07fdc160ab2ef64";
-    };
-  };
-in
-stdenv.mkDerivation rec {
-  name = "riak-1.3.1";
-
-  buildInputs = [unzip erlangR15];
-
-  src = srcs.riak;
-
-  patches = [ ./riak-1.3.1.patch ./riak-admin-1.3.1.patch ];
-
-  postUnpack = ''
-    ln -sv ${srcs.leveldb} $sourceRoot/deps/eleveldb/c_src/leveldb.zip
-    pushd $sourceRoot/deps/eleveldb/c_src/
-    unzip leveldb.zip
-    mv leveldb-* leveldb
-    cd ../../
-    mkdir riaknostic/deps
-    cp -R lager riaknostic/deps
-    cp -R getopt riaknostic/deps
-    cp -R meck riaknostic/deps
-    popd
-    patchShebangs .
-  '';
-
-  buildPhase = ''
-    make rel
-  '';
-
-  doCheck = false;
-
-  installPhase = ''
-    mkdir $out
-    mv rel/riak/etc rel/riak/riak-etc
-    mkdir -p rel/riak/etc
-    mv rel/riak/riak-etc rel/riak/etc/riak
-    mv rel/riak/* $out
-  '';
-
-  meta = {
-    maintainers = [ stdenv.lib.maintainers.orbitz ];
-    description = "Dynamo inspired NoSQL DB by Basho";
-    longDescription = ''
-      This patches the riak and riak-admin scripts to work better in Nix.
-      Rather than the scripts using their own location to determine where
-      the data, log, and etc directories should live, the scripts expect
-      RIAK_DATA_DIR, RIAK_LOG_DIR, and RIAK_ETC_DIR to be defined
-      and use those.
-    '';
-    platforms   = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/servers/nosql/riak/2.1.1.nix b/pkgs/servers/nosql/riak/2.2.0.nix
index c62cea180be7..9998d34a2dae 100644
--- a/pkgs/servers/nosql/riak/2.1.1.nix
+++ b/pkgs/servers/nosql/riak/2.2.0.nix
@@ -1,22 +1,22 @@
-{ stdenv, lib, fetchurl, unzip, erlangR16, which, pam, coreutils }:
+{ stdenv, lib, fetchurl, unzip, erlang, which, pam, coreutils }:
 
 let
-  solrName = "solr-4.7.0-yz-1.tgz";
-  yokozunaJarName = "yokozuna-2.jar";
+  solrName = "solr-4.10.4-yz-2.tgz";
+  yokozunaJarName = "yokozuna-3.jar";
   yzMonitorJarName = "yz_monitor-1.jar";
 
   srcs = {
     riak = fetchurl {
-      url = "http://s3.amazonaws.com/downloads.basho.com/riak/2.1/2.1.1/riak-2.1.1.tar.gz";
-      sha256 = "1bm5j3zknz82mkyh5zgaap73awflh4mkibdvdz164235mdxlwhdm";
+      url = "http://s3.amazonaws.com/downloads.basho.com/riak/2.2/2.2.0/riak-2.2.0.tar.gz";
+      sha256 = "0kl28bpyzajcllybili46jfr1schl45w5ysii187jr0ssgls2c9p";
     };
     solr = fetchurl {
       url = "http://s3.amazonaws.com/files.basho.com/solr/${solrName}";
-      sha256 = "0brml3lb3xk26rmi05rrzpxrw92alfi9gi7p7537ny9lqg3808qp";
+      sha256 = "0fy5slnldn628gmr2kilyx606ph0iykf7pz6j0xjcc3wqvrixa2a";
     };
     yokozunaJar = fetchurl {
       url = "http://s3.amazonaws.com/files.basho.com/yokozuna/${yokozunaJarName}";
-      sha256 = "0xzfy181qxv27pc4f5xd0szn8vls5743273awr5rwv3608gkspj2";
+      sha256 = "17n6m100fz8affdcxsn4niw2lrpnswgfnd6aszgzipffwbg7v8v5";
     };
     yzMonitorJar = fetchurl {
       url = "http://s3.amazonaws.com/files.basho.com/yokozuna/${yzMonitorJarName}";
@@ -26,14 +26,16 @@ let
 in
 
 stdenv.mkDerivation rec {
-  name = "riak-2.1.1";
+  name = "riak-2.2.0";
 
   buildInputs = [
-    which unzip erlangR16 pam
+    which unzip erlang pam
   ];
 
   src = srcs.riak;
 
+  hardeningDisable = [ "format" ];
+
   postPatch = ''
     sed -i deps/node_package/priv/base/env.sh \
       -e 's@{{platform_data_dir}}@''${RIAK_DATA_DIR:-/var/db/riak}@' \
@@ -87,7 +89,7 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with lib; {
-    maintainers = with maintainers; [ cstrahan ];
+    maintainers = with maintainers; [ cstrahan mdaiter ];
     description = "Dynamo inspired NoSQL DB by Basho";
     platforms   = [ "x86_64-linux" ];
   };
diff --git a/pkgs/servers/nosql/riak/riak-1.3.1.patch b/pkgs/servers/nosql/riak/riak-1.3.1.patch
deleted file mode 100644
index e36bd31ab88c..000000000000
--- a/pkgs/servers/nosql/riak/riak-1.3.1.patch
+++ /dev/null
@@ -1,64 +0,0 @@
---- a/rel/files/riak	2013-05-22 20:45:55.613299952 +0200
-+++ b/rel/files/riak	2013-06-04 03:20:47.679943612 +0200
-@@ -13,33 +13,34 @@
- fi
- unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
- 
-+if [ -z "$RIAK_ETC_DIR" ]; then
-+    echo "Must set RIAK_ETC_DIR"
-+    exit 1
-+fi
-+
-+if [ -z "$RIAK_LOG_DIR" ]; then
-+    echo "Must set RIAK_LOG_DIR"
-+    exit 1
-+fi
-+
-+if [ -z "$RIAK_DATA_DIR" ]; then
-+    echo "Must set RIAK_DATA_DIR"
-+    exit 1
-+fi
-+
- RUNNER_SCRIPT_DIR={{runner_script_dir}}
- RUNNER_SCRIPT=${0##*/}
- 
- RUNNER_BASE_DIR={{runner_base_dir}}
--RUNNER_ETC_DIR={{runner_etc_dir}}
-+RUNNER_ETC_DIR=$RIAK_ETC_DIR
- RUNNER_LIB_DIR={{platform_lib_dir}}
--RUNNER_LOG_DIR={{runner_log_dir}}
-+RUNNER_LOG_DIR=$RIAK_LOG_DIR
- # Note the trailing slash on $PIPE_DIR/
- PIPE_DIR={{pipe_dir}}
--RUNNER_USER={{runner_user}}
--PLATFORM_DATA_DIR={{platform_data_dir}}
-+PLATFORM_DATA_DIR=$RIAK_DATA_DIR
- SSL_DIST_CONFIG=$PLATFORM_DATA_DIR/ssl_distribution.args_file
- RIAK_VERSION="git"
- 
--WHOAMI=$(whoami)
--
--# Make sure this script is running as the appropriate user
--if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
--    type sudo > /dev/null 2>&1
--    if [ $? -ne 0 ]; then
--        echo "sudo doesn't appear to be installed and your EUID isn't $RUNNER_USER" 1>&2
--        exit 1
--    fi
--    echo "Attempting to restart script through sudo -H -u $RUNNER_USER" >&2
--    exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
--fi
--
- # Warn the user if ulimit -n is less than 4096
- ULIMIT_F=`ulimit -n`
- if [ "$ULIMIT_F" -lt 4096 ]; then
-@@ -48,9 +49,6 @@
-     echo "!!!!"
- fi
- 
--# Make sure CWD is set to runner base dir
--cd $RUNNER_BASE_DIR
--
- # Make sure log directory exists
- mkdir -p $RUNNER_LOG_DIR
- 
diff --git a/pkgs/servers/nosql/riak/riak-admin-1.3.1.patch b/pkgs/servers/nosql/riak/riak-admin-1.3.1.patch
deleted file mode 100644
index 9c87a6329943..000000000000
--- a/pkgs/servers/nosql/riak/riak-admin-1.3.1.patch
+++ /dev/null
@@ -1,52 +0,0 @@
---- a/rel/files/riak-admin	2013-05-22 20:45:55.613299952 +0200
-+++ b/rel/files/riak-admin	2013-06-04 03:30:00.101604175 +0200
-@@ -11,31 +11,31 @@
- fi
- unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
- 
-+
-+if [ -z "$RIAK_ETC_DIR" ]; then
-+    echo "Must set RIAK_ETC_DIR"
-+    exit 1
-+fi
-+
-+if [ -z "$RIAK_LOG_DIR" ]; then
-+    echo "Must set RIAK_LOG_DIR"
-+    exit 1
-+fi
-+
-+if [ -z "$RIAK_DATA_DIR" ]; then
-+    echo "Must set RIAK_DATA_DIR"
-+    exit 1
-+fi
-+
- RUNNER_SCRIPT_DIR={{runner_script_dir}}
- RUNNER_SCRIPT=${0##*/}
- 
- RUNNER_BASE_DIR={{runner_base_dir}}
--RUNNER_ETC_DIR={{runner_etc_dir}}
-+RUNNER_ETC_DIR=$RIAK_ETC_DIR
- RUNNER_LIB_DIR={{platform_lib_dir}}
--RUNNER_LOG_DIR={{runner_log_dir}}
-+RUNNER_LOG_DIR=$RIAK_LOG_DIR
- RUNNER_USER={{runner_user}}
- 
--WHOAMI=$(whoami)
--
--# Make sure this script is running as the appropriate user
--if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
--    type sudo > /dev/null 2>&1
--    if [ $? -ne 0 ]; then
--        echo "sudo doesn't appear to be installed and your EUID isn't $RUNNER_USER" 1>&2
--        exit 1
--    fi
--    echo "Attempting to restart script through sudo -H -u $RUNNER_USER" >&2
--    exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
--fi
--
--# Make sure CWD is set to runner base dir
--cd $RUNNER_BASE_DIR
--
- # Extract the target node name from node.args
- NAME_ARG=`egrep "^ *-s?name" $RUNNER_ETC_DIR/vm.args`
- if [ -z "$NAME_ARG" ]; then
diff --git a/pkgs/servers/nsq/default.nix b/pkgs/servers/nsq/default.nix
new file mode 100644
index 000000000000..fa78c876c1ec
--- /dev/null
+++ b/pkgs/servers/nsq/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "nsq-${version}";
+  version = "0.3.5";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/bitly/nsq";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "bitly";
+    repo = "nsq";
+    sha256 = "1r7jgplzn6bgwhd4vn8045n6cmm4iqbzssbjgj7j1c28zbficy2f";
+  };
+
+  goDeps = ./deps.nix;
+}
diff --git a/pkgs/servers/nsq/deps.nix b/pkgs/servers/nsq/deps.nix
new file mode 100644
index 000000000000..751a18ca92d7
--- /dev/null
+++ b/pkgs/servers/nsq/deps.nix
@@ -0,0 +1,83 @@
+[
+  {
+    goPackagePath = "github.com/mreiferson/go-snappystream";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mreiferson/go-snappystream";
+      rev = "028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504";
+      sha256 = "0jdd5whp74nvg35d9hzydsi3shnb1vrnd7shi9qz4wxap7gcrid6";
+    };
+  }
+  {
+    goPackagePath = "github.com/bitly/go-nsq";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bitly/go-nsq";
+      rev = "22a8bd48c443ec23bb559675b6df8284bbbdab29";
+      sha256 = "06hrkwk84w8rshkanvfgmgbiml7n06ybv192dvibhwgk2wz2dl46";
+    };
+  }
+  {
+    goPackagePath = "github.com/bitly/go-simplejson";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bitly/go-simplejson";
+      rev = "18db6e68d8fd9cbf2e8ebe4c81a78b96fd9bf05a";
+      sha256 = "0lj9cxyncchlw6p35j0yym5q5waiz0giw6ri41qdwm8y3dghwwiy";
+    };
+  }
+  {
+    goPackagePath = "github.com/blang/semver";
+    fetch = {
+      type = "git";
+      url = "https://github.com/blang/semver";
+      rev = "9bf7bff48b0388cb75991e58c6df7d13e982f1f2";
+      sha256 = "11sinbf942dpyc9wdpidkhmqn438cfp5n8x3xqnmq9aszkld9hy7";
+    };
+  }
+  {
+    goPackagePath = "github.com/bmizerany/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bmizerany/perks";
+      rev = "6cb9d9d729303ee2628580d9aec5db968da3a607";
+      sha256 = "0cdh84hmn21is6hvv6dy9qjdcg9w3l2k8avlk0881a8cqm09s90j";
+    };
+  }
+  {
+    goPackagePath = "github.com/BurntSushi/toml";
+    fetch = {
+      type = "git";
+      url = "https://github.com/BurntSushi/toml";
+      rev = "056c9bc7be7190eaa7715723883caffa5f8fa3e4";
+      sha256 = "0gkgkw04ndr5y7hrdy0r4v2drs5srwfcw2bs1gyas066hwl84xyw";
+    };
+  }
+  {
+    goPackagePath = "github.com/bitly/go-hostpool";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bitly/go-hostpool";
+      rev = "d0e59c22a56e8dadfed24f74f452cea5a52722d2";
+      sha256 = "14ph12krn5zlg00vh9g6g08lkfjxnpw46nzadrfb718yl1hgyk3g";
+    };
+  }
+  {
+    goPackagePath = "github.com/bitly/timer_metrics";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bitly/timer_metrics";
+      rev = "afad1794bb13e2a094720aeb27c088aa64564895";
+      sha256 = "1b717vkwj63qb5kan4b92kx4rg6253l5mdb3lxpxrspy56a6rl0c";
+    };
+  }
+  {
+    goPackagePath = "github.com/mreiferson/go-options";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mreiferson/go-options";
+      rev = "7c174072188d0cfbe6f01bb457626abb22bdff52";
+      sha256 = "0ksyi2cb4k6r2fxamljg42qbz5hdcb9kv5i7y6cx4ajjy0xznwgm";
+    };
+  }
+]
diff --git a/pkgs/servers/oauth2_proxy/default.nix b/pkgs/servers/oauth2_proxy/default.nix
new file mode 100644
index 000000000000..d9919005e39d
--- /dev/null
+++ b/pkgs/servers/oauth2_proxy/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "oauth2_proxy-${version}";
+  version = "20180325-${stdenv.lib.strings.substring 0 7 rev}";
+  rev = "a94b0a8b25e553f7333f7b84aeb89d9d18ec259b";
+  
+  goPackagePath = "github.com/bitly/oauth2_proxy";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    repo = "oauth2_proxy";
+    owner = "bitly";
+    sha256 = "07m258s9fxjsgixggw0d1zicd7l6l2rkm5mh3zdjdaj20sqcj217";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with lib; {
+    description = "A reverse proxy that provides authentication with Google, Github or other provider";
+    homepage = https://github.com/bitly/oauth2_proxy/;
+    license = licenses.mit;
+    maintainers = [ maintainers.yorickvp ];
+  };
+}
diff --git a/pkgs/servers/oauth2_proxy/deps.nix b/pkgs/servers/oauth2_proxy/deps.nix
new file mode 100644
index 000000000000..435c7d127821
--- /dev/null
+++ b/pkgs/servers/oauth2_proxy/deps.nix
@@ -0,0 +1,129 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "cloud.google.com/go";
+    fetch = {
+      type = "git";
+      url = "https://code.googlesource.com/gocloud";
+      rev = "d27f27d9b3cf75c9901d9981f9af50bbfd9002da";
+      sha256 = "18vdhkymm4cqh5fjyz0ia0bc2mpmarjk6w6zh9ydm2d4nkj36cm5";
+    };
+  }
+  {
+    goPackagePath = "github.com/BurntSushi/toml";
+    fetch = {
+      type = "git";
+      url = "https://github.com/BurntSushi/toml";
+      rev = "a368813c5e648fee92e5f6c30e3944ff9d5e8895";
+      sha256 = "1sjxs2lwc8jpln80s4rlzp7nprbcljhy5mz4rf9995gq93wqnym5";
+    };
+  }
+  {
+    goPackagePath = "github.com/bitly/go-simplejson";
+    fetch = {
+      type = "git";
+      url = "https://github.com/bitly/go-simplejson";
+      rev = "0c965951289cce37dec52ad1f34200fefc816777";
+      sha256 = "0ys37wshd430dizzbg39x5mw55daih2q4qj5l9gr3qbmq9qdn0f3";
+    };
+  }
+  {
+    goPackagePath = "github.com/coreos/go-oidc";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/go-oidc";
+      rev = "065b426bd41667456c1a924468f507673629c46b";
+      sha256 = "10xhrh70rccgydi708dc9xl4ivmjnzhh1skd1ij6xl1i3x8lk3g6";
+    };
+  }
+  {
+    goPackagePath = "github.com/mbland/hmacauth";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mbland/hmacauth";
+      rev = "44256dfd4bfa7594cfa73587a464ca890e85971a";
+      sha256 = "1d5pbjgc5j8pi3frsjp5gqg7j12bxdbl55nhy01cv4c96hay2ij1";
+    };
+  }
+  {
+    goPackagePath = "github.com/mreiferson/go-options";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mreiferson/go-options";
+      rev = "77551d20752b54535462404ad9d877ebdb26e53d";
+      sha256 = "02c18zrx038gbas58l90xzsz9m5q3gpjprdcwmnvxsn0zvld0vpj";
+    };
+  }
+  {
+    goPackagePath = "github.com/pquerna/cachecontrol";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pquerna/cachecontrol";
+      rev = "525d0eb5f91d30e3b1548de401b7ef9ea6898520";
+      sha256 = "13r6qz9pghy9fapps5h9mhblggnjq2nfxysvf2jp4scanc5vw2y3";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "88942b9c40a4c9d203b82b3731787b672d6e809b";
+      sha256 = "0jw1faq8krcxwf1fv3w75apk1ncnykwg8y5ahs5rasjmspvkv8cw";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "6078986fec03a1dcc236c34816c71b0e05018fda";
+      sha256 = "0qbl17mzpq7anwyzy6hdvxqk7f6q2xlm6f9dknkwlszfd4id2fwb";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/oauth2";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/oauth2";
+      rev = "fdc9e635145ae97e6c2cb777c48305600cf515cb";
+      sha256 = "0pznj7pb2rjar005dvppimdynarm8smj6vnqz9wvd9fxyn0q0yww";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "13d03a9a82fba647c21a0ef8fba44a795d0f0835";
+      sha256 = "1lmyd4mk7lbgnxyvr6ndfdfafazp9a4cc6c0a2q2j4n53g2vwbgk";
+    };
+  }
+  {
+    goPackagePath = "google.golang.org/api";
+    fetch = {
+      type = "git";
+      url = "https://code.googlesource.com/google-api-go-client";
+      rev = "e4126357c891acdef6dcd7805daa4c6533be6544";
+      sha256 = "19c874pr7vhhiyw7zn6v625g8i70gqzi3rr645kai6pnd1w7s27n";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/fsnotify.v1";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/fsnotify/fsnotify.v1";
+      rev = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9";
+      sha256 = "07va9crci0ijlivbb7q57d2rz9h27zgn2fsm60spjsqpdbvyrx4g";
+    };
+  }
+  {
+    goPackagePath = "gopkg.in/square/go-jose.v2";
+    fetch = {
+      type = "git";
+      url = "https://gopkg.in/square/go-jose.v2";
+      rev = "552e98edab5d620205ff1a8960bf52a5a10aad03";
+      sha256 = "03w6rgxkvdv3vcfr23s6wbck431w7dwnw0jy7qnyl0qihxzn40rv";
+    };
+  }
+]
diff --git a/pkgs/servers/openafs-client/default.nix b/pkgs/servers/openafs-client/default.nix
deleted file mode 100644
index 5d8e255f47f1..000000000000
--- a/pkgs/servers/openafs-client/default.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-{ stdenv, fetchurl, fetchgit, which, autoconf, automake, flex, yacc,
-  kernel, glibc, ncurses, perl, kerberos }:
-
-let
-  version = if stdenv.lib.versionAtLeast kernel.version "4.2"
-    then "1.6.14-1-602130"
-    else "1.6.14";
-in
-stdenv.mkDerivation {
-  name = "openafs-${version}-${kernel.version}";
-
-  src = if version == "1.6.14-1-602130"
-    # 1.6.14 + patches to run on linux 4.2 that will get into 1.6.15
-    then fetchgit {
-      url = "git://git.openafs.org/openafs.git";
-      rev = "feab09080ec050b3026eff966352b058e2c2295b";
-      sha256 = "03j71c7y487jbjmm6ydr1hw38pf43j2dz153xknndf4x4v21nnp2";
-    }
-    else fetchurl {
-      url = "http://www.openafs.org/dl/openafs/${version}/openafs-${version}-src.tar.bz2";
-      sha256 = "3e62c798a7f982c4f88d85d32e46bee6a47848d207b1e318fe661ce44ae4e01f";
-    };
-
-  buildInputs = [ autoconf automake flex yacc ncurses perl which ];
-
-  preConfigure = ''
-    ln -s "${kernel.dev}/lib/modules/"*/build $TMP/linux
-
-    patchShebangs .
-    for i in `grep -l -R '/usr/\(include\|src\)' .`; do
-      echo "Patch /usr/include and /usr/src in $i"
-      substituteInPlace $i \
-        --replace "/usr/include" "${glibc}/include" \
-        --replace "/usr/src" "$TMP"
-    done
-
-    ./regen.sh
-
-    ${stdenv.lib.optionalString (kerberos != null)
-      "export KRB5_CONFIG=${kerberos}/bin/krb5-config"}
-
-    configureFlagsArray=(
-      "--with-linux-kernel-build=$TMP/linux"
-      ${stdenv.lib.optionalString (kerberos != null) "--with-krb5"}
-      "--sysconfdir=/etc/static"
-      "--disable-linux-d_splice-alias-extra-iput"
-    )
-  '';
-
-  meta = {
-    description = "Open AFS client";
-    homepage = http://www.openafs.org;
-    license = stdenv.lib.licenses.ipl10;
-    platforms = stdenv.lib.platforms.linux;
-    maintainers = [ stdenv.lib.maintainers.z77z ];
-  };
-}
diff --git a/pkgs/servers/openafs/default.nix b/pkgs/servers/openafs/default.nix
new file mode 100644
index 000000000000..3f92299c2a0a
--- /dev/null
+++ b/pkgs/servers/openafs/default.nix
@@ -0,0 +1,89 @@
+{ stdenv, fetchurl, fetchgit, which, autoconf, automake, flex, yacc
+, glibc, perl, kerberos, libxslt, docbook_xsl, docbook_xml_dtd_43
+, ncurses # Extra ncurses utilities. Only needed for debugging.
+, tsmbac ? null # Tivoli Storage Manager Backup Client from IBM
+}:
+
+with (import ./srcs.nix { inherit fetchurl; });
+
+stdenv.mkDerivation rec {
+  name = "openafs-${version}";
+  inherit version srcs;
+
+  nativeBuildInputs = [ autoconf automake flex yacc perl which libxslt ];
+
+  buildInputs = [ ncurses ];
+
+  patches = stdenv.lib.optional (tsmbac != null) ./tsmbac.patch;
+
+  outputs = [ "out" "dev" "man" "doc" ];
+
+  preConfigure = ''
+
+    patchShebangs .
+    for i in `grep -l -R '/usr/\(include\|src\)' .`; do
+      echo "Patch /usr/include and /usr/src in $i"
+      substituteInPlace $i \
+        --replace "/usr/include" "${glibc.dev}/include" \
+        --replace "/usr/src" "$TMP"
+    done
+
+    for i in ./doc/xml/{AdminGuide,QuickStartUnix,UserGuide}/*.xml; do
+      substituteInPlace "''${i}" --replace "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" \
+        "${docbook_xml_dtd_43}/xml/dtd/docbook/docbookx.dtd"
+    done
+
+    ./regen.sh
+
+    ${stdenv.lib.optionalString (kerberos != null)
+      "export KRB5_CONFIG=${kerberos.dev}/bin/krb5-config"}
+
+    export AFS_SYSKVERS=26
+
+    configureFlagsArray=(
+      ${stdenv.lib.optionalString (kerberos != null) "--with-krb5"}
+      "--sysconfdir=/etc"
+      "--localstatedir=/var"
+      "--disable-kernel-module"
+      "--disable-fuse-client"
+      "--with-html-xsl=${docbook_xsl}/share/xml/docbook-xsl/html/chunk.xsl"
+      ${stdenv.lib.optionalString (tsmbac != null) "--enable-tivoli-tsm"}
+      ${stdenv.lib.optionalString (ncurses == null) "--disable-gtx"}
+      "--disable-linux-d_splice-alias-extra-iput"
+    )
+  '' + stdenv.lib.optionalString (tsmbac != null) ''
+    export XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I${tsmbac}/lib64/sample -DXBSA_TSMLIB=\\\"${tsmbac}/lib64/libApiTSM64.so\\\""
+    export XBSA_XLIBS="-ldl"
+  '';
+
+  buildFlags = [ "all_nolibafs" ];
+
+  postBuild = ''
+    for d in doc/xml/{AdminGuide,QuickStartUnix,UserGuide}; do
+      make -C "''${d}" html
+    done
+  '';
+
+  postInstall = ''
+    mkdir -p $doc/share/doc/openafs/{AdminGuide,QuickStartUnix,UserGuide}
+    cp -r doc/{arch,examples,pdf,protocol,txt} README NEWS $doc/share/doc/openafs
+    for d in AdminGuide QuickStartUnix UserGuide ; do
+      cp "doc/xml/''${d}"/*.html "$doc/share/doc/openafs/''${d}"
+    done
+
+    rm -r $out/lib/{openafs,afs,*.a}
+    rm $out/bin/kpasswd
+    rm $out/sbin/{kas,kdb,ka-forwarder,kadb_check}
+    rm $out/libexec/openafs/kaserver
+    rm $man/share/man/man{1/kpasswd*,5/kaserver*,8/{ka*,kdb*}}
+  '';
+
+  meta = with stdenv.lib; {
+    outputsToInstall = [ "out" "doc" "man" ];
+    description = "Open AFS client";
+    homepage = https://www.openafs.org;
+    license = licenses.ipl10;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.z77z maintainers.spacefrogg ];
+  };
+}
diff --git a/pkgs/servers/openafs/module.nix b/pkgs/servers/openafs/module.nix
new file mode 100644
index 000000000000..8cd9287a7772
--- /dev/null
+++ b/pkgs/servers/openafs/module.nix
@@ -0,0 +1,57 @@
+{ stdenv, fetchurl, which, autoconf, automake, flex, yacc
+, kernel, glibc, perl }:
+
+with (import ./srcs.nix { inherit fetchurl; });
+
+let
+  modDestDir = "$out/lib/modules/${kernel.modDirVersion}/extra/openafs";
+  kernelBuildDir = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
+
+in stdenv.mkDerivation rec {
+  name = "openafs-${version}-${kernel.version}";
+  inherit version src;
+
+  nativeBuildInputs = [ autoconf automake flex perl yacc which ] ++ kernel.moduleBuildDependencies;
+
+  hardeningDisable = [ "pic" ];
+
+  configureFlags = [
+    "--with-linux-kernel-build=${kernelBuildDir}"
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+    "--disable-linux-d_splice-alias-extra-iput"
+  ];
+
+  preConfigure = ''
+    patchShebangs .
+    for i in `grep -l -R '/usr/\(include\|src\)' .`; do
+      echo "Patch /usr/include and /usr/src in $i"
+      substituteInPlace $i \
+        --replace "/usr/include" "${glibc.dev}/include" \
+        --replace "/usr/src" "${kernelBuildDir}"
+    done
+
+    ./regen.sh -q
+
+  '';
+
+  buildPhase = ''
+    make V=1 only_libafs
+  '';
+
+  installPhase = ''
+    mkdir -p ${modDestDir}
+    cp src/libafs/MODLOAD-*/libafs-${kernel.version}.* ${modDestDir}/libafs.ko
+    xz -f ${modDestDir}/libafs.ko
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Open AFS client kernel module";
+    homepage = https://www.openafs.org;
+    license = licenses.ipl10;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.z77z maintainers.spacefrogg ];
+    broken = versionOlder kernel.version "3.18";
+  };
+
+}
diff --git a/pkgs/servers/openafs/srcs.nix b/pkgs/servers/openafs/srcs.nix
new file mode 100644
index 000000000000..9e9ff623e5cd
--- /dev/null
+++ b/pkgs/servers/openafs/srcs.nix
@@ -0,0 +1,14 @@
+{ fetchurl }:
+rec {
+  version = "1.6.22.2";
+  src = fetchurl {
+    url = "http://www.openafs.org/dl/openafs/${version}/openafs-${version}-src.tar.bz2";
+    sha256 = "15j17igignsfzv5jb47ryczsrz3zsmiqwnj38dx9gzz95807rkyf";
+  };
+
+  srcs = [ src
+    (fetchurl {
+      url = "http://www.openafs.org/dl/openafs/${version}/openafs-${version}-doc.tar.bz2";
+      sha256 = "1lpydca95nx5pmqvplb9n3akmxbzvhhypswh0s589ywxpv3zynxm";
+    })];
+}
diff --git a/pkgs/servers/openafs/tsmbac.patch b/pkgs/servers/openafs/tsmbac.patch
new file mode 100644
index 000000000000..412765fe8a5b
--- /dev/null
+++ b/pkgs/servers/openafs/tsmbac.patch
@@ -0,0 +1,62 @@
+diff -ru3 openafs-1.6.18.1/acinclude.m4 openafs-1.6.18.1.new/acinclude.m4
+--- openafs-1.6.18.1/acinclude.m4	2016-06-21 17:13:39.000000000 +0200
++++ openafs-1.6.18.1.new/acinclude.m4	2016-11-02 18:44:30.423039662 +0100
+@@ -1373,45 +1373,7 @@
+ 
+ dnl check for tivoli
+ AC_MSG_CHECKING(for tivoli tsm butc support)
+-XBSA_CFLAGS=""
+-if test "$enable_tivoli_tsm" = "yes"; then
+-	XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
+-	XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
+-	XBSADIR3=/usr/tivoli/tsm/client/api/bin/sample
+-	XBSADIR4=/opt/tivoli/tsm/client/api/bin/sample
+-	XBSADIR5=/usr/tivoli/tsm/client/api/bin64/sample
+-	XBSADIR6=/opt/tivoli/tsm/client/api/bin64/sample
+-
+-	if test -r "$XBSADIR3/dsmapifp.h"; then
+-		XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR3"
+-		XBSA_XLIBS="-ldl"
+-		AC_MSG_RESULT([yes, $XBSA_CFLAGS])
+-	elif test -r "$XBSADIR4/dsmapifp.h"; then
+-		XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR4"
+-		XBSA_XLIBS="-ldl"
+-		AC_MSG_RESULT([yes, $XBSA_CFLAGS])
+-	elif test -r "$XBSADIR5/dsmapifp.h"; then
+-		XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR5"
+-		XBSA_XLIBS="-ldl"
+-		AC_MSG_RESULT([yes, $XBSA_CFLAGS])
+-	elif test -r "$XBSADIR6/dsmapifp.h"; then
+-		XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR6"
+-		XBSA_XLIBS="-ldl"
+-		AC_MSG_RESULT([yes, $XBSA_CFLAGS])
+-	elif test -r "$XBSADIR1/xbsa.h"; then
+-		XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
+-		XBSA_XLIBS=""
+-		AC_MSG_RESULT([yes, $XBSA_CFLAGS])
+-	elif test -r "$XBSADIR2/xbsa.h"; then
+-		XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
+-		XBSA_XLIBS=""
+-		AC_MSG_RESULT([yes, $XBSA_CFLAGS])
+-	else
+-		AC_MSG_RESULT([no, missing xbsa.h and dsmapifp.h header files])
+-	fi
+-else
+-	AC_MSG_RESULT([no])
+-fi
++AC_MSG_RESULT([yes])
+ AC_SUBST(XBSA_CFLAGS)
+ AC_SUBST(XBSA_XLIBS) 
+ 
+diff -ru3 openafs-1.6.18.1/src/butc/afsxbsa.c openafs-1.6.18.1.new/src/butc/afsxbsa.c
+--- openafs-1.6.18.1/src/butc/afsxbsa.c	2016-06-21 17:13:39.000000000 +0200
++++ openafs-1.6.18.1.new/src/butc/afsxbsa.c	2016-11-02 18:45:10.734662987 +0100
+@@ -651,7 +651,7 @@
+ #if defined(AFS_AIX_ENV)
+         dynlib = dlopen("/usr/lib/libApiDS.a(dsmapish.o)", RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER);
+ #elif defined (AFS_AMD64_LINUX26_ENV)
+-	dynlib = dlopen("/usr/lib64/libApiTSM64.so", RTLD_NOW | RTLD_LOCAL);
++	dynlib = dlopen(XBSA_TSMLIB, RTLD_NOW | RTLD_LOCAL);
+ #elif defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV)
+         dynlib = dlopen("/usr/lib/libApiDS.so", RTLD_NOW | RTLD_LOCAL);
+ #else
diff --git a/pkgs/servers/openpts/bugs.patch b/pkgs/servers/openpts/bugs.patch
deleted file mode 100644
index d818bafbc9f3..000000000000
--- a/pkgs/servers/openpts/bugs.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -urNp openpts-0.2.6-cvs-patched/src/fsm.c openpts-0.2.6-current/src/fsm.c
---- openpts-0.2.6-cvs-patched/src/fsm.c	2012-01-05 03:49:15.000000000 -0500
-+++ openpts-0.2.6-current/src/fsm.c	2012-01-09 12:11:17.338706205 -0500
-@@ -934,7 +934,7 @@ char *getEventString(OPENPTS_PCR_EVENT_W
-     /* event */
-     event = eventWrapper->event;
-     if (event != NULL) {
--        // len = snprintf(buf, size, "PCR[%d],TYPE=%d", (int)event->ulPcrIndex, event->eventType);
-+        snprintf(buf, size, "PCR[%d],TYPE=%d", (int)event->ulPcrIndex, event->eventType);
-     } else {
-         LOG(LOG_ERR, "NULL event\n");  // TODO(munetoh)
-         xfree(buf);
diff --git a/pkgs/servers/openpts/default.nix b/pkgs/servers/openpts/default.nix
deleted file mode 100644
index 7d82af72b554..000000000000
--- a/pkgs/servers/openpts/default.nix
+++ /dev/null
@@ -1,53 +0,0 @@
-{ stdenv, fetchurl, autoconf, automake, pkgconfig, libtool, trousers, openssl, libxml2, libuuid, gettext, perl }:
-
-stdenv.mkDerivation rec {
-  name = "openpts-${version}";
-  version = "0.2.6";
-
-  src = fetchurl {
-    url = "http://jaist.dl.osdn.jp/openpts/54410/openpts-${version}.tar.gz";
-    sha256 = "1b5phshl49fxr5y3g5zz75gm0n4cw8i7n29x5f1a95xkwrjpazi0";
-  };
-
-  # patches from https://apps.fedoraproject.org/packages/openpts/sources/patches/
-  patches = [ ./bugs.patch ./zlib.patch ./tboot.patch ./ptsc.patch ];
-
-  buildInputs = [ autoconf automake pkgconfig libtool trousers openssl libxml2 libuuid gettext ];
-
-  preConfigure = ''
-    substituteInPlace include/Makefile.am --replace "./cvs2msg.pl" "${perl}/bin/perl cvs2msg.pl";
-    $SHELL bootstrap.sh
-    '';
-
-  configureFlags = [ "--with-tss" "--with-aru" "--with-tboot" "--enable-tnc" "--with-aide" ];
-
-  NIX_CFLAGS_COMPILE = "-I${trousers}/include/trousers -I${trousers}/include/tss";
-
-  preInstall = ''
-    mkdir -p $out
-    mkdir -p $out/etc
-    cp -p dist/ptsc.conf.in $out/etc/ptsc.conf
-    cp -p dist/ptsv.conf.in $out/etc/ptsv.conf
-    mkdir -p $out/share/openpts/models
-    cp -p models/*.uml $out/share/openpts/models/
-
-    mkdir -p $out/share/openpts/tpm_emulator
-    cp dist/tpm_emulator/README.rhel $out/share/openpts/tpm_emulator/README
-    cp dist/tpm_emulator/binary_bios_measurements $out/share/openpts/tpm_emulator/
-    cp dist/tpm_emulator/tcsd $out/share/openpts/tpm_emulator/
-
-    mkdir -p $out/share/openpts/tboot
-    cp dist/tboot/README.fedora15 $out/share/openpts/tboot/README
-    cp dist/tboot/ptsc.conf.fedora15 $out/share/openpts/tboot/ptsc.conf
-    cp dist/tboot/tcsd.conf.fedora15 $out/share/openpts/tboot/tcsd.conf
-    cp dist/tboot/tcsd.fedora15 $out/share/openpts/tboot/tcsd
-    '';
-
-  meta = {
-    description = "TCG Platform Trust Service (PTS)";
-    homepage = "ttp://sourceforge.jp/projects/openpts";
-    license = stdenv.lib.licenses.cpl10;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = with stdenv.lib.maintainers; [ tstrobel ];
-  };
-}
diff --git a/pkgs/servers/openpts/ptsc.patch b/pkgs/servers/openpts/ptsc.patch
deleted file mode 100644
index b6fcde740744..000000000000
--- a/pkgs/servers/openpts/ptsc.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff -urNp openpts-0.2.6-patched/src/ptsc.c openpts-0.2.6-current/src/ptsc.c
---- openpts-0.2.6-patched/src/ptsc.c	2012-08-21 15:57:07.733841433 -0400
-+++ openpts-0.2.6-current/src/ptsc.c	2012-08-21 16:13:26.479732504 -0400
-@@ -457,7 +457,10 @@ void ptsc_lock(void) {
-             exit(1);
-         }
-         oldgrp = getegid();
--        setegid(grp.gr_gid);
-+        if(setegid(grp.gr_gid) != 0){
-+		LOG(LOG_ERR, "setegid fail");
-+		exit(1);
-+	}
-     }
- 
-     oldmask = umask(0);
-@@ -467,7 +470,10 @@ void ptsc_lock(void) {
-     }
-     if (grpent) {
-         chmod(LOCK_DIR, 02775);
--        setegid(oldgrp);
-+	if(setegid(oldgrp) != 0){
-+		LOG(LOG_ERR, "setegid fail");
-+		exit(1);
-+        }
-     }
-     fd = open(LOCK_FILE, O_RDWR | O_CREAT | O_TRUNC, 0660);
-     if (fd < 0) {
-
diff --git a/pkgs/servers/openpts/tboot.patch b/pkgs/servers/openpts/tboot.patch
deleted file mode 100644
index 6ecee5839202..000000000000
--- a/pkgs/servers/openpts/tboot.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -urNp openpts-0.2.6-patched/src/tboot2iml.c openpts-0.2.6-current/src/tboot2iml.c
---- openpts-0.2.6-patched/src/tboot2iml.c	2012-07-23 16:30:12.381361421 -0400
-+++ openpts-0.2.6-current/src/tboot2iml.c	2012-07-23 17:25:59.053945778 -0400
-@@ -531,7 +531,7 @@ int sinit_acm_hash(char *filename, int s
- 
- 
- int sha1sum_unzip(char *filename, int *filesize, BYTE *digest) {
--    FILE *fp;
-+    gzFile fp;
-     char buf[2048];
-     SHA_CTX sha_ctx;
-     int len;
-@@ -541,7 +541,7 @@ int sha1sum_unzip(char *filename, int *f
- 
-     /* open */
-     fp = gzopen(filename, "rb");
--    if (fp == NULL) {
-+    if (fp == Z_NULL) {
-         LOG(LOG_ERR, "File %s does not exist\n", filename);
-         return 0;
-     }
diff --git a/pkgs/servers/openpts/zlib.patch b/pkgs/servers/openpts/zlib.patch
deleted file mode 100644
index 7fa3fce10fe9..000000000000
--- a/pkgs/servers/openpts/zlib.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -urNp openpts-0.2.6-cvs-patched/src/Makefile.am openpts-0.2.6-current/src/Makefile.am
---- openpts-0.2.6-cvs-patched/src/Makefile.am	2012-01-05 03:49:15.000000000 -0500
-+++ openpts-0.2.6-current/src/Makefile.am	2012-01-09 14:12:02.507361732 -0500
-@@ -30,7 +30,7 @@ localedir = $(datadir)/locale
- 
- 
- AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBXML2_CFLAGS) $(TSS_CFLAGS) -I../include -DLOCALEDIR=\"$(localedir)\"
--AM_LDFLAGS = $(LIBXML2_LIBS) $(LIBCRYPTO_LIBS) $(TSS_LIBS) -lopenpts
-+AM_LDFLAGS = $(LIBXML2_LIBS) $(LIBCRYPTO_LIBS) $(TSS_LIBS) -lz -lopenpts
- # $(LIBINTL) -lopenpts
- 
- if HAVE_LIBUUID
diff --git a/pkgs/servers/openxpki/default.nix b/pkgs/servers/openxpki/default.nix
index dd1ed7c473b7..111c2f02b996 100644
--- a/pkgs/servers/openxpki/default.nix
+++ b/pkgs/servers/openxpki/default.nix
@@ -8,7 +8,7 @@ buildPerlPackage {
   src = fetchgit {
     url = "https://github.com/openxpki/openxpki";
     rev = "5cb76c553b6b1a81ede380857700628a7521f6e3";
-    sha256 = "7c93bdce7a205c58b08c91c249e566e885ed08f9d43cc2ac652c705c1f7e4490";
+    sha256 = "05bmhani2c7ays488xv3hx5xbxb612bnwq5rdjwmsj51xpaz454p";
   };
 
   buildInputs = [ perl openssl gettext python34Packages.sphinx ];
@@ -50,7 +50,10 @@ buildPerlPackage {
       lib libapreq2 libnet podlators threads threadsshared version ];
 
   preConfigure = ''
-    export OPENSSL_PREFIX=${openssl}
+    substituteInPlace core/server/Makefile.PL \
+      --replace "my \$openssl_inc_dir = ''';" "my \$openssl_inc_dir = '${openssl.dev}/include';" \
+      --replace "my \$openssl_lib_dir = ''';" "my \$openssl_lib_dir = '${openssl.out}/lib';" \
+      --replace "my \$openssl_binary  = ''';" "my \$openssl_binary  = '${openssl.bin}/bin/openssl';"
     substituteInPlace tools/vergen --replace "#!/usr/bin/perl" "#!${perl}/bin/perl"
     cp ${./vergen_revision_state} .vergen_revision_state
     cd core/server
@@ -69,9 +72,10 @@ buildPerlPackage {
   doCheck = false;
 
   meta = {
-    homepage = "http://www.openxpki.org";
+    homepage = http://www.openxpki.org;
     description = "Enterprise-grade PKI/Trustcenter software";
     license = stdenv.lib.licenses.asl20;
     maintainers = with stdenv.lib.maintainers; [ tstrobel ];
+    platforms = with stdenv.lib.platforms; linux;
   };
 }
diff --git a/pkgs/servers/osrm-backend/4.5.0-default-profile-path.template.patch b/pkgs/servers/osrm-backend/4.5.0-default-profile-path.template.patch
deleted file mode 100644
index 12fcdb4fd02c..000000000000
--- a/pkgs/servers/osrm-backend/4.5.0-default-profile-path.template.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/extractor/extractor_options.cpp b/extractor/extractor_options.cpp
-index d14d8d9..c64d7fd 100644
---- a/extractor/extractor_options.cpp
-+++ b/extractor/extractor_options.cpp
-@@ -50,7 +50,7 @@ bool ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &e
-     boost::program_options::options_description config_options("Configuration");
-     config_options.add_options()("profile,p",
-                                  boost::program_options::value<boost::filesystem::path>(
--                                     &extractor_config.profile_path)->default_value("profile.lua"),
-+                                     &extractor_config.profile_path)->default_value("@out@/profiles/car.lua"),
-                                  "Path to LUA routing profile")(
-         "threads,t",
-         boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
diff --git a/pkgs/servers/osrm-backend/4.5.0-openmp.patch b/pkgs/servers/osrm-backend/4.5.0-openmp.patch
deleted file mode 100644
index f4010131f602..000000000000
--- a/pkgs/servers/osrm-backend/4.5.0-openmp.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index b6a40f9..87ca301 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -261,9 +261,10 @@ target_link_libraries(OSRM ${STXXL_LIBRARY})
- target_link_libraries(osrm-extract ${STXXL_LIBRARY})
- target_link_libraries(osrm-prepare ${STXXL_LIBRARY})
- 
--if(MINGW)
--  # STXXL needs OpenMP library
--  target_link_libraries(osrm-extract gomp)
-+find_package(OpenMP)
-+if (OPENMP_FOUND)
-+    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
-+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
- endif()
- 
- find_package( OSMPBF REQUIRED )
diff --git a/pkgs/servers/osrm-backend/default.nix b/pkgs/servers/osrm-backend/default.nix
index 3e9e2158524c..04fd2e37b357 100644
--- a/pkgs/servers/osrm-backend/default.nix
+++ b/pkgs/servers/osrm-backend/default.nix
@@ -1,21 +1,18 @@
-{stdenv, fetchurl, cmake, luabind, libosmpbf, stxxl, tbb, boost, expat, protobuf, bzip2, zlib, substituteAll}:
+{stdenv, fetchFromGitHub, cmake, pkgconfig, bzip2, libxml2, libzip, boost, lua, luabind, tbb, expat}:
 
 stdenv.mkDerivation rec {
-  name = "osrm-backend-4.5.0";
+  name = "osrm-backend-${version}";
+  version = "5.18.0";
 
-  src = fetchurl {
-    url = "https://github.com/Project-OSRM/osrm-backend/archive/v4.5.0.tar.gz";
-    sha256 = "af61e883051f2ecb73520ace6f17cc6da30edc413208ff7cf3d87992eca0756c";
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner  = "Project-OSRM";
+    repo   = "osrm-backend";
+    sha256 = "0ffdw02rgjb4z7xi8fk97c0hl1i7z04csjh3yd18zsb19bk1mkva";
   };
 
-  patches = [
-    ./4.5.0-openmp.patch
-    (substituteAll {
-      src = ./4.5.0-default-profile-path.template.patch;
-    })
-  ];
-
-  buildInputs = [ cmake luabind libosmpbf stxxl tbb boost expat protobuf bzip2 zlib ];
+  nativeBuildInputs = [ cmake pkgconfig ];
+  buildInputs = [ bzip2 libxml2 libzip boost lua luabind tbb expat ];
 
   postInstall = "mkdir -p $out/share/osrm-backend && cp -r ../profiles $out/share/osrm-backend/profiles";
 
@@ -23,5 +20,7 @@ stdenv.mkDerivation rec {
     homepage = https://github.com/Project-OSRM/osrm-backend/wiki;
     description = "Open Source Routing Machine computes shortest paths in a graph. It was designed to run well with map data from the Openstreetmap Project";
     license = stdenv.lib.licenses.bsd2;
+    maintainers = with stdenv.lib.maintainers;[ erictapen ];
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/servers/owncloud/default.nix b/pkgs/servers/owncloud/default.nix
index 449eee556c1c..f02e67740b62 100644
--- a/pkgs/servers/owncloud/default.nix
+++ b/pkgs/servers/owncloud/default.nix
@@ -1,28 +1,65 @@
 { stdenv, fetchurl }:
-stdenv.mkDerivation rec {
-  name= "owncloud-${version}";
-  version = "7.0.5";
+let
+  common = { versiona, sha256 } @ args: stdenv.mkDerivation (rec {
 
-  src = fetchurl {
-    url = "https://download.owncloud.org/community/${name}.tar.bz2";
-    sha256 = "1j21b7ljvbhni9l0b1cpzlhsjy36scyas1l1j222mqdg2srfsi9y";
+    name= "owncloud-${version}";
+    version= versiona;
+
+    src = fetchurl {
+      url = "https://download.owncloud.org/community/${name}.tar.bz2";
+      inherit sha256;
+    };
+
+    installPhase =
+      ''
+        mkdir -p $out
+        find . -maxdepth 1 -execdir cp -r '{}' $out \;
+
+        substituteInPlace $out/lib/base.php \
+          --replace 'OC_Config::$object = new \OC\Config(self::$configDir);' \
+                    'self::$configDir = getenv("OC_CONFIG_PATH"); OC_Config::$object = new \OC\Config(self::$configDir);'
+      '';
+
+    meta = {
+      description = "An enterprise file sharing solution for online collaboration and storage";
+      homepage = https://owncloud.org;
+      maintainers = with stdenv.lib.maintainers; [ matejc ];
+      license = stdenv.lib.licenses.agpl3Plus;
+      platforms = with stdenv.lib.platforms; unix;
+    };
+
+  });
+
+in {
+
+  owncloud70 = common {
+    versiona = "7.0.15";
+    sha256 = "1b2a0fccxlkqyyzsymx7qw8qbhsks3i6h1ybvxv8nn8hgw33nqv7";
+  };
+
+  owncloud80 = common {
+    versiona = "8.0.16";
+    sha256 = "1pgfawrmx6n02h7h6g5wk0sa1kgablqa8ljfiywyw8znxxa5lnrm";
+  };
+
+  owncloud81 = common {
+    versiona = "8.1.11";
+    sha256 = "04izfzj3ckcs0x882kkggp6y7zcrhdihm71wkd9vk6j5fn8k9am0";
+  };
+
+  owncloud82 = common {
+    versiona = "8.2.9";
+    sha256 = "09gzpxd9gjg8h57m8j0r6xnr85fdb951ykwmjby811c6730769pw";
+  };
+
+  owncloud90 = common {
+    versiona = "9.0.7";
+    sha256 = "1j6xrd4dhc0v0maa3z8n392nfc9hrnvbxxyqr8g8kz88w9vbqa6h";
   };
 
-  installPhase =
-    ''
-      mkdir -p $out
-      find . -maxdepth 1 -execdir cp -r '{}' $out \;
-
-      substituteInPlace $out/lib/base.php \
-        --replace 'OC_Config::$object = new \OC\Config(self::$configDir);' \
-                  'self::$configDir = getenv("OC_CONFIG_PATH"); OC_Config::$object = new \OC\Config(self::$configDir);'
-    '';
-
-  meta = {
-    description = "An enterprise file sharing solution for online collaboration and storage";
-    homepage = https://owncloud.org;
-    maintainers = with stdenv.lib.maintainers; [ matejc ];
-    license = stdenv.lib.licenses.agpl3Plus;
+  owncloud91 = common {
+    versiona = "9.1.3";
+    sha256 = "1sgnsj2ng14lh05n5kc3jv03xk6xnkyx7xj1rasxlqgvzwsyp8g0";
   };
 
 }
diff --git a/pkgs/servers/p910nd/default.nix b/pkgs/servers/p910nd/default.nix
index ea5214c7bb44..bcf1255ff4a9 100644
--- a/pkgs/servers/p910nd/default.nix
+++ b/pkgs/servers/p910nd/default.nix
@@ -1,10 +1,8 @@
 { stdenv, fetchurl }:
 
-let
-  version = "0.97";
+stdenv.mkDerivation rec {
   name = "p910nd-${version}";
-in stdenv.mkDerivation {
-  inherit name;
+  version = "0.97";
 
   src = fetchurl {
     sha256 = "0vy2qf386dif1nqznmy3j953mq7c4lk6j2hgyzkbmfi4msiq1jaa";
@@ -15,7 +13,7 @@ in stdenv.mkDerivation {
     sed -e "s|/usr||g" -i Makefile
   '';
 
-  makeFlags = "DESTDIR=$(out) BINDIR=/bin";
+  makeFlags = [ "DESTDIR=$(out)" "BINDIR=/bin" ];
 
   postInstall = ''
     # Match the man page:
@@ -27,7 +25,6 @@ in stdenv.mkDerivation {
   '';
 
   meta = with stdenv.lib; {
-    inherit version;
     description = "Small printer daemon passing jobs directly to the printer";
     longDescription = ''
       p910nd is a small printer daemon intended for diskless platforms that
@@ -43,6 +40,5 @@ in stdenv.mkDerivation {
     downloadPage = http://sourceforge.net/projects/p910nd/;
     license = licenses.gpl2;
     platforms = platforms.linux;
-    maintainers = with maintainers; [ nckx ];
   };
 }
diff --git a/pkgs/servers/pies/default.nix b/pkgs/servers/pies/default.nix
index 56c7da5caedf..73af60e55c42 100644
--- a/pkgs/servers/pies/default.nix
+++ b/pkgs/servers/pies/default.nix
@@ -1,13 +1,17 @@
 { fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
-  name = "pies-1.2";
+  name = "pies-1.3";
 
   src = fetchurl {
     url = "mirror://gnu/pies/${name}.tar.bz2";
-    sha256 = "18w0dbg77i56cx1bwa789w0qi3l4xkkbascxcv2b6gbm0zmjg1g6";
+    sha256 = "12r7rjjyibjdj08dvwbp0iflfpzl4s0zhn6cr6zj3hwf9gbzgl1g";
   };
 
+  configureFlags = ["--sysconfdir=/etc"];
+
+  hardeningDisable = [ "format" ];
+
   doCheck = true;
 
   meta = {
@@ -38,7 +42,7 @@ stdenv.mkDerivation rec {
 
     homepage = http://www.gnu.org/software/pies/;
 
-    platforms = stdenv.lib.platforms.gnu;
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
     maintainers = [ ];
   };
 }
diff --git a/pkgs/servers/plex/default.nix b/pkgs/servers/plex/default.nix
index 7194e0994aad..57de5281fdfc 100644
--- a/pkgs/servers/plex/default.nix
+++ b/pkgs/servers/plex/default.nix
@@ -1,15 +1,25 @@
 { stdenv, fetchurl, rpmextract, glibc
 , dataDir ? "/var/lib/plex" # Plex's data directory must be baked into the package due to symlinks.
+, enablePlexPass ? false
 }:
 
-stdenv.mkDerivation rec {
+let
+  plexPass = throw "Plex pass has been removed at upstream's request; please unset nixpkgs.config.plex.pass";
+  plexpkg = if enablePlexPass then plexPass else {
+    version = "1.13.0.5023";
+    vsnHash = "31d3c0c65";
+    sha256 = "b94d571bcd47bc3201fd7f54b910f5693cabd1b543d5d0b4705668b7b7c24602";
+  };
+
+in stdenv.mkDerivation rec {
   name = "plex-${version}";
-  version = "0.9.12.11.1406";
-  vsnHash = "8403350";
+  version = plexpkg.version;
+  vsnHash = plexpkg.vsnHash;
+  sha256 = plexpkg.sha256;
 
   src = fetchurl {
     url = "https://downloads.plex.tv/plex-media-server/${version}-${vsnHash}/plexmediaserver-${version}-${vsnHash}.x86_64.rpm";
-    sha256 = "295174b3617d699f11ecc22bc603a579e2291fe6ba55a536711acafd64455390";
+    inherit sha256;
   };
 
   buildInputs = [ rpmextract glibc ];
@@ -26,13 +36,20 @@ stdenv.mkDerivation rec {
 
     # Now we need to patch up the executables and libraries to work on Nix.
     # Side note: PLEASE don't put spaces in your binary names. This is stupid.
-    for bin in "Plex Media Server" "Plex DLNA Server" "Plex Media Scanner"; do
-      patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" "$out/usr/lib/plexmediaserver/$bin"
+    for bin in "Plex Media Server"              \
+               "Plex DLNA Server"               \
+               "Plex Media Scanner"             \
+               "Plex Media Server Tests"        \
+               "Plex Relay"                     \
+               "Plex Script Host"               \
+               "Plex Transcoder"                \
+               "Plex Tuner Service"             ; do
+      patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" "$out/usr/lib/plexmediaserver/$bin"
       patchelf --set-rpath "$out/usr/lib/plexmediaserver" "$out/usr/lib/plexmediaserver/$bin"
     done
 
     find $out/usr/lib/plexmediaserver/Resources -type f -a -perm -0100 \
-        -print -exec patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" '{}' \;
+        -print -exec patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" '{}' \;
 
     # executables need libstdc++.so.6
     ln -s "${stdenv.lib.makeLibraryPath [ stdenv.cc.cc ]}/libstdc++.so.6" "$out/usr/lib/plexmediaserver/libstdc++.so.6"
@@ -57,7 +74,7 @@ stdenv.mkDerivation rec {
     homepage = http://plex.tv/;
     license = licenses.unfree;
     platforms = platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ forkk ];
+    maintainers = with stdenv.lib.maintainers; [ colemickens forkk thoughtpolice pjones lnl7 ];
     description = "Media / DLNA server";
     longDescription = ''
       Plex is a media server which allows you to store your media and play it
diff --git a/pkgs/servers/plexpy/default.nix b/pkgs/servers/plexpy/default.nix
new file mode 100644
index 000000000000..2875ecc52404
--- /dev/null
+++ b/pkgs/servers/plexpy/default.nix
@@ -0,0 +1,41 @@
+{stdenv, fetchFromGitHub, python}:
+
+stdenv.mkDerivation rec {
+  version = "1.4.25";
+  pname = "plexpy";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "JonnyWong16";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0a4ynrfamlwkgqil4n61v47p21czxpjdzg0mias4kdjam2nnwnjx";
+  };
+
+  buildPhase = ":";
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R * $out/
+
+    # Remove superfluous Python checks from main script;
+    # prepend shebang
+    echo "#!${python.interpreter}" > $out/PlexPy.py
+    tail -n +7 PlexPy.py >> $out/PlexPy.py
+
+    mkdir $out/bin
+    # Can't just symlink to the main script, since it uses __file__ to
+    # import bundled packages and manage the service
+    echo "#!/bin/bash" > $out/bin/plexpy
+    echo "$out/PlexPy.py \$*" >> $out/bin/plexpy
+    chmod +x $out/bin/plexpy
+  '';
+
+  meta  = with stdenv.lib; {
+    description = "A Python based monitoring and tracking tool for Plex Media Server.";
+    homepage = http://jonnywong16.github.io/plexpy/;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ csingley ];
+  };
+}
diff --git a/pkgs/servers/polipo/default.nix b/pkgs/servers/polipo/default.nix
index 08ccbbd06c6b..a7a0791b8520 100644
--- a/pkgs/servers/polipo/default.nix
+++ b/pkgs/servers/polipo/default.nix
@@ -16,7 +16,10 @@ stdenv.mkDerivation rec {
     homepage = http://www.pps.jussieu.fr/~jch/software/polipo/;
     description = "A small and fast caching web proxy";
     license = licenses.mit;
-    maintainers = with maintainers; [ phreedom emery ];
+    maintainers = with maintainers; [ phreedom ehmry ];
     platforms = platforms.all;
+    knownVulnerabilities = [
+      "Unmaintained upstream: https://github.com/jech/polipo/commit/4d42ca1b5849"
+    ];
   };
-}
\ No newline at end of file
+}
diff --git a/pkgs/servers/portmap/default.nix b/pkgs/servers/portmap/default.nix
deleted file mode 100644
index e53690ebc113..000000000000
--- a/pkgs/servers/portmap/default.nix
+++ /dev/null
@@ -1,45 +0,0 @@
-{ fetchurl, stdenv, lib, tcp_wrappers
-, daemonUser ? false, daemonUID ? false, daemonGID ? false }:
-
-assert daemonUser -> (!daemonUID && !daemonGID);
-
-stdenv.mkDerivation rec {
-  name = "portmap-6.0";
-  
-  src = fetchurl {
-    url = "http://neil.brown.name/portmap/${name}.tgz";
-    sha256 = "1pj13ll4mbfwjwpn3fbg03qq9im6v2i8fcpa3ffp4viykz9j1j02";
-  };
-
-  patches = [ ./reuse-socket.patch ];
-
-  postPatch = ''
-    substituteInPlace "Makefile" --replace "/usr/share" "" \
-      --replace "install -o root -g root" "install"
-  '';
-
-  makeFlags =
-    lib.optional (daemonUser != false) "RPCUSER=\"${daemonUser}\""
-    ++ lib.optional (daemonUID != false) "DAEMON_UID=${toString daemonUID}"
-    ++ lib.optional (daemonGID != false) "DAEMON_GID=${toString daemonGID}";
-
-  buildInputs = [ tcp_wrappers ];
-
-  installPhase = ''
-    mkdir -p "$out/sbin" "$out/man/man8"
-    make install BASEDIR=$out
-  '';
-
-  meta = {
-    description = "ONC RPC portmapper";
-    longDescription = ''
-      Portmap is part of the ONC RPC software collection implementing
-      remote procedure calls (RPCs) between computer programs.  It is
-      widely used by NFS and NIS, among others.
-    '';
-
-    homepage = http://neil.brown.name/portmap/;
-    license = "BSD";
-    platforms = stdenv.lib.platforms.linux;
-  };
-}
diff --git a/pkgs/servers/portmap/reuse-socket.patch b/pkgs/servers/portmap/reuse-socket.patch
deleted file mode 100644
index 7d1a0ca09524..000000000000
--- a/pkgs/servers/portmap/reuse-socket.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-Set SO_REUSEADDR to ensure that portmap can restart properly.
-
-https://bugs.launchpad.net/ubuntu/+source/portmap/+bug/688550
-
-===================================================================
---- portmap-6.0.0.orig/portmap.c	2011-03-16 20:43:26.000000000 +0100
-+++ portmap-6.0.0/portmap.c	2011-03-17 07:30:17.000000000 +0100
-@@ -142,9 +142,9 @@
-   * loopback interface address.
-   */
- 
-+static int on = 1;
- #ifdef LOOPBACK_SETUNSET
- static SVCXPRT *ludpxprt, *ltcpxprt;
--static int on = 1;
- #ifndef INADDR_LOOPBACK
- #define INADDR_LOOPBACK ntohl(inet_addr("127.0.0.1"))
- #endif
-@@ -399,9 +399,7 @@
- 		syslog(LOG_ERR, "cannot create udp socket: %m");
- 		exit(1);
- 	}
--#ifdef LOOPBACK_SETUNSET
- 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on);
--#endif
- 
- 	memset((char *) &addr, 0, sizeof(addr));
- 	addr.sin_addr.s_addr = 0;
-@@ -434,9 +432,7 @@
- 		syslog(LOG_ERR, "cannot create tcp socket: %m");
- 		exit(1);
- 	}
--#ifdef LOOPBACK_SETUNSET
- 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on);
--#endif
- 	if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
- 		syslog(LOG_ERR, "cannot bind tcp: %m");
- 		exit(1);
diff --git a/pkgs/servers/prayer/default.nix b/pkgs/servers/prayer/default.nix
index 1e476cb2301a..7997d0ebcd8b 100644
--- a/pkgs/servers/prayer/default.nix
+++ b/pkgs/servers/prayer/default.nix
@@ -6,31 +6,36 @@ let
 in
 stdenv.mkDerivation rec {
   name = "prayer-1.3.5";
-  
+
   src = fetchurl {
     url = "ftp://ftp.csx.cam.ac.uk/pub/software/email/prayer/${name}.tar.gz";
     sha256 = "135fjbxjn385b6cjys6qhbwfw61mdcl2akkll4jfpdzfvhbxlyda";
   };
 
-  buildInputs = [ openssl db zlib uwimap html-tidy pam ];
-  nativeBuildInputs = [ perl ];
-
-  NIX_LDFLAGS = "-lpam";
-
   patches = [ ./install.patch ];
   postPatch = ''
     sed -i -e s/gmake/make/ -e 's/LDAP_ENABLE.*= true/LDAP_ENABLE=false/' \
       ${ssl} \
       -e 's/CCLIENT_LIBS=.*/CCLIENT_LIBS=-lc-client/' \
       -e 's,^PREFIX .*,PREFIX='$out, \
+      -e 's,^CCLIENT_DIR=.*,CCLIENT_DIR=${uwimap}/include/c-client,' \
       Config
     sed -i -e s,/usr/bin/perl,${perl}/bin/perl, \
       templates/src/*.pl
+  '' + /* html-tidy updates */ ''
+    substituteInPlace ./session/html_secure_tidy.c \
+      --replace buffio.h tidybuffio.h
   '';
 
+  buildInputs = [ openssl db zlib uwimap html-tidy pam ];
+  nativeBuildInputs = [ perl ];
+
+  NIX_LDFLAGS = "-lpam";
+
   meta = {
     homepage = http://www-uxsup.csx.cam.ac.uk/~dpc22/prayer/;
     description = "Yet another Webmail interface for IMAP servers on Unix systems written in C";
     license = stdenv.lib.licenses.gpl2Plus;
+    platforms = stdenv.lib.platforms.linux;
   };
 }
diff --git a/pkgs/servers/ps3netsrv/default.nix b/pkgs/servers/ps3netsrv/default.nix
new file mode 100644
index 000000000000..6aaaf95fae16
--- /dev/null
+++ b/pkgs/servers/ps3netsrv/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchgit }:
+
+stdenv.mkDerivation rec {
+  name = "ps3netsrv-${version}";
+  version = "1.1.0";
+
+  enableParallelBuilding = true;
+
+  src = fetchgit {
+    url = "https://github.com/dirkvdb/ps3netsrv--";
+    fetchSubmodules = true;
+    rev = "e54a66cbf142b86e2cffc1701984b95adb921e81";
+    sha256 = "09hvmfzqy2jckpsml0z1gkcnar8sigmgs1q66k718fph2d3g54sa";
+  };
+
+  buildPhase = "make CXX=$CXX";
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ps3netsrv++ $out/bin
+  '';
+
+  meta = {
+    description = "C++ implementation of the ps3netsrv server";
+    homepage = https://github.com/dirkvdb/ps3netsrv--;
+    license = stdenv.lib.licenses.mit;
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ makefu ];
+  };
+}
diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix
index d1888e1928a9..ed4a8889c67d 100644
--- a/pkgs/servers/pulseaudio/default.nix
+++ b/pkgs/servers/pulseaudio/default.nix
@@ -1,5 +1,5 @@
-{ lib, stdenv, fetchurl, pkgconfig, intltool, autoreconfHook
-, json_c, libsndfile, libtool
+{ lib, stdenv, fetchurl, fetchpatch, pkgconfig, intltool, autoreconfHook
+, libsndfile, libtool
 , xorg, libcap, alsaLib, glib
 , avahi, libjack2, libasyncns, lirc, dbus
 , sbc, bluez5, udev, openssl, fftwFloat
@@ -30,18 +30,31 @@
 
 , # Whether to build only the library.
   libOnly ? false
+
+, CoreServices, AudioUnit, Cocoa
 }:
 
 stdenv.mkDerivation rec {
   name = "${if libOnly then "lib" else ""}pulseaudio-${version}";
-  version = "7.0";
+  version = "11.1";
 
   src = fetchurl {
     url = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${version}.tar.xz";
-    sha256 = "1yp8x8z4wigrzik131kjdyhn7hznazvbkbp2zz1vy9l9gqvy26na";
+    sha256 = "17ndr6kc7hpv4ih4gygwlcpviqifbkvnk4fbwf4n25kpb991qlpj";
   };
 
-  patches = [ ./caps-fix.patch ];
+  patches = [ ./caps-fix.patch (fetchpatch {
+    name = "glibc-2.27.patch";
+    url = "https://cgit.freedesktop.org/pulseaudio/pulseaudio/patch/?id=dfb0460fb4743aec047cdf755a660a9ac2d0f3fb";
+    sha256 = "1bi6rbfdjyl6wn0jql4k18xa4hm5l2lpf1sc5j77f8l6jw956afv";
+  }) ]
+    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl (fetchpatch {
+      name = "padsp-fix.patch";
+      url = "https://git.alpinelinux.org/cgit/aports/plain/testing/pulseaudio/0001-padsp-Make-it-compile-on-musl.patch?id=167be02bf4618a90328e2b234f6a63a5dc05f244";
+      sha256 = "0gf4w25zi123ghk0njapysvrlljkc3hyanacgiswfnnm1i8sab1q";
+    });
+
+  outputs = [ "out" "dev" ];
 
   nativeBuildInputs = [ pkgconfig intltool autoreconfHook ];
 
@@ -49,8 +62,9 @@ stdenv.mkDerivation rec {
     lib.optionals stdenv.isLinux [ libcap ];
 
   buildInputs =
-    [ json_c libsndfile speexdsp fftwFloat ]
-    ++ lib.optionals stdenv.isLinux [ glib dbus.libs ]
+    [ libtool libsndfile speexdsp fftwFloat ]
+    ++ lib.optionals stdenv.isLinux [ glib dbus ]
+    ++ lib.optionals stdenv.isDarwin [ CoreServices AudioUnit Cocoa ]
     ++ lib.optionals (!libOnly) (
       [ libasyncns webrtc-audio-processing ]
       ++ lib.optional jackaudioSupport libjack2
@@ -110,13 +124,14 @@ stdenv.mkDerivation rec {
 
   postInstall = lib.optionalString libOnly ''
     rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}}
-    sed 's|-lltdl|-L${libtool}/lib -lltdl|' -i $out/lib/libpulsecore-${version}.la
-  '';
+    sed 's|-lltdl|-L${libtool.lib}/lib -lltdl|' -i $out/lib/pulseaudio/libpulsecore-${version}.la
+  ''
+    + ''moveToOutput lib/cmake "$dev" '';
 
   meta = {
     description = "Sound server for POSIX and Win32 systems";
     homepage    = http://www.pulseaudio.org/;
-    licenses    = lib.licenses.lgpl2Plus;
+    license     = lib.licenses.lgpl2Plus;
     maintainers = with lib.maintainers; [ lovek323 wkennington ];
     platforms   = lib.platforms.unix;
 
diff --git a/pkgs/servers/quagga/default.nix b/pkgs/servers/quagga/default.nix
new file mode 100644
index 000000000000..c6f150938ac6
--- /dev/null
+++ b/pkgs/servers/quagga/default.nix
@@ -0,0 +1,73 @@
+{ stdenv, fetchurl, libcap, libnl, readline, net_snmp, less, perl, texinfo,
+  pkgconfig, c-ares }:
+
+stdenv.mkDerivation rec {
+  name = "quagga-${version}";
+  version = "1.2.4";
+
+  src = fetchurl {
+    url = "mirror://savannah/quagga/${name}.tar.gz";
+    sha256 = "1lsksqxij5f1llqn86pkygrf5672kvrqn1kvxghi169hqf1c0r73";
+  };
+
+  buildInputs =
+    [ readline net_snmp c-ares ]
+    ++ stdenv.lib.optionals stdenv.isLinux [ libcap libnl ];
+
+  nativeBuildInputs = [ pkgconfig perl texinfo ];
+
+  configureFlags = [
+    "--sysconfdir=/etc/quagga"
+    "--localstatedir=/run/quagga"
+    "--sbindir=$(out)/libexec/quagga"
+    "--disable-exampledir"
+    "--enable-user=quagga"
+    "--enable-group=quagga"
+    "--enable-configfile-mask=0640"
+    "--enable-logfile-mask=0640"
+    "--enable-vtysh"
+    "--enable-vty-group=quaggavty"
+    "--enable-snmp"
+    "--enable-multipath=64"
+    "--enable-rtadv"
+    "--enable-irdp"
+    "--enable-opaque-lsa"
+    "--enable-ospf-te"
+    "--enable-pimd"
+    "--enable-isis-topology"
+  ];
+
+  preConfigure = ''
+    substituteInPlace vtysh/vtysh.c --replace \"more\" \"${less}/bin/less\"
+  '';
+
+  postInstall = ''
+    rm -f $out/bin/test_igmpv3_join
+    mv -f $out/libexec/quagga/ospfclient $out/bin/
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Quagga BGP/OSPF/ISIS/RIP/RIPNG routing daemon suite";
+    longDescription = ''
+      GNU Quagga is free software which manages TCP/IP based routing protocols.
+      It supports BGP4, BGP4+, OSPFv2, OSPFv3, IS-IS, RIPv1, RIPv2, and RIPng as
+      well as the IPv6 versions of these.
+
+      As the predecessor Zebra has been considered orphaned, the Quagga project
+      has been formed by members of the zebra mailing list and the former
+      zebra-pj project to continue developing.
+
+      Quagga uses threading if the kernel supports it, but can also run on
+      kernels that do not support threading. Each protocol has its own daemon.
+
+      It is more than a routed replacement, it can be used as a Route Server and
+      a Route Reflector.
+    '';
+    homepage = http://www.nongnu.org/quagga/;
+    license = licenses.gpl2;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ tavyc ];
+  };
+}
diff --git a/pkgs/servers/radarr/default.nix b/pkgs/servers/radarr/default.nix
new file mode 100644
index 000000000000..5fd23476d7da
--- /dev/null
+++ b/pkgs/servers/radarr/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, mono, libmediainfo, sqlite, curl, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "radarr-${version}";
+  version = "0.2.0.995";
+
+  src = fetchurl {
+    url = "https://github.com/Radarr/Radarr/releases/download/v${version}/Radarr.develop.${version}.linux.tar.gz";
+    sha256 = "04sgs292qz65fcg5vsps0fk2669xzvyfw1rbc5sbbk3hig5lhlns";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out/{bin,share/${name}}
+    cp -r * $out/share/${name}/.
+
+    makeWrapper "${mono}/bin/mono" $out/bin/Radarr \
+      --add-flags "$out/share/${name}/Radarr.exe" \
+      --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [
+          curl sqlite libmediainfo ]}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A Usenet/BitTorrent movie downloader.";
+    homepage = https://radarr.video/;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ edwtjo ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/radicale/1.x.nix b/pkgs/servers/radicale/1.x.nix
new file mode 100644
index 000000000000..13db868845a0
--- /dev/null
+++ b/pkgs/servers/radicale/1.x.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, pythonPackages }:
+
+pythonPackages.buildPythonApplication rec {
+  name = "radicale-${version}";
+  version = "1.1.6";
+
+  src = fetchurl {
+    url = "mirror://pypi/R/Radicale/Radicale-${version}.tar.gz";
+    sha256 = "0ay90nj6fmr2aq8imi0mbjl4m2rzq7a83ikj8qs9gxsylj71j1y0";
+  };
+
+  propagatedBuildInputs = stdenv.lib.optionals (!pythonPackages.isPy3k) [
+    pythonPackages.flup
+    pythonPackages.ldap
+    pythonPackages.sqlalchemy
+  ];
+
+  doCheck = !pythonPackages.isPy3k;
+
+  meta = with stdenv.lib; {
+    homepage = http://www.radicale.org/;
+    description = "CalDAV CardDAV server";
+    longDescription = ''
+      The Radicale Project is a complete CalDAV (calendar) and CardDAV
+      (contact) server solution. Calendars and address books are available for
+      both local and remote access, possibly limited through authentication
+      policies. They can be viewed and edited by calendar and contact clients
+      on mobile phones or computers.
+    '';
+    license = licenses.gpl3Plus;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ edwtjo pSub aneeshusa ];
+  };
+}
diff --git a/pkgs/servers/radicale/default.nix b/pkgs/servers/radicale/default.nix
new file mode 100644
index 000000000000..171fcc887d21
--- /dev/null
+++ b/pkgs/servers/radicale/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitHub, python3Packages }:
+
+let
+  version = "2.1.9";
+  sha256 = "1sywxn7j9bq39qwq74h327crc44j9049cykai1alv44agx8s1nhz";
+in
+
+python3Packages.buildPythonApplication {
+  name = "radicale-${version}";
+  inherit version;
+
+  src = fetchFromGitHub {
+    owner = "Kozea";
+    repo = "Radicale";
+    rev = version;
+    inherit sha256;
+  };
+
+  doCheck = false;
+
+  propagatedBuildInputs = with python3Packages; [
+    vobject
+    passlib
+    pytz
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.radicale.org/;
+    description = "CalDAV CardDAV server";
+    longDescription = ''
+      The Radicale Project is a complete CalDAV (calendar) and CardDAV
+      (contact) server solution. Calendars and address books are available for
+      both local and remote access, possibly limited through authentication
+      policies. They can be viewed and edited by calendar and contact clients
+      on mobile phones or computers.
+    '';
+    license = licenses.gpl3Plus;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ edwtjo pSub aneeshusa infinisil ];
+  };
+}
diff --git a/pkgs/servers/radius/default.nix b/pkgs/servers/radius/default.nix
deleted file mode 100644
index a8c991e12d3e..000000000000
--- a/pkgs/servers/radius/default.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{ fetchurl, stdenv, m4, groff, readline }:
-
-stdenv.mkDerivation rec {
-  name = "radius-1.6.1";
-
-  src = fetchurl {
-    url = "mirror://gnu/radius/${name}.tar.gz";
-    sha256 = "1l4k17zkbjsmk8mqrjjymagq8a8kwgrain9mcb5zp8jaf1qbclrh";
-  };
-
-  buildInputs = [ m4 groff readline ] ;
-
-  doCheck = true;
-
-  meta = {
-    description = "GNU Radius remote authentication and accounting system";
-
-    longDescription =
-      '' Radius is a server for remote user authentication and
-         accounting.  Its primary use is for Internet Service
-         Providers, though it may as well be used on any network that
-         needs a centralized authentication and/or accounting service
-         for its workstations.  The package includes an authentication
-         and accounting server and administrator tools.
-      '';
-
-    homepage = http://www.gnu.org/software/radius/;
-    license = stdenv.lib.licenses.gpl3Plus;
-
-    maintainers = [ stdenv.lib.maintainers.bjg ];
-    platforms = stdenv.lib.platforms.all;
-
-    broken = true;
-  };
-}
diff --git a/pkgs/servers/restund/default.nix b/pkgs/servers/restund/default.nix
deleted file mode 100644
index 8a831f7ff697..000000000000
--- a/pkgs/servers/restund/default.nix
+++ /dev/null
@@ -1,33 +0,0 @@
-{ stdenv, fetchurl, zlib, openssl, libre, librem, mysql }:
-stdenv.mkDerivation rec {
-  version = "0.4.2";
-  name = "restund-${version}";
-  src=fetchurl {
-    url = "http://www.creytiv.com/pub/restund-${version}.tar.gz";
-    sha256 = "db5260939d40cb2ce531075bef02b9d6431067bdd52f3168a6f25246bdf7b9f2";
-  };
-  buildInputs = [ zlib openssl libre librem mysql.lib ];
-  makeFlags = [
-    "LIBRE_MK=${libre}/share/re/re.mk"
-    "LIBRE_INC=${libre}/include/re"
-    "LIBRE_SO=${libre}/lib"
-    "LIBREM_PATH=${librem}"
-    ''PREFIX=$(out)''
-    "USE_MYSQL=1"
-  ]
-  ++ stdenv.lib.optional (stdenv.cc.cc != null) "SYSROOT_ALT=${stdenv.cc.cc}"
-  ++ stdenv.lib.optional (stdenv.cc.libc != null) "SYSROOT=${stdenv.cc.libc}"
-  ;
-  NIX_LDFLAGS='' -L${mysql.lib}/lib/mysql '';
-  meta = {
-    homepage = "http://www.creytiv.com/restund.html";
-    platforms = with stdenv.lib.platforms; linux;
-    maintainers = with stdenv.lib.maintainers; [raskin];
-    license = stdenv.lib.licenses.bsd3;
-    inherit version;
-    downloadPage = "http://www.creytiv.com/pub/";
-    updateWalker = true;
-    downloadURLRegexp = "/restund-.*[.]tar[.]";
-    broken = true; # probably due to glibc-2.20
-  };
-}
diff --git a/pkgs/servers/rippled/default.nix b/pkgs/servers/rippled/default.nix
index 808f181442a9..c1d9655ef23a 100644
--- a/pkgs/servers/rippled/default.nix
+++ b/pkgs/servers/rippled/default.nix
@@ -15,7 +15,8 @@ stdenv.mkDerivation rec {
     sed -i -e "s@ENV = dict.*@ENV = os.environ@g" SConstruct
   '';
 
-  buildInputs = [ scons pkgconfig openssl protobuf boost zlib ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ scons openssl protobuf boost zlib ];
 
   buildPhase = "scons";
 
@@ -27,8 +28,9 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "Ripple P2P payment network reference server";
     homepage = https://ripple.com;
-    maintainers = with maintainers; [ emery offline ];
+    maintainers = with maintainers; [ ehmry offline ];
     license = licenses.isc;
     platforms = [ "x86_64-linux" ];
+    broken = true;
   };
 }
diff --git a/pkgs/servers/rippled/ripple-rest.nix b/pkgs/servers/rippled/ripple-rest.nix
deleted file mode 100644
index 01fd098c920f..000000000000
--- a/pkgs/servers/rippled/ripple-rest.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ lib, fetchFromGitHub, nodePackages }:
-
-with lib;
-
-let
-  np = nodePackages.override { generated = ./package.nix; self = np; };
-in nodePackages.buildNodePackage rec {
-  name = "ripple-rest-${version}";
-  version = "1.7.0-rc1";
-
-  src = fetchFromGitHub {
-    repo = "ripple-rest";
-    owner = "ripple";
-    rev = version;
-    sha256 = "19ixgrz40iawd927jan0g1ac8w56wxh2vy3n3sa3dn9cmjd4k2r3";
-  };
-
-  deps = (filter (v: nixType v == "derivation") (attrValues np));
-
-  meta = {
-    description = " RESTful API for submitting payments and monitoring accounts on the Ripple Network";
-    homepage = https://github.com/ripple/ripple-rest;
-    maintainers = with maintainers; [ offline ];
-    license = [ licenses.mit ];
-  };
-}
diff --git a/pkgs/servers/rpcbind/default.nix b/pkgs/servers/rpcbind/default.nix
index 6eb8a57cab4f..6b3d60bcaea1 100644
--- a/pkgs/servers/rpcbind/default.nix
+++ b/pkgs/servers/rpcbind/default.nix
@@ -1,21 +1,32 @@
-{ fetchurl, stdenv, pkgconfig, libtirpc
+{ fetchurl, stdenv, pkgconfig, libnsl, libtirpc, fetchpatch
 , useSystemd ? true, systemd }:
 
-let version = "0.2.3";
-in stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   name = "rpcbind-${version}";
-  
+  version = "0.2.4";
+
   src = fetchurl {
     url = "mirror://sourceforge/rpcbind/${version}/${name}.tar.bz2";
-    sha256 = "0yyjzv4161rqxrgjcijkrawnk55rb96ha0pav48s03l2klx855wq";
+    sha256 = "0rjc867mdacag4yqvs827wqhkh27135rp9asj06ixhf71m9rljh7";
   };
 
-  patches = [ ./sunrpc.patch ];
+  patches = [
+    ./sunrpc.patch
+    (fetchpatch {
+      name = "CVE-2017-8779.patch";
+      url = "https://raw.githubusercontent.com/guidovranken/rpcbomb/e6da9e489aa8ad000b0ad5ac9abc5b4eefc3a769/rpcbind_patch.txt";
+      sha256 = "0w231w8fxihgrn526np078j3vbj3ylvjvxjmfpjvqhga5zg821ab";
+    })
+  ];
 
-  buildInputs = [ libtirpc ]
+  buildInputs = [ libnsl libtirpc ]
              ++ stdenv.lib.optional useSystemd systemd;
 
-  configureFlags = stdenv.lib.optional (!useSystemd) "--with-systemdsystemunitdir=no";
+  configureFlags = [
+    "--with-systemdsystemunitdir=${if useSystemd then "$(out)/etc/systemd/system" else "no"}"
+    "--enable-warmstarts"
+    "--with-rpcuser=rpc"
+  ];
 
   nativeBuildInputs = [ pkgconfig ];
 
@@ -23,7 +34,7 @@ in stdenv.mkDerivation rec {
     description = "ONC RPC portmapper";
     license = licenses.bsd3;
     platforms = platforms.unix;
-    homepage = http://sourceforge.net/projects/rpcbind/;
+    homepage = https://sourceforge.net/projects/rpcbind/;
     maintainers = with maintainers; [ abbradar ];
     longDescription = ''
       Universal addresses to RPC program number mapper.
diff --git a/pkgs/servers/rt/default.nix b/pkgs/servers/rt/default.nix
new file mode 100644
index 000000000000..dcbfc40d7ddd
--- /dev/null
+++ b/pkgs/servers/rt/default.nix
@@ -0,0 +1,102 @@
+{ stdenv, buildEnv, fetchurl, perl, perlPackages, makeWrapper }:
+
+# This package isn't extremely useful as it is, but is getting close.
+# After running:
+#
+#   nix-build . -A rt
+#
+# I created a config file named myconfig.pm with:
+#
+#   use utf8;
+#   Set($rtname, '127.0.0.1');
+#   # These dirs need to be pre-created:
+#   Set($MasonSessionDir, '/home/grahamc/foo/sessiondir/');
+#   Set($MasonDataDir, '/home/grahamc/foo/localstate/');
+#   Set($WebPort, 8080);
+#
+#   Set($DatabaseType, "SQLite");
+#   Set( $DatabaseName, '/home/grahamc/projects/foo/my.db' );
+#
+#   1;
+#
+# and ran
+#
+#  RT_SITE_CONFIG=$(pwd)/myconfig.pm ./result/bin/rt-setup-database --action init
+#
+# Then:
+#
+#   RT_SITE_CONFIG=$(pwd)/myconfig.pm ./result/bin/rt-server
+#
+# Make sure to check out result/etc/RT_Config.pm
+#
+# Good luck.
+stdenv.mkDerivation rec {
+  name = "rt-${version}";
+
+  version = "4.4.2";
+
+  src = fetchurl {
+    url = "https://download.bestpractical.com/pub/rt/release/${name}.tar.gz";
+    sha256 = "0s5ykc5imcii66zkzcb8lf8adkr8zlbc2ikcpkaxzcccikhndqxj";
+  };
+
+  patches = [ ./override-generated.patch ];
+
+  buildInputs = [
+    makeWrapper
+    perl
+    (buildEnv {
+      name = "rt-perl-deps";
+      paths = (with perlPackages; [
+        ApacheSession BusinessHours CGIEmulatePSGI CGIPSGI
+        CSSMinifierXP CSSSquish ConvertColor CryptEksblowfish
+        CryptSSLeay DBDSQLite DBDmysql DBIxSearchBuilder DataGUID
+        DataICal DataPagePageset DateExtract DateManip
+        DateTimeFormatNatural DevelGlobalDestruction EmailAddress
+        EmailAddressList FCGI FCGIProcManager FileShareDir FileWhich
+        GD GDGraph GnuPGInterface GraphViz HTMLFormatTextWithLinks
+        HTMLFormatTextWithLinksAndTables HTMLMason
+        HTMLMasonPSGIHandler HTMLQuoted HTMLRewriteAttributes
+        HTMLScrubber IPCRun IPCRun3 JSON JavaScriptMinifierXS LWP
+        LWPProtocolHttps LocaleMaketextFuzzy LocaleMaketextLexicon
+        LogDispatch MIMETools MIMETypes MailTools ModuleRefresh
+        ModuleVersionsReport MozillaCA NetCIDR NetIP PerlIOeol Plack
+        RegexpCommon RegexpCommonnetCIDR RegexpIPv6 RoleBasic
+        ScopeUpper Starlet SymbolGlobalName TermReadKey
+        TextPasswordPronounceable TextQuoted TextTemplate
+        TextWikiFormat TextWrapper TimeParseDate TreeSimple
+        UNIVERSALrequire XMLRSS
+      ]);
+    })
+  ];
+
+  preConfigure = ''
+    configureFlags="$configureFlags --with-web-user=$UID"
+    configureFlags="$configureFlags --with-web-group=$(id -g)"
+    configureFlags="$configureFlags --with-rt-group=$(id -g)"
+    configureFlags="$configureFlags --with-bin-owner=$UID"
+    configureFlags="$configureFlags --with-libs-owner=$UID"
+    configureFlags="$configureFlags --with-libs-group=$(id -g)"
+  '';
+  configureFlags = [
+    "--enable-graphviz"
+    "--enable-gd"
+    "--enable-gpg"
+    "--with-db-type=SQLite"
+  ];
+
+  buildPhase = ''
+    make testdeps | grep -i missing | sort
+  '';
+
+  preFixup = ''
+    for i in $(find $out/bin -type f; find $out/sbin -type f); do
+      wrapProgram $i \
+          --prefix PERL5LIB ':' $PERL5LIB
+    done
+  '';
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/pkgs/servers/rt/override-generated.patch b/pkgs/servers/rt/override-generated.patch
new file mode 100644
index 000000000000..5727a9b50c58
--- /dev/null
+++ b/pkgs/servers/rt/override-generated.patch
@@ -0,0 +1,21 @@
+commit 7aec1e9478ef679227e759ab9537df7584c6a852
+Author: Shea Levy <shea@shealevy.com>
+Date:   Fri Jan 15 09:09:18 2016 -0500
+
+    Make it possible to override hard-coded paths
+
+diff --git a/lib/RT/Generated.pm.in b/lib/RT/Generated.pm.in
+index 9dcb80b..99b034b 100644
+--- a/lib/RT/Generated.pm.in
++++ b/lib/RT/Generated.pm.in
+@@ -82,4 +82,10 @@ $MasonDataDir = '@MASON_DATA_PATH@';
+ $MasonSessionDir = '@MASON_SESSION_PATH@';
+ 
+ 
++if ( my $override_file = $ENV{RT_PATHS_OVERRIDE} )
++{
++    require "$override_file" || die "Couldn't load paths override file: $@";
++}
++
++
+ 1;
diff --git a/pkgs/servers/s6/default.nix b/pkgs/servers/s6/default.nix
deleted file mode 100644
index 5e29c20339cf..000000000000
--- a/pkgs/servers/s6/default.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ stdenv, execline, fetchgit, skalibs }:
-
-let
-
-  version = "2.2.1.0";
-
-in stdenv.mkDerivation rec {
-
-  name = "s6-${version}";
-
-  src = fetchgit {
-    url = "git://git.skarnet.org/s6";
-    rev = "refs/tags/v${version}";
-    sha256 = "1g8gr3znxj8lyqpwrmgzh47yb64zldrvvvgpp1m4pb37k5k11bj9";
-  };
-
-  dontDisableStatic = true;
-
-  enableParallelBuilding = true;
-
-  configureFlags = [
-    "--with-sysdeps=${skalibs}/lib/skalibs/sysdeps"
-    "--with-include=${skalibs}/include"
-    "--with-include=${execline}/include"
-    "--with-lib=${skalibs}/lib"
-    "--with-lib=${execline}/lib"
-    "--with-dynlib=${skalibs}/lib"
-    "--with-dynlib=${execline}/lib"
-  ] ++ [ (if stdenv.isDarwin then "--disable-shared" else "--enable-shared") ];
-
-  preBuild = ''
-    substituteInPlace "src/daemontools-extras/s6-log.c" \
-      --replace '"execlineb"' '"${execline}/bin/execlineb"'
-  '';
-
-  meta = {
-    homepage = http://www.skarnet.org/software/s6/;
-    description = "skarnet.org's small & secure supervision software suite";
-    platforms = stdenv.lib.platforms.all;
-    license = stdenv.lib.licenses.isc;
-    maintainers = with stdenv.lib.maintainers; [ pmahoney ];
-  };
-
-}
diff --git a/pkgs/servers/sabnzbd/builder.sh b/pkgs/servers/sabnzbd/builder.sh
deleted file mode 100644
index 3a5c8adb421e..000000000000
--- a/pkgs/servers/sabnzbd/builder.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-source $stdenv/setup
-
-tar xvfz $src
-mv SABnzbd-* $out
-
-# Create a start script and let wrapProgram with toPythonPath wrap it so that python is started with cheetahTemplate in its importpath (classpath)
-mkdir $out/bin
-echo "$python/bin/python $out/SABnzbd.py \$*" > $out/bin/sabnzbd
-chmod +x $out/bin/sabnzbd
-
-for i in $(cd $out/bin && ls); do
-  wrapProgram $out/bin/$i --prefix PYTHONPATH : "$(toPythonPath $python):$(toPythonPath $out):$(toPythonPath $cheetahTemplate):$(toPythonPath $sqlite3)" \
-                          --prefix PATH : "$par2cmdline/bin:$unzip/bin:$unrar/bin"
-done
-
-echo $out
diff --git a/pkgs/servers/sabnzbd/default.nix b/pkgs/servers/sabnzbd/default.nix
index 09c0de9c74f1..1b5a8c24424a 100644
--- a/pkgs/servers/sabnzbd/default.nix
+++ b/pkgs/servers/sabnzbd/default.nix
@@ -1,20 +1,36 @@
-{stdenv, fetchurl, python, pythonPackages, cheetahTemplate, makeWrapper, par2cmdline, unzip, unrar}:
+{stdenv, fetchFromGitHub, python2, par2cmdline, unzip, unrar, p7zip, makeWrapper}:
 
-stdenv.mkDerivation rec {
-  name = "sabnzbd-0.7.17";
-  
-  src = fetchurl {
-    url = mirror://sourceforge/sabnzbdplus/SABnzbd-0.7.17-src.tar.gz;
-    sha256 = "02gbh3q3qnbwy4xn1hw4i4fyw4j5nkrqy4ak46mxwqgip9ym20d5";
+let
+  pythonEnv = python2.withPackages(ps: with ps; [ cryptography cheetah yenc ]);
+  path = stdenv.lib.makeBinPath [ par2cmdline unrar unzip p7zip ];
+in stdenv.mkDerivation rec {
+  version = "2.3.3";
+  pname = "sabnzbd";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = version;
+    sha256 = "0za4xjc4x44f7i30r86bbza3zppid333ifwzp5h526w3zak1lal8";
   };
 
-  buildInputs = [makeWrapper python sqlite3 cheetahTemplate];
-  inherit stdenv python cheetahTemplate par2cmdline unzip unrar; 
-  inherit (pythonPackages) sqlite3;
+  buildInputs = [ pythonEnv makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R * $out/
+    mkdir $out/bin
+    echo "${pythonEnv}/bin/python $out/SABnzbd.py \$*" > $out/bin/sabnzbd
+    chmod +x $out/bin/sabnzbd
+    wrapProgram $out/bin/sabnzbd --set PATH ${path}
+  '';
 
-  builder = ./builder.sh;
-  
-  meta = {
+  meta = with stdenv.lib; {
     description = "Usenet NZB downloader, par2 repairer and auto extracting server";
+    homepage = http://sabnzbd.org;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ fridh ];
   };
 }
diff --git a/pkgs/servers/samba/3.x.nix b/pkgs/servers/samba/3.x.nix
index e2818a1f6484..91b1c8f95c1c 100644
--- a/pkgs/servers/samba/3.x.nix
+++ b/pkgs/servers/samba/3.x.nix
@@ -25,6 +25,12 @@ stdenv.mkDerivation rec {
     sha256 = "0l9pz2m67vf398q3c2dwn8jwdxsjb20igncf4byhv6yq5dzqlb4g";
   };
 
+  patches = [(fetchurl {
+    url = "https://download.samba.org/pub/samba/patches/security/"
+        + "samba-3.6.25-security-2015-12-16.patch";
+    sha256 = "00dcjcn577825mfdwdp76jfy5kcrqw3s4d5c41gqdq5gfcdbmqdb";
+  })];
+
   buildInputs = [ readline pam openldap popt iniparser libunwind fam acl cups ]
     ++ stdenv.lib.optional useKerberos kerberos;
 
@@ -85,5 +91,8 @@ stdenv.mkDerivation rec {
     homepage = http://www.samba.org/;
     description = "The standard Windows interoperability suite of programs for Linux and Unix";
     platforms = stdenv.lib.platforms.linux;
+    knownVulnerabilities = [
+      "Numerous CVEs and no patches from upstream for 3.x since 2014."
+    ];
   };
 }
diff --git a/pkgs/servers/samba/4.x-fix-ctdb-deps.patch b/pkgs/servers/samba/4.x-fix-ctdb-deps.patch
deleted file mode 100644
index 338863484124..000000000000
--- a/pkgs/servers/samba/4.x-fix-ctdb-deps.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/ctdb/wscript b/ctdb/wscript
-index 3e2a992..3fe15cc 100755
---- a/ctdb/wscript
-+++ b/ctdb/wscript
-@@ -568,7 +568,7 @@ def build(bld):
-                          source='ib/ibwrapper_test.c',
-                          includes='include include/internal',
-                          deps='''replace talloc ctdb-client ctdb-common
--                                 ctdb-system''' +
-+                                 ctdb-system ctdb-common-util''' +
-                               ib_deps,
-                          install_path='${CTDB_TEST_LIBDIR}')
- 
diff --git a/pkgs/servers/samba/4.x-no-persistent-install-dynconfig.patch b/pkgs/servers/samba/4.x-no-persistent-install-dynconfig.patch
new file mode 100644
index 000000000000..7e3652dbe7b7
--- /dev/null
+++ b/pkgs/servers/samba/4.x-no-persistent-install-dynconfig.patch
@@ -0,0 +1,15 @@
+diff -ru3 samba-4.4.6/dynconfig/wscript samba-4.4.6-new/dynconfig/wscript
+--- samba-4.4.6/dynconfig/wscript	2016-01-26 14:45:46.000000000 +0300
++++ samba-4.4.6-new/dynconfig/wscript	2016-10-15 22:21:18.159705132 +0300
+@@ -416,11 +416,3 @@
+                         public_headers=os_path_relpath(os.path.join(Options.launch_dir, version_header), bld.curdir),
+                         header_path='samba',
+                         cflags=cflags)
+-
+-    # install some extra empty directories
+-    bld.INSTALL_DIRS("", "${CONFIGDIR} ${PRIVATE_DIR} ${LOGFILEBASE}");
+-    bld.INSTALL_DIRS("", "${PRIVATE_DIR} ${PRIVILEGED_SOCKET_DIR}")
+-    bld.INSTALL_DIRS("", "${STATEDIR} ${CACHEDIR}");
+-
+-    # these might be on non persistent storage
+-    bld.INSTALL_DIRS("", "${LOCKDIR} ${PIDDIR} ${SOCKET_DIR}")
diff --git a/pkgs/servers/samba/4.x-no-persistent-install.patch b/pkgs/servers/samba/4.x-no-persistent-install.patch
index c3e013f7862b..1c360f6b2c77 100644
--- a/pkgs/servers/samba/4.x-no-persistent-install.patch
+++ b/pkgs/servers/samba/4.x-no-persistent-install.patch
@@ -1,26 +1,7 @@
-diff --git a/dynconfig/wscript b/dynconfig/wscript
-index aa4e66e..d53f433 100755
---- a/dynconfig/wscript
-+++ b/dynconfig/wscript
-@@ -379,9 +379,9 @@ def build(bld):
-                         cflags=cflags)
- 
-     # install some extra empty directories
--    bld.INSTALL_DIRS("", "${CONFIGDIR} ${PRIVATE_DIR} ${LOGFILEBASE}");
--    bld.INSTALL_DIRS("", "${PRIVATE_DIR} ${PRIVILEGED_SOCKET_DIR}")
--    bld.INSTALL_DIRS("", "${STATEDIR} ${CACHEDIR}");
-+    #bld.INSTALL_DIRS("", "${CONFIGDIR} ${PRIVATE_DIR} ${LOGFILEBASE}");
-+    #bld.INSTALL_DIRS("", "${PRIVATE_DIR} ${PRIVILEGED_SOCKET_DIR}")
-+    #bld.INSTALL_DIRS("", "${STATEDIR} ${CACHEDIR}");
- 
-     # these might be on non persistent storage
--    bld.INSTALL_DIRS("", "${LOCKDIR} ${PIDDIR} ${SOCKET_DIR}")
-+    #bld.INSTALL_DIRS("", "${LOCKDIR} ${PIDDIR} ${SOCKET_DIR}")
-diff --git a/ctdb/wscript b/ctdb/wscript
-index 3e2a992..1b93a4d 100755
---- a/ctdb/wscript
-+++ b/ctdb/wscript
-@@ -473,10 +473,10 @@ def build(bld):
+diff -ru3 samba-4.4.6/ctdb/wscript samba-4.4.6-new/ctdb/wscript
+--- samba-4.4.6/ctdb/wscript	2016-09-22 09:42:48.000000000 +0300
++++ samba-4.4.6-new/ctdb/wscript	2016-10-15 23:31:13.932088237 +0300
+@@ -581,7 +581,7 @@
      for t in etc_subdirs:
          files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
          for fmode in files:
@@ -28,12 +9,8 @@ index 3e2a992..1b93a4d 100755
 +            bld.INSTALL_FILES('${EXEC_PREFIX}${CTDB_ETCDIR}', 'config/%s' % fmode[0],
                                destname=fmode[0], chmod=fmode[1])
  
--    bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/functions',
-+    bld.INSTALL_FILES('${EXEC_PREFIX}${CTDB_ETCDIR}', 'config/functions',
-                       destname='functions')
- 
-     etc_scripts = [
-@@ -489,18 +489,18 @@ def build(bld):
+     bld.SAMBA_GENERATOR('ctdb-functions',
+@@ -601,23 +601,19 @@
      ]
  
      for t in etc_scripts:
@@ -41,8 +18,12 @@ index 3e2a992..1b93a4d 100755
 +        bld.INSTALL_FILES('${EXEC_PREFIX}${CTDB_ETCDIR}', 'config/%s' % t,
                            destname=t, chmod=0755)
  
--    bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
-+    bld.INSTALL_FILES('${EXEC_PREFIX}${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
+     bld.SAMBA_GENERATOR('ctdb-sudoers',
+                         source='config/ctdb.sudoers',
+                         target='ctdb.sudoers',
+                         rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+-    bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
++    bld.INSTALL_FILES('${EXEC_PREFIX}${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
                        destname='ctdb')
  
 -    bld.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
@@ -52,9 +33,7 @@ index 3e2a992..1b93a4d 100755
 -    bld.install_dir(bld.env.CTDB_LOGDIR)
 -    bld.install_dir(bld.env.CTDB_RUNDIR)
 -    bld.install_dir(bld.env.CTDB_VARDIR)
-+    #bld.install_dir(bld.env.CTDB_LOGDIR)
-+    #bld.install_dir(bld.env.CTDB_RUNDIR)
-+    #bld.install_dir(bld.env.CTDB_VARDIR)
- 
-     sed_expr = 's/@PACKAGE_VERSION@/%s/g' % VERSION
-     t = bld.SAMBA_GENERATOR('ctdb-pc',
+-
+     # Unit tests
+     ctdb_unit_tests = [
+         'db_hash_test',
diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix
index 2e8f8a67fd42..ee14ec6443bf 100644
--- a/pkgs/servers/samba/4.x.nix
+++ b/pkgs/servers/samba/4.x.nix
@@ -1,11 +1,11 @@
 { lib, stdenv, fetchurl, python, pkgconfig, perl, libxslt, docbook_xsl
-, docbook_xml_dtd_42, docbook_xml_dtd_45, readline, talloc, ntdb, tdb, tevent
-, ldb, popt, iniparser, libbsd, libarchive, libiconv, gettext
-, kerberos, zlib, openldap, cups, pam, avahi, acl, libaio, fam, libceph, glusterfs
+, fetchpatch
+, docbook_xml_dtd_42, docbook_xml_dtd_45, readline, talloc
+, popt, iniparser, libbsd, libarchive, libiconv, gettext
+, krb5Full, zlib, openldap, cups, pam, avahi, acl, libaio, fam, libceph, glusterfs
 , gnutls, libgcrypt, libgpgerror
 , ncurses, libunwind, libibverbs, librdmacm, systemd
 
-, enableKerberos ? false
 , enableInfiniband ? false
 , enableLDAP ? false
 , enablePrinting ? false
@@ -14,30 +14,39 @@
 , enableRegedit ? true
 , enableCephFS ? false
 , enableGlusterFS ? false
+, enableAcl ? (!stdenv.isDarwin)
+, enablePam ? (!stdenv.isDarwin)
 }:
 
 with lib;
 
 stdenv.mkDerivation rec {
-  name = "samba-4.3.0";
+  name = "samba-${version}";
+  version = "4.7.6";
 
   src = fetchurl {
     url = "mirror://samba/pub/samba/stable/${name}.tar.gz";
-    sha256 = "0qyvmjl8p8fnyhibwivhxxkm67nxxaj4lp35jni9l7gcknrbdnyq";
+    sha256 = "0vkxqp3wh7bpn1fd45lznmrpn2ma1fq75yq28vi08rggr07y7v8y";
   };
 
+  outputs = [ "out" "dev" "man" ];
+
   patches =
     [ ./4.x-no-persistent-install.patch
-      ./4.x-fix-ctdb-deps.patch
+      ./patch-source3__libads__kerberos_keytab.c.patch
+      ./4.x-no-persistent-install-dynconfig.patch
+      (fetchpatch {
+        url = "https://patch-diff.githubusercontent.com/raw/samba-team/samba/pull/107.patch";
+        sha256 = "0r6q34vjj0bdzmcbnrkad9rww58k4krbwicv4gs1g3dj49skpvd6";
+      })
     ];
 
   buildInputs =
     [ python pkgconfig perl libxslt docbook_xsl docbook_xml_dtd_42 /*
-      docbook_xml_dtd_45 */ readline talloc ntdb tdb tevent ldb popt iniparser
-      libbsd libarchive zlib acl fam libiconv gettext libunwind
+      docbook_xml_dtd_45 */ readline talloc popt iniparser
+      libbsd libarchive zlib fam libiconv gettext libunwind krb5Full
     ]
-    ++ optionals stdenv.isLinux [ libaio pam systemd ]
-    ++ optional enableKerberos kerberos
+    ++ optionals stdenv.isLinux [ libaio systemd ]
     ++ optionals (enableInfiniband && stdenv.isLinux) [ libibverbs librdmacm ]
     ++ optional enableLDAP openldap
     ++ optional (enablePrinting && stdenv.isLinux) cups
@@ -45,7 +54,9 @@ stdenv.mkDerivation rec {
     ++ optional enableDomainController gnutls
     ++ optional enableRegedit ncurses
     ++ optional (enableCephFS && stdenv.isLinux) libceph
-    ++ optional (enableGlusterFS && stdenv.isLinux) glusterfs;
+    ++ optional (enableGlusterFS && stdenv.isLinux) glusterfs
+    ++ optional enableAcl acl
+    ++ optional enablePam pam;
 
   postPatch = ''
     # Removes absolute paths in scripts
@@ -58,23 +69,23 @@ stdenv.mkDerivation rec {
   configureFlags =
     [ "--with-static-modules=NONE"
       "--with-shared-modules=ALL"
+      "--with-system-mitkrb5"
+      "--with-system-mitkdc" "${krb5Full}"
       "--enable-fhs"
       "--sysconfdir=/etc"
       "--localstatedir=/var"
-      "--bundled-libraries=${if enableKerberos && kerberos != null &&
-        kerberos.implementation == "heimdal" then "NONE" else "com_err"}"
-      "--private-libraries=NONE"
-      "--builtin-libraries=replace"
     ]
-    ++ optional (enableKerberos && kerberos != null &&
-      kerberos.implementation == "krb5") "--with-system-mitkrb5"
     ++ optional (!enableDomainController) "--without-ad-dc"
-    ++ optionals (!enableLDAP) [ "--without-ldap" "--without-ads" ];
-
-  enableParallelBuilding = true;
+    ++ optionals (!enableLDAP) [ "--without-ldap" "--without-ads" ]
+    ++ optional (!enableAcl) "--without-acl-support"
+    ++ optional (!enablePam) "--without-pam";
 
-  stripAllList = [ "bin" "sbin" ];
+  # To build in parallel.
+  buildPhase = "python buildtools/bin/waf build -j $NIX_BUILD_CORES";
 
+  # Some libraries don't have /lib/samba in RPATH but need it.
+  # Use find -type f -executable -exec echo {} \; -exec sh -c 'ldd {} | grep "not found"' \;
+  # Looks like a bug in installer scripts.
   postFixup = ''
     export SAMBA_LIBS="$(find $out -type f -name \*.so -exec dirname {} \; | sort | uniq)"
     read -r -d "" SCRIPT << EOF || true
@@ -85,7 +96,7 @@ stdenv.mkDerivation rec {
     patchelf --set-rpath "\$ALL_LIBS" "\$BIN" 2>/dev/null || exit $?;
     patchelf --shrink-rpath "\$BIN";
     EOF
-    find $out -type f -exec $SHELL -c "$SCRIPT" \;
+    find $out -type f -name \*.so -exec $SHELL -c "$SCRIPT" \;
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/servers/samba/master.nix b/pkgs/servers/samba/master.nix
new file mode 100644
index 000000000000..df1f9feb4de5
--- /dev/null
+++ b/pkgs/servers/samba/master.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchFromGitHub
+, samba4
+, nettle
+} :
+
+  (samba4.overrideAttrs(oldAttrs: rec {
+    name = "samba-unstable-${version}";
+    version = "2018-03-09";
+
+    src = fetchFromGitHub {
+      owner = "samba-team";
+      repo = "samba";
+      rev = "9e954bcbf43d67a18ee55f84cda0b09028f96b92";
+      sha256 = "07j1pwm4kax6pq21gq9gpmp7dhj5afdyvkhgyl3yz334mb41q11g";
+    };
+
+    # Remove unnecessary install flags, same as <4.8 patch
+    postPatch = oldAttrs.postPatch + ''
+      sed -i '423,433d' dynconfig/wscript
+    '';
+
+    patches = [ ./4.x-no-persistent-install.patch ];
+    buildInputs = [ nettle ] ++ oldAttrs.buildInputs;
+    meta.branch = "master";
+  })).override {
+    # samba4.8+ removed the ability to disable LDAP.
+    # Enable for base derivation here:
+    enableLDAP = true;
+  }
diff --git a/pkgs/servers/samba/patch-source3__libads__kerberos_keytab.c.patch b/pkgs/servers/samba/patch-source3__libads__kerberos_keytab.c.patch
new file mode 100644
index 000000000000..9f6577c65c14
--- /dev/null
+++ b/pkgs/servers/samba/patch-source3__libads__kerberos_keytab.c.patch
@@ -0,0 +1,20 @@
+--- old/source3/libads/kerberos_keytab.c	2017-12-23 14:23:53.247467000 +0100
++++ new/source3/libads/kerberos_keytab.c	2017-12-23 18:57:07.135340000 +0100
+@@ -32,8 +32,6 @@
+ 
+ #ifdef HAVE_KRB5
+ 
+-#ifdef HAVE_ADS
+-
+ /* This MAX_NAME_LEN is a constant defined in krb5.h */
+ #ifndef MAX_KEYTAB_NAME_LEN
+ #define MAX_KEYTAB_NAME_LEN 1100
+@@ -85,6 +83,8 @@
+ 	return ret;
+ }
+ 
++#ifdef HAVE_ADS
++
+ /**********************************************************************
+  Adds a single service principal, i.e. 'host' to the system keytab
+ ***********************************************************************/
diff --git a/pkgs/servers/search/elasticsearch/2.x.nix b/pkgs/servers/search/elasticsearch/2.x.nix
new file mode 100644
index 000000000000..28244d1b3dcd
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/2.x.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, makeWrapper, jre, utillinux }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  version = "2.4.4";
+  name = "elasticsearch-${version}";
+
+  src = fetchurl {
+    url = "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${version}/${name}.tar.gz";
+    sha256 = "1qjq04sfqb35pf2xpvr8j5p27chfxpjp8ymrp1h5bfk5rbk9444q";
+  };
+
+  patches = [ ./es-home-2.x.patch ./es-classpath-2.x.patch ];
+
+  buildInputs = [ makeWrapper jre utillinux ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R bin config lib modules $out
+
+    # don't want to have binary with name plugin
+    mv $out/bin/plugin $out/bin/elasticsearch-plugin
+    wrapProgram $out/bin/elasticsearch \
+      --prefix ES_CLASSPATH : "$out/lib/${name}.jar":"$out/lib/*" \
+      --prefix PATH : "${utillinux}/bin" \
+      --set JAVA_HOME "${jre}"
+    wrapProgram $out/bin/elasticsearch-plugin --set JAVA_HOME "${jre}"
+  '';
+
+  meta = {
+    description = "Open Source, Distributed, RESTful Search Engine";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = [
+      maintainers.offline
+      maintainers.markWot
+    ];
+  };
+}
diff --git a/pkgs/servers/search/elasticsearch/5.x.nix b/pkgs/servers/search/elasticsearch/5.x.nix
new file mode 100644
index 000000000000..c80bbbcfde91
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/5.x.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, elk5Version, makeWrapper, jre_headless, utillinux }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  version = elk5Version;
+  name = "elasticsearch-${version}";
+
+  src = fetchurl {
+    url = "https://artifacts.elastic.co/downloads/elasticsearch/${name}.tar.gz";
+    sha256 = "0sm99m4m4mmigj6ll22kyaw7zkp1s2i0mhzx15fzidnybdnlifb4";
+  };
+
+  patches = [ ./es-home-5.x.patch ./es-classpath-5.x.patch ];
+
+  buildInputs = [ makeWrapper jre_headless utillinux ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R bin config lib modules plugins $out
+
+    chmod -x $out/bin/*.*
+
+    wrapProgram $out/bin/elasticsearch \
+      --prefix ES_CLASSPATH : "$out/lib/*" \
+      --prefix PATH : "${utillinux}/bin" \
+      --set JAVA_HOME "${jre_headless}" \
+      --set ES_JVM_OPTIONS "$out/config/jvm.options"
+
+    wrapProgram $out/bin/elasticsearch-plugin --set JAVA_HOME "${jre_headless}"
+  '';
+
+  meta = {
+    description = "Open Source, Distributed, RESTful Search Engine";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = [
+      maintainers.apeschar
+    ];
+  };
+}
diff --git a/pkgs/servers/search/elasticsearch/6.x.nix b/pkgs/servers/search/elasticsearch/6.x.nix
new file mode 100644
index 000000000000..06caf191587c
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/6.x.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, elk6Version, makeWrapper, jre_headless, utillinux }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  version = elk6Version;
+  name = "elasticsearch-${version}";
+
+  src = fetchurl {
+    url = "https://artifacts.elastic.co/downloads/elasticsearch/${name}.tar.gz";
+    sha256 = "13hf00khq33yw6zv022vcrsf6vm43isx40x7ww8r1lqx3vmg3rli";
+  };
+
+  patches = [ ./es-home-6.x.patch ];
+
+  postPatch = ''
+    sed -i "s|ES_CLASSPATH=\"\$ES_HOME/lib/\*\"|ES_CLASSPATH=\"$out/lib/*\"|" ./bin/elasticsearch-env
+  '';
+
+  buildInputs = [ makeWrapper jre_headless utillinux ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R bin config lib modules plugins $out
+
+    chmod -x $out/bin/*.*
+
+    wrapProgram $out/bin/elasticsearch \
+      --prefix PATH : "${utillinux}/bin/" \
+      --set JAVA_HOME "${jre_headless}"
+
+    wrapProgram $out/bin/elasticsearch-plugin --set JAVA_HOME "${jre_headless}"
+  '';
+
+  meta = {
+    description = "Open Source, Distributed, RESTful Search Engine";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ apeschar basvandijk ];
+  };
+}
diff --git a/pkgs/servers/search/elasticsearch/default.nix b/pkgs/servers/search/elasticsearch/default.nix
index 859f1501bb3c..f4780603f502 100644
--- a/pkgs/servers/search/elasticsearch/default.nix
+++ b/pkgs/servers/search/elasticsearch/default.nix
@@ -1,19 +1,18 @@
-{ stdenv, fetchurl, makeWrapper, jre, utillinux, getopt }:
+{ stdenv, fetchurl, makeWrapper, jre, utillinux }:
 
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
-  name = "elasticsearch-1.5.2";
+  name = "elasticsearch-1.7.2";
 
   src = fetchurl {
     url = "https://download.elastic.co/elasticsearch/elasticsearch/${name}.tar.gz";
-    sha256 = "054s0k0y0g1x6wzbd6gmvrp5n89fqwqssbyhay0gmhvs6sbpibpg";
+    sha256 = "1lix4asvx1lbc227gzsrws3xqbcbqaal7v10w60kch0c4xg970bg";
   };
 
   patches = [ ./es-home.patch ];
 
-  buildInputs = [ makeWrapper jre ] ++
-    (if (!stdenv.isDarwin) then [utillinux] else [getopt]);
+  buildInputs = [ makeWrapper jre utillinux ];
 
   installPhase = ''
     mkdir -p $out
@@ -25,9 +24,7 @@ stdenv.mkDerivation rec {
     # set ES_CLASSPATH and JAVA_HOME
     wrapProgram $out/bin/elasticsearch \
       --prefix ES_CLASSPATH : "$out/lib/${name}.jar":"$out/lib/*":"$out/lib/sigar/*" \
-      ${if (!stdenv.isDarwin)
-        then ''--prefix PATH : "${utillinux}/bin/"''
-        else ''--prefix PATH : "${getopt}/bin"''} \
+      --prefix PATH : "${utillinux}/bin" \
       --set JAVA_HOME "${jre}"
     wrapProgram $out/bin/elasticsearch-plugin \
       --prefix ES_CLASSPATH : "$out/lib/${name}.jar":"$out/lib/*":"$out/lib/sigar/*" \
diff --git a/pkgs/servers/search/elasticsearch/es-classpath-2.x.patch b/pkgs/servers/search/elasticsearch/es-classpath-2.x.patch
new file mode 100644
index 000000000000..46a3f0be71b7
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/es-classpath-2.x.patch
@@ -0,0 +1,38 @@
+diff -rupN a/bin/elasticsearch b/bin/elasticsearch
+--- a/bin/elasticsearch	2017-02-08 18:32:28.000298543 -0500
++++ b/bin/elasticsearch	2017-02-08 19:10:45.692916675 -0500
+@@ -81,12 +81,7 @@ ES_HOME=`cd "$ES_HOME"; pwd`
+ # If an include wasn't specified in the environment, then search for one...
+ if [ "x$ES_INCLUDE" = "x" ]; then
+     # Locations (in order) to use when searching for an include file.
+-    for include in /usr/share/elasticsearch/elasticsearch.in.sh \
+-                   /usr/local/share/elasticsearch/elasticsearch.in.sh \
+-                   /opt/elasticsearch/elasticsearch.in.sh \
+-                   ~/.elasticsearch.in.sh \
+-                   "$ES_HOME/bin/elasticsearch.in.sh" \
+-                   "`dirname "$0"`"/elasticsearch.in.sh; do
++    for include in "`dirname "$0"`"/elasticsearch.in.sh; do
+         if [ -r "$include" ]; then
+             . "$include"
+             break
+diff -rupN a/bin/elasticsearch.in.sh b/bin/elasticsearch.in.sh
+--- a/bin/elasticsearch.in.sh	2017-02-08 18:32:28.000298543 -0500
++++ b/bin/elasticsearch.in.sh	2017-02-08 18:33:46.816634599 -0500
+@@ -1,17 +1,5 @@
+ #!/bin/sh
+ 
+-# check in case a user was using this mechanism
+-if [ "x$ES_CLASSPATH" != "x" ]; then
+-    cat >&2 << EOF
+-Error: Don't modify the classpath with ES_CLASSPATH. Best is to add
+-additional elements via the plugin mechanism, or if code must really be
+-added to the main classpath, add jars to lib/ (unsupported).
+-EOF
+-    exit 1
+-fi
+-
+-ES_CLASSPATH="$ES_HOME/lib/elasticsearch-2.4.4.jar:$ES_HOME/lib/*"
+-
+ if [ "x$ES_MIN_MEM" = "x" ]; then
+     ES_MIN_MEM=256m
+ fi
diff --git a/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch b/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch
new file mode 100644
index 000000000000..6898ffcf1d79
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/es-classpath-5.x.patch
@@ -0,0 +1,34 @@
+diff -rupN a/bin/elasticsearch b/bin/elasticsearch
+--- a/bin/elasticsearch	2017-05-17 10:53:49.444487071 +0200
++++ b/bin/elasticsearch	2017-05-17 10:55:52.755081523 +0200
+@@ -129,12 +129,7 @@ ES_JAVA_OPTS="$(parse_jvm_options "$ES_J
+ # If an include wasn't specified in the environment, then search for one...
+ if [ "x$ES_INCLUDE" = "x" ]; then
+     # Locations (in order) to use when searching for an include file.
+-    for include in /usr/share/elasticsearch/elasticsearch.in.sh \
+-                   /usr/local/share/elasticsearch/elasticsearch.in.sh \
+-                   /opt/elasticsearch/elasticsearch.in.sh \
+-                   ~/.elasticsearch.in.sh \
+-                   "$ES_HOME/bin/elasticsearch.in.sh" \
+-                   "`dirname "$0"`"/elasticsearch.in.sh; do
++    for include in "`dirname "$0"`"/elasticsearch.in.sh; do
+         if [ -r "$include" ]; then
+             . "$include"
+             break
+diff -rupN a/bin/elasticsearch.in.sh b/bin/elasticsearch.in.sh
+--- a/bin/elasticsearch.in.sh	2017-04-28 19:41:47.000000000 +0200
++++ b/bin/elasticsearch.in.sh	2017-05-17 10:56:49.303519788 +0200
+@@ -1,13 +1 @@
+ #!/bin/bash
+-
+-# check in case a user was using this mechanism
+-if [ "x$ES_CLASSPATH" != "x" ]; then
+-    cat >&2 << EOF
+-Error: Don't modify the classpath with ES_CLASSPATH. Best is to add
+-additional elements via the plugin mechanism, or if code must really be
+-added to the main classpath, add jars to lib/ (unsupported).
+-EOF
+-    exit 1
+-fi
+-
+-ES_CLASSPATH="$ES_HOME/lib/*"
diff --git a/pkgs/servers/search/elasticsearch/es-home-2.x.patch b/pkgs/servers/search/elasticsearch/es-home-2.x.patch
new file mode 100644
index 000000000000..0c80e8651145
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/es-home-2.x.patch
@@ -0,0 +1,31 @@
+diff -rupN a/bin/elasticsearch b/bin/elasticsearch
+--- a/bin/elasticsearch	2015-11-18 21:48:18.000000000 +0100
++++ b/bin/elasticsearch	2015-12-04 00:52:21.032475098 +0100
+@@ -72,7 +72,11 @@ while [ -h "$SCRIPT" ] ; do
+ done
+ 
+ # determine elasticsearch home
+-ES_HOME=`dirname "$SCRIPT"`/..
++
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # make ELASTICSEARCH_HOME absolute
+ ES_HOME=`cd "$ES_HOME"; pwd`
+diff -rupN a/bin/plugin b/bin/plugin
+--- a/bin/plugin	2015-11-18 21:48:18.000000000 +0100
++++ b/bin/plugin	2015-12-04 00:52:55.947453619 +0100
+@@ -17,7 +17,10 @@ while [ -h "$SCRIPT" ] ; do
+ done
+ 
+ # determine elasticsearch home
+-ES_HOME=`dirname "$SCRIPT"`/..
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # make ELASTICSEARCH_HOME absolute
+ ES_HOME=`cd "$ES_HOME"; pwd`
diff --git a/pkgs/servers/search/elasticsearch/es-home-5.x.patch b/pkgs/servers/search/elasticsearch/es-home-5.x.patch
new file mode 100644
index 000000000000..cee0137312f1
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/es-home-5.x.patch
@@ -0,0 +1,31 @@
+diff -rupN a/bin/elasticsearch b/bin/elasticsearch
+--- a/bin/elasticsearch	2017-05-17 10:53:42.214686741 +0200
++++ b/bin/elasticsearch	2017-05-17 10:53:49.444487071 +0200
+@@ -105,7 +105,11 @@ while [ -h "$SCRIPT" ] ; do
+ done
+ 
+ # determine elasticsearch home
+-ES_HOME=`dirname "$SCRIPT"`/..
++
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # make ELASTICSEARCH_HOME absolute
+ ES_HOME=`cd "$ES_HOME"; pwd`
+diff -rupN a/bin/elasticsearch-plugin b/bin/elasticsearch-plugin
+--- a/bin/elasticsearch-plugin	2017-05-17 10:53:42.214686741 +0200
++++ b/bin/elasticsearch-plugin	2017-05-17 10:53:49.445487044 +0200
+@@ -16,7 +16,10 @@ while [ -h "$SCRIPT" ] ; do
+ done
+ 
+ # determine elasticsearch home
+-ES_HOME=`dirname "$SCRIPT"`/..
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # make ELASTICSEARCH_HOME absolute
+ ES_HOME=`cd "$ES_HOME"; pwd`
diff --git a/pkgs/servers/search/elasticsearch/es-home-6.x.patch b/pkgs/servers/search/elasticsearch/es-home-6.x.patch
new file mode 100644
index 000000000000..aba8d396a69c
--- /dev/null
+++ b/pkgs/servers/search/elasticsearch/es-home-6.x.patch
@@ -0,0 +1,26 @@
+diff -Naur a/bin/elasticsearch-env b/bin/elasticsearch-env
+--- a/bin/elasticsearch-env	2017-12-12 13:31:51.000000000 +0100
++++ b/bin/elasticsearch-env	2017-12-18 19:51:12.282809695 +0100
+@@ -19,18 +19,10 @@
+   fi
+ done
+ 
+-# determine Elasticsearch home; to do this, we strip from the path until we find
+-# bin, and then strip bin (there is an assumption here that there is no nested
+-# directory under bin also named bin)
+-ES_HOME=`dirname "$SCRIPT"`
+-
+-# now make ES_HOME absolute
+-ES_HOME=`cd "$ES_HOME"; pwd`
+-
+-while [ "`basename "$ES_HOME"`" != "bin" ]; do
+-  ES_HOME=`dirname "$ES_HOME"`
+-done
+-ES_HOME=`dirname "$ES_HOME"`
++if [ -z "$ES_HOME" ]; then
++    echo "You must set the ES_HOME var" >&2
++    exit 1
++fi
+ 
+ # now set the classpath
+ ES_CLASSPATH="$ES_HOME/lib/*"
diff --git a/pkgs/servers/search/elasticsearch/es-home.patch b/pkgs/servers/search/elasticsearch/es-home.patch
index 2f7a7fe79198..2f2018fd69fa 100644
--- a/pkgs/servers/search/elasticsearch/es-home.patch
+++ b/pkgs/servers/search/elasticsearch/es-home.patch
@@ -28,9 +28,10 @@ diff -rupN a/bin/plugin b/bin/plugin
  
  # make ELASTICSEARCH_HOME absolute
  ES_HOME=`cd "$ES_HOME"; pwd`
-@@ -45,4 +48,4 @@ while [ $# -gt 0 ]; do
-   shift
- done
- 
--exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args
-+exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_CLASSPATH/lib/*" org.elasticsearch.plugins.PluginManager $args
+@@ -105,4 +105,4 @@
+
+ export HOSTNAME=`hostname -s`
+
+-eval "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home=\""$ES_HOME"\" $properties -cp \""$ES_HOME/lib/*"\" org.elasticsearch.plugins.PluginManager $args
+\ No newline at end of file
++eval "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_CLASSPATH/lib/*" org.elasticsearch.plugins.PluginManager $args
diff --git a/pkgs/servers/search/elasticsearch/plugins.nix b/pkgs/servers/search/elasticsearch/plugins.nix
index 32b065364a6a..ade2ea944534 100644
--- a/pkgs/servers/search/elasticsearch/plugins.nix
+++ b/pkgs/servers/search/elasticsearch/plugins.nix
@@ -30,13 +30,13 @@ in {
       sha256 = "1p75l3vcnb90ar4j3dci2xf8dqnqyy31kc1r075fa2xqlsxgigcp";
     };
     meta = {
-      homepage = "https://github.com/jprante/elasticsearch-river-jdbc";
+      homepage = https://github.com/jprante/elasticsearch-river-jdbc;
       description = "Plugin to fetch data from JDBC sources for indexing into Elasticsearch";
       license = licenses.asl20;
     };
   };
 
-  elasticsearch_analisys_lemmagen = esPlugin rec {
+  elasticsearch_analysis_lemmagen = esPlugin rec {
     name = "elasticsearch-analysis-lemmagen-${version}";
     pluginName = "elasticsearch-analysis-lemmagen";
     version = "0.1";
@@ -45,7 +45,7 @@ in {
       sha256 = "bf7bf5ce3ccdd3afecd0e18cd6fce1ef56f824e41f4ef50553ae598caa5c366d";
     };
     meta = {
-      homepage = "https://github.com/vhyza/elasticsearch-analysis-lemmagen";
+      homepage = https://github.com/vhyza/elasticsearch-analysis-lemmagen;
       description = "LemmaGen Analysis plugin provides jLemmaGen lemmatizer as Elasticsearch token filter";
       license = licenses.asl20;
     };
@@ -83,7 +83,7 @@ in {
     };
 
     meta = {
-      homepage = "https://github.com/elasticsearch/elasticsearch-river-twitter";
+      homepage = https://github.com/elasticsearch/elasticsearch-river-twitter;
       description = "Twitter River Plugin for ElasticSearch";
       license = licenses.asl20;
       maintainers = [ maintainers.edwtjo ];
@@ -94,10 +94,10 @@ in {
   elasticsearch_kopf = esPlugin rec {
     name = "elasticsearch-kopf-${version}";
     pluginName = "elasticsearch-kopf";
-    version = "1.5.7";
+    version = "2.1.1";
     src = fetchurl {
       url = "https://github.com/lmenezes/elasticsearch-kopf/archive/v${version}.zip";
-      sha256 = "0mq6jmjb4ldi03m431kzr7ly0bf7mdim7s5dx4wplb85gyhscns1";
+      sha256 = "1nwwd92g0jxhfpkxb1a9z5a62naa1y7hvlx400dm6mwwav3mrf4v";
     };
     meta = {
       homepage = https://github.com/lmenezes/elasticsearch-kopf;
diff --git a/pkgs/servers/search/groonga/default.nix b/pkgs/servers/search/groonga/default.nix
new file mode 100644
index 000000000000..a4b2418f58c9
--- /dev/null
+++ b/pkgs/servers/search/groonga/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, mecab, kytea, libedit, pkgconfig
+, suggestSupport ? false, zeromq, libevent, libmsgpack
+, lz4Support  ? false, lz4
+, zlibSupport ? false, zlib
+}:
+
+stdenv.mkDerivation rec {
+
+  name    = "groonga-${version}";
+  version = "8.0.2";
+
+  src = fetchurl {
+    url    = "http://packages.groonga.org/source/groonga/${name}.tar.gz";
+    sha256 = "0bsf4dbgbddij49xg6d6kl9kb1m5ywdyc1w1xz2giisqk1hdwsz4";
+  };
+
+  buildInputs = with stdenv.lib;
+     [ pkgconfig mecab kytea libedit ]
+    ++ optional lz4Support lz4
+    ++ optional zlibSupport zlib
+    ++ optionals suggestSupport [ zeromq libevent libmsgpack ];
+
+  configureFlags = with stdenv.lib;
+       optional zlibSupport "--with-zlib"
+    ++ optional lz4Support  "--with-lz4";
+
+  doInstallCheck    = true;
+  installCheckPhase = "$out/bin/groonga --version";
+
+  meta = with stdenv.lib; {
+    homepage    = http://groonga.org/;
+    description = "An open-source fulltext search engine and column store";
+    license     = licenses.lgpl21;
+    maintainers = [ maintainers.ericsagnes ];
+    platforms   = platforms.linux;
+    longDescription = ''
+      Groonga is an open-source fulltext search engine and column store. 
+      It lets you write high-performance applications that requires fulltext search.
+    '';
+  };
+
+}
diff --git a/pkgs/servers/search/solr/default.nix b/pkgs/servers/search/solr/default.nix
index 76a83d77c5e5..0326784b2ac8 100644
--- a/pkgs/servers/search/solr/default.nix
+++ b/pkgs/servers/search/solr/default.nix
@@ -18,11 +18,11 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with stdenv.lib; {
-    homepage = "https://lucene.apache.org/solr/";
+    homepage = https://lucene.apache.org/solr/;
     description = "Open source enterprise search platform from the Apache Lucene project";
     license = licenses.asl20;
     platforms = platforms.all;
-    maintainers = [ maintainers.rickynils maintainers.iElectric ];
+    maintainers = [ maintainers.rickynils maintainers.domenkozar ];
   };
 
 }
diff --git a/pkgs/servers/search/sphinxsearch/default.nix b/pkgs/servers/search/sphinxsearch/default.nix
index 17095750dbfd..7ba23f61fedb 100644
--- a/pkgs/servers/search/sphinxsearch/default.nix
+++ b/pkgs/servers/search/sphinxsearch/default.nix
@@ -1,8 +1,8 @@
 { stdenv, fetchurl, pkgconfig,
-  version ? "2.2.8",
+  version ? "2.2.11",
   mainSrc ? fetchurl {
     url = "http://sphinxsearch.com/files/sphinx-${version}-release.tar.gz";
-    sha256 = "1q6jdw5g81k7ciw9fhwklb5ifgb8zna39795m0x0lbvwjbk3ampv";
+    sha256 = "1aa1mh32y019j8s3sjzn4vwi0xn83dwgl685jnbgh51k16gh6qk6";
   }
 }:
 
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
     "--enable-id64"
   ];
 
-  buildInputs = [
+  nativeBuildInputs = [
     pkgconfig
   ];
 
diff --git a/pkgs/servers/serf/default.nix b/pkgs/servers/serf/default.nix
new file mode 100644
index 000000000000..4c5f71cb37d6
--- /dev/null
+++ b/pkgs/servers/serf/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "serf-${version}";
+  version = "0.8.1";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/hashicorp/serf";
+
+  src = fetchFromGitHub {
+    owner = "hashicorp";
+    repo = "serf";
+    inherit rev;
+    sha256 = "1arakjvhyasrk52vhxas2ghlrby3i3wj59r7sjrkbpln2cdbqnlx";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Tool for service orchestration and management";
+    homepage = https://www.serf.io/;
+    platforms = platforms.linux ++ platforms.darwin;
+    license = licenses.mpl20;
+    maintainers = with maintainers; [ pradeepchhetri ];
+  };
+}
diff --git a/pkgs/servers/serviio/default.nix b/pkgs/servers/serviio/default.nix
new file mode 100644
index 000000000000..876cc01592e9
--- /dev/null
+++ b/pkgs/servers/serviio/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "serviio-${version}";
+  version = "1.9";
+
+  src = fetchurl {
+    url = "http://download.serviio.org/releases/${name}-linux.tar.gz";
+    sha256 = "0vi9dwpdrk087gpi0xib0hwpvdmaf9g99nfdfx2r3wmmdzw7wysl";
+  };
+
+  phases = ["unpackPhase" "installPhase"];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R config legal lib library plugins LICENCE.txt NOTICE.txt README.txt RELEASE_NOTES.txt $out
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://serviio.org;
+    description = "UPnP Media Streaming Server";
+    longDescription = ''
+      Serviio is a free media server. It allows you to stream your media files (music, video or images)
+      to any DLNA-certified renderer device (e.g. a TV set, Bluray player, games console) on your home network.
+    '';
+    license = licenses.unfree;
+    maintainers = [ maintainers.thpham ];
+    platforms = platforms.linux;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/servers/shairplay/default.nix b/pkgs/servers/shairplay/default.nix
new file mode 100644
index 000000000000..f9b17b947cf5
--- /dev/null
+++ b/pkgs/servers/shairplay/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig
+, avahi, libao }:
+
+stdenv.mkDerivation rec {
+  name = "shairplay-${version}";
+  version = "2016-01-01";
+
+  src = fetchFromGitHub {
+    owner  = "juhovh";
+    repo   = "shairplay";
+    rev    = "ce80e005908f41d0e6fde1c4a21e9cb8ee54007b";
+    sha256 = "10b4bmqgf4rf1wszvj066mc42p90968vqrmyqyrdal4k6f8by1r6";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  buildInputs = [ avahi libao ];
+
+  enableParallelBuilding = true;
+
+  # the build will fail without complaining about a reference to /tmp
+  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
+    patchelf \
+      --set-rpath "${stdenv.lib.makeLibraryPath buildInputs}:$out/lib" \
+      $out/bin/shairplay
+  '';
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Apple airplay and raop protocol server";
+    license     = licenses.mit;
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/pkgs/servers/shairport-sync/default.nix b/pkgs/servers/shairport-sync/default.nix
index 2ee5683a2ca2..f7a9fc658352 100644
--- a/pkgs/servers/shairport-sync/default.nix
+++ b/pkgs/servers/shairport-sync/default.nix
@@ -2,23 +2,23 @@
 , libdaemon, popt, pkgconfig, libconfig, libpulseaudio, soxr }:
 
 stdenv.mkDerivation rec {
-  version = "2.3.6.5";
+  version = "3.1.7";
   name = "shairport-sync-${version}";
 
   src = fetchFromGitHub {
-    sha256 = "1337y62pnch27s2gr47miip3na1am24xprlc5a27lbr764nr85s3";
+    sha256 = "1ip8vlyly190fhcd55am5xvqisvch8mnw50xwbm663dapdb1f8ys";
     rev = version;
     repo = "shairport-sync";
     owner = "mikebrady";
   };
 
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
   buildInputs = [
-    autoreconfHook
     openssl
     avahi
     alsaLib
     libdaemon
-    pkgconfig
     popt
     libconfig
     libpulseaudio
@@ -37,6 +37,7 @@ stdenv.mkDerivation rec {
     inherit (src.meta) homepage;
     description = "Airtunes server and emulator with multi-room capabilities";
     license = licenses.mit;
+    maintainers =  with maintainers; [ lnl7 ];
     platforms = platforms.unix;
   };
 }
diff --git a/pkgs/servers/shellinabox/default.nix b/pkgs/servers/shellinabox/default.nix
index 37a546770a0d..70bf5c32b3d4 100644
--- a/pkgs/servers/shellinabox/default.nix
+++ b/pkgs/servers/shellinabox/default.nix
@@ -1,19 +1,20 @@
-{ stdenv, fetchFromGitHub, autoconf, automake, libtool, pam, openssl, openssh, shadow, makeWrapper }:
+{ stdenv, fetchFromGitHub, autoreconfHook, pam, openssl, openssh, shadow, makeWrapper }:
 
 stdenv.mkDerivation rec {
-  version = "2.16";
+  version = "2.20";
   name = "shellinabox-${version}";
 
   src = fetchFromGitHub {
     owner = "shellinabox";
     repo = "shellinabox";
-    rev = "8ac3a4efcf20f7b66d3f1eb1d4f3054aef6e196b";
-    sha256 = "1pp6nk0279d2q7l1cvx8jc73skfjv0s42wxb2m00x0bg9i1fvs5j";
+    rev = "v${version}";
+    sha256 = "1hmfayh21cks2lyj572944ll0mmgsxbnj981b3hq3nhdg8ywzjfr";
   };
 
   patches = [ ./shellinabox-minus.patch ];
 
-  buildInputs = [ autoconf automake libtool pam openssl openssh makeWrapper];
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ pam openssl openssh makeWrapper ];
 
   # Disable GSSAPIAuthentication errors. Also, paths in certain source files are
   # hardcoded. Replace the hardcoded paths with correct paths.
@@ -22,19 +23,18 @@ stdenv.mkDerivation rec {
     substituteInPlace ./shellinabox/launcher.c --replace "/usr/games" "${openssh}/bin"
     substituteInPlace ./shellinabox/service.c --replace "/bin/login" "${shadow}/bin/login"
     substituteInPlace ./shellinabox/launcher.c --replace "/bin/login" "${shadow}/bin/login"
-    substituteInPlace ./libhttp/ssl.c --replace "/usr/bin" "${openssl}/bin"
-    autoreconf -vfi
+    substituteInPlace ./libhttp/ssl.c --replace "/usr/bin" "${openssl.bin}/bin"
   '';
 
   postInstall = ''
     wrapProgram $out/bin/shellinaboxd \
-      --prefix LD_LIBRARY_PATH : ${openssl}/lib
+      --prefix LD_LIBRARY_PATH : ${openssl.out}/lib
     mkdir -p $out/lib
     cp shellinabox/* $out/lib
   '';
 
   meta = with stdenv.lib; {
-    homepage = https://code.google.com/p/shellinabox;
+    homepage = https://github.com/shellinabox/shellinabox;
     description = "Web based AJAX terminal emulator";
     license = licenses.gpl2;
     maintainers = with maintainers; [ tomberek lihop ];
diff --git a/pkgs/servers/shishi/default.nix b/pkgs/servers/shishi/default.nix
index a97e6847a450..1540a6f1fd18 100644
--- a/pkgs/servers/shishi/default.nix
+++ b/pkgs/servers/shishi/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl
+{ stdenv, fetchurl, pkgconfig
 , libgcrypt, libgpgerror, libtasn1
 
 # Optional Dependencies
@@ -6,14 +6,15 @@
 }:
 
 let
-  mkFlag = trueStr: falseStr: cond: name: val:
-    if cond == null then null else
-      "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
+  mkFlag = trueStr: falseStr: cond: name: val: "--"
+    + (if cond then trueStr else falseStr)
+    + name
+    + stdenv.lib.optionalString (val != null && cond != false) "=${val}";
   mkEnable = mkFlag "enable-" "disable-";
   mkWith = mkFlag "with-" "without-";
   mkOther = mkFlag "" "" true;
 
-  shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
+  shouldUsePkg = pkg: if pkg != null && pkg.meta.available then pkg else null;
 
   optPam = shouldUsePkg pam;
   optLibidn = shouldUsePkg libidn;
@@ -29,8 +30,9 @@ stdenv.mkDerivation rec {
   };
 
   # Fixes support for gcrypt 1.6+
-  patches = [ ./gcrypt-fix.patch ];
+  patches = [ ./gcrypt-fix.patch ./freebsd-unistd.patch ];
 
+  nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libgcrypt libgpgerror libtasn1 optPam optLibidn optGnutls ];
 
   configureFlags = [
@@ -60,13 +62,13 @@ stdenv.mkDerivation rec {
   postInstall = ''
     sed -i $out/lib/libshi{sa,shi}.la \
   '' + optionalString (optLibidn != null) ''
-      -e 's,\(-lidn\),-L${optLibidn}/lib \1,' \
+      -e 's,\(-lidn\),-L${optLibidn.out}/lib \1,' \
   '' + optionalString (optGnutls != null) ''
-      -e 's,\(-lgnutls\),-L${optGnutls}/lib \1,' \
+      -e 's,\(-lgnutls\),-L${optGnutls.out}/lib \1,' \
   '' + ''
-      -e 's,\(-lgcrypt\),-L${libgcrypt}/lib \1,' \
-      -e 's,\(-lgpg-error\),-L${libgpgerror}/lib \1,' \
-      -e 's,\(-ltasn1\),-L${libtasn1}/lib \1,'
+      -e 's,\(-lgcrypt\),-L${libgcrypt.out}/lib \1,' \
+      -e 's,\(-lgpg-error\),-L${libgpgerror.out}/lib \1,' \
+      -e 's,\(-ltasn1\),-L${libtasn1.out}/lib \1,'
   '';
 
   meta = {
@@ -74,6 +76,6 @@ stdenv.mkDerivation rec {
     description = "An implementation of the Kerberos 5 network security system";
     license     = licenses.gpl3Plus;
     maintainers = with maintainers; [ bjg lovek323 wkennington ];
-    platforms   = platforms.all;
+    platforms   = platforms.linux;
   };
 }
diff --git a/pkgs/servers/shishi/freebsd-unistd.patch b/pkgs/servers/shishi/freebsd-unistd.patch
new file mode 100644
index 000000000000..9399e20205b9
--- /dev/null
+++ b/pkgs/servers/shishi/freebsd-unistd.patch
@@ -0,0 +1,12 @@
+diff --git a/gl/unistd.in.h b/gl/unistd.in.h
+index 2ea9af4..ed58960 100644
+--- a/gl/unistd.in.h
++++ b/gl/unistd.in.h
+@@ -116,6 +116,7 @@
+ # include <getopt.h>
+ #endif
+ 
++#include "config.h"
+ _GL_INLINE_HEADER_BEGIN
+ #ifndef _GL_UNISTD_INLINE
+ # define _GL_UNISTD_INLINE _GL_INLINE
diff --git a/pkgs/servers/simplehttp2server/default.nix b/pkgs/servers/simplehttp2server/default.nix
new file mode 100644
index 000000000000..083a224d1558
--- /dev/null
+++ b/pkgs/servers/simplehttp2server/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "simplehttp2server-${version}";
+  version = "3.1.3";
+
+  goPackagePath = "github.com/GoogleChromeLabs/simplehttp2server";
+
+  src = fetchFromGitHub {
+     owner = "GoogleChromeLabs";
+     repo = "simplehttp2server";
+     rev = version;
+     sha256 = "113mcfvy1m91wask5039mhr0187nlw325ac32785yl4bb4igi8aw";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+     homepage = https://github.com/GoogleChromeLabs/simplehttp2server;
+     description = "HTTP/2 server for development purposes";
+     license = licenses.asl20;
+     maintainers = with maintainers; [ yrashk ];
+  };
+
+}
diff --git a/pkgs/servers/simplehttp2server/deps.nix b/pkgs/servers/simplehttp2server/deps.nix
new file mode 100644
index 000000000000..e6a26bf2506c
--- /dev/null
+++ b/pkgs/servers/simplehttp2server/deps.nix
@@ -0,0 +1,12 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/NYTimes/gziphandler";
+    fetch = {
+      type = "git";
+      url = "https://github.com/NYTimes/gziphandler";
+      rev = "289a3b81f5aedc99f8d6eb0f67827c142f1310d8";
+      sha256 = "1r9ly9wdqjcc4nwv71mfldf1f5cjm4r34vvkdm5wabmdqqqwkbyx";
+    };
+  }
+]
diff --git a/pkgs/servers/sip/freeswitch/default.nix b/pkgs/servers/sip/freeswitch/default.nix
index efa70875549f..a952dbada66f 100644
--- a/pkgs/servers/sip/freeswitch/default.nix
+++ b/pkgs/servers/sip/freeswitch/default.nix
@@ -1,22 +1,34 @@
-{ fetchurl, stdenv, ncurses, curl, pkgconfig, gnutls, readline, openssl, perl, libjpeg
-, libzrtpcpp, gcc48 }:
+{ fetchurl, stdenv, ncurses, curl, pkgconfig, gnutls, readline
+, openssl, perl, sqlite, libjpeg, speex, pcre
+, ldns, libedit, yasm, which, lua, libopus, libsndfile }:
 
 stdenv.mkDerivation rec {
-  name = "freeswitch-1.2.3";
+  name = "freeswitch-1.6.20";
 
   src = fetchurl {
-    url = http://files.freeswitch.org/freeswitch-1.2.3.tar.bz2;
-    sha256 = "0kfvn5f75c6r6yp18almjz9p6llvpm66gpbxcjswrg3ddgbkzg0k";
+    url = "http://files.freeswitch.org/freeswitch-releases/${name}.tar.bz2";
+    sha256 = "0hqz68abs5x5vzf1mndcvdi35nrhmnklzdrnrk8dyvzvz67hp2ah";
   };
+  postPatch = ''
+    patchShebangs     libs/libvpx/build/make/rtcd.pl
+    substituteInPlace libs/libvpx/build/make/configure.sh \
+      --replace AS=\''${AS} AS=yasm
+  '';
 
-  buildInputs = [ ncurses curl pkgconfig gnutls readline openssl perl libjpeg
-    libzrtpcpp gcc48 ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    openssl ncurses curl gnutls readline perl libjpeg
+    sqlite pcre speex ldns libedit yasm which lua libopus
+    libsndfile
+  ];
 
-  NIX_CFLAGS_COMPILE = "-Wno-error=cpp";
+  NIX_CFLAGS_COMPILE = "-Wno-error";
+
+  hardeningDisable = [ "format" ];
 
   meta = {
     description = "Cross-Platform Scalable FREE Multi-Protocol Soft Switch";
-    homepage = http://freeswitch.org/;
+    homepage = https://freeswitch.org/;
     license = stdenv.lib.licenses.mpl11;
     maintainers = with stdenv.lib.maintainers; [ viric ];
     platforms = with stdenv.lib.platforms; linux;
diff --git a/pkgs/servers/sip/sipwitch/default.nix b/pkgs/servers/sip/sipwitch/default.nix
index 8eecfa1e276b..0ba5a3ee5adb 100644
--- a/pkgs/servers/sip/sipwitch/default.nix
+++ b/pkgs/servers/sip/sipwitch/default.nix
@@ -1,14 +1,15 @@
 { fetchurl, stdenv, pkgconfig, ucommon, libosip, libexosip, gnutls, zlib }:
 
 stdenv.mkDerivation rec {
-  name = "sipwitch-1.9.8";
+  name = "sipwitch-1.9.15";
 
   src = fetchurl {
     url = "mirror://gnu/sipwitch/${name}.tar.gz";
-    sha256 = "0117c5iid1vrwl7sl3pys2jlinpmx2vfp8wcdwk93m7cc6k9793b";
+    sha256 = "2a7aa86a653f6810b3cd9cce6c37b3f70e937e7d14b09fd5c2a70d70588a9482";
   };
 
-  buildInputs = [ pkgconfig ucommon libosip libexosip gnutls zlib ];
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ ucommon libosip libexosip gnutls zlib ];
 
   preConfigure = ''
     export configureFlags="--sysconfdir=$out/etc"
diff --git a/pkgs/servers/sks/default.nix b/pkgs/servers/sks/default.nix
new file mode 100644
index 000000000000..fe4029db1c14
--- /dev/null
+++ b/pkgs/servers/sks/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromBitbucket, ocaml, zlib, db, perl, camlp4 }:
+
+stdenv.mkDerivation rec {
+  name = "sks-${version}";
+  version = "1.1.6";
+
+  src = fetchFromBitbucket {
+    owner = "skskeyserver";
+    repo = "sks-keyserver";
+    rev = "${version}";
+    sha256 = "00q5ma5rvl10rkc6cdw8d69bddgrmvy0ckqj3hbisy65l4idj2zm";
+  };
+
+  buildInputs = [ ocaml zlib db perl camlp4 ];
+
+  makeFlags = [ "PREFIX=$(out)" "MANDIR=$(out)/share/man" ];
+  preConfigure = ''
+    cp Makefile.local.unused Makefile.local
+    sed -i \
+      -e "s:^LIBDB=.*$:LIBDB=-ldb:g" \
+      Makefile.local
+  '';
+
+  preBuild = "make dep";
+
+  doCheck = true;
+  checkPhase = "./sks unit_test";
+
+  meta = with stdenv.lib; {
+    description = "An easily deployable & decentralized OpenPGP keyserver";
+    longDescription = ''
+      SKS is an OpenPGP keyserver whose goal is to provide easy to deploy,
+      decentralized, and highly reliable synchronization. That means that a key
+      submitted to one SKS server will quickly be distributed to all key
+      servers, and even wildly out-of-date servers, or servers that experience
+      spotty connectivity, can fully synchronize with rest of the system.
+    '';
+    inherit (src.meta) homepage;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ primeos fpletz ];
+  };
+}
+
diff --git a/pkgs/servers/skydns/default.nix b/pkgs/servers/skydns/default.nix
new file mode 100644
index 000000000000..ccb174371e0c
--- /dev/null
+++ b/pkgs/servers/skydns/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, lib, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "skydns-${version}";
+  version = "2.5.3a";
+  rev = "${version}";
+  
+  goPackagePath = "github.com/skynetservices/skydns";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "skynetservices";
+    repo = "skydns";
+    sha256 = "0i1iaif79cwnwm7pc8nxfa261cgl4zhm3p2a5a3smhy1ibgccpq7";
+  };
+
+  goDeps = ./deps.nix;
+}
diff --git a/pkgs/servers/skydns/deps.nix b/pkgs/servers/skydns/deps.nix
new file mode 100644
index 000000000000..a4f4eb120458
--- /dev/null
+++ b/pkgs/servers/skydns/deps.nix
@@ -0,0 +1,128 @@
+[
+  {
+    goPackagePath = "github.com/golang/protobuf";
+    fetch = {
+      type = "git";
+      url = "https://github.com/golang/protobuf";
+      rev = "59b73b37c1e45995477aae817e4a653c89a858db";
+      sha256 = "1dx22jvhvj34ivpr7gw01fncg9yyx35mbpal4mpgnqka7ajmgjsa";
+    };
+  }
+  {
+    goPackagePath = "github.com/coreos/go-systemd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/go-systemd";
+      rev = "a606a1e936df81b70d85448221c7b1c6d8a74ef1";
+      sha256 = "0fhan564swp982dnzzspb6jzfdl453489c0qavh65g3shy5x8x28";
+    };
+  }
+  {
+    goPackagePath = "github.com/rcrowley/go-metrics";
+    fetch = {
+      type = "git";
+      url = "https://github.com/rcrowley/go-metrics";
+      rev = "1ce93efbc8f9c568886b2ef85ce305b2217b3de3";
+      sha256 = "06gg72krlmd0z3zdq6s716blrga95pyj8dc2f2psfbknbkyrkfqa";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_model";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_model";
+      rev = "fa8ad6fec33561be4280a8f0514318c79d7f6cb6";
+      sha256 = "11a7v1fjzhhwsl128znjcf5v7v6129xjgkdpym2lial4lac1dhm9";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/common";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/common";
+      rev = "40456948a47496dc22168e6af39297a2f8fbf38c";
+      sha256 = "15700w18pifng0l2isa6v25y91r5rb7yfgljqw2g2gqrvac6sr5l";
+    };
+  }
+  {
+    goPackagePath = "github.com/beorn7/perks";
+    fetch = {
+      type = "git";
+      url = "https://github.com/beorn7/perks";
+      rev = "b965b613227fddccbfffe13eae360ed3fa822f8d";
+      sha256 = "1p8zsj4r0g61q922khfxpwxhdma2dx4xad1m5qx43mfn28kxngqk";
+    };
+  }
+  {
+    goPackagePath = "github.com/coreos/go-etcd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/coreos/go-etcd";
+      rev = "9847b93751a5fbaf227b893d172cee0104ac6427";
+      sha256 = "1ihq01ayqzxvn6hca5j00vl189vi5lm78f0fy2wpk5mrm3xi01l4";
+    };
+  }
+  {
+    goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
+    fetch = {
+      type = "git";
+      url = "https://github.com/matttproud/golang_protobuf_extensions";
+      rev = "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a";
+      sha256 = "0ajg41h6402big484drvm72wvid1af2sffw0qkzbmpy04lq68ahj";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/client_golang";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/client_golang";
+      rev = "6dbab8106ed3ed77359ac85d9cf08e30290df864";
+      sha256 = "1i3g5h2ncdb8b67742kfpid7d0a1jas1pyicglbglwngfmzhpkna";
+    };
+  }
+  {
+    goPackagePath = "github.com/stathat/go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/stathat/go";
+      rev = "91dfa3a59c5b233fef9a346a1460f6e2bc889d93";
+      sha256 = "105ql5v8r4hqcsq0ag7asdxqg9n7rvf83y1q1dj2nfjyn4manv6r";
+    };
+  }
+  {
+    goPackagePath = "github.com/ugorji/go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/ugorji/go";
+      rev = "03e33114d4d60a1f37150325e15f51b0fa6fc4f6";
+      sha256 = "01kdzgx23cgb4k867m1pvsw14hhdr9jf2frqy6i4j4221055m57v";
+    };
+  }
+  {
+    goPackagePath = "github.com/miekg/dns";
+    fetch = {
+      type = "git";
+      url = "https://github.com/miekg/dns";
+      rev = "7e024ce8ce18b21b475ac6baf8fa3c42536bf2fa";
+      sha256 = "0hlwb52lnnj3c6papjk9i5w5cjdw6r7c891v4xksnfvk1f9cy9kl";
+    };
+  }
+  {
+    goPackagePath = "github.com/prometheus/procfs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/prometheus/procfs";
+      rev = "c91d8eefde16bd047416409eb56353ea84a186e4";
+      sha256 = "0pj3gzw9b58l72w0rkpn03ayssglmqfmyxghhfad6mh0b49dvj3r";
+    };
+  }
+  {
+    goPackagePath = "bitbucket.org/ww/goautoneg";
+    fetch = {
+      type = "hg";
+      url = "bitbucket.org/ww/goautoneg";
+      rev = "75cd24fc2f2c2a2088577d12123ddee5f54e0675";
+      sha256 = "19khhn5xhqv1yp7d6k987gh5w5rhrjnp4p0c6fyrd8z6lzz5h9qi";
+    };
+  }
+]
diff --git a/pkgs/servers/slimserver/default.nix b/pkgs/servers/slimserver/default.nix
new file mode 100644
index 000000000000..c9bf8393afc7
--- /dev/null
+++ b/pkgs/servers/slimserver/default.nix
@@ -0,0 +1,105 @@
+{ stdenv, buildPerlPackage, fetchurl, fetchpatch, makeWrapper
+, perl, perlPackages, flac, faad2, sox, lame, monkeysAudio, wavpack }:
+
+buildPerlPackage rec {
+  name = "slimserver-${version}";
+  version = "7.9.1";
+
+  src = fetchurl {
+    url = "https://github.com/Logitech/slimserver/archive/${version}.tar.gz";
+    sha256 = "0szp5zkmx2b5lncsijf97asjnl73fyijkbgbwkl1i7p8qnqrb4mp";
+  };
+
+  patches = [ (fetchpatch {
+    url = "https://github.com/Logitech/slimserver/pull/204.patch";
+    sha256 = "0n1c8nsbvqkmwj5ivkcxh1wkqqm1lwymmfz9i47ih6ifj06hkpxk";
+  } ) ];
+
+  buildInputs = [
+    makeWrapper
+    perl
+    perlPackages.AnyEvent
+    perlPackages.AudioScan
+    perlPackages.CarpClan
+    perlPackages.CGI
+    perlPackages.ClassXSAccessor
+    perlPackages.DataDump
+    perlPackages.DataURIEncode
+    perlPackages.DBDSQLite
+    perlPackages.DBI
+    perlPackages.DBIxClass
+    perlPackages.DigestSHA1
+    perlPackages.EV
+    perlPackages.ExporterLite
+    perlPackages.FileBOM
+    perlPackages.FileCopyRecursive
+    perlPackages.FileNext
+    perlPackages.FileReadBackwards
+    perlPackages.FileSlurp
+    perlPackages.FileWhich
+    perlPackages.HTMLParser
+    perlPackages.HTTPCookies
+    perlPackages.HTTPDaemon
+    perlPackages.HTTPMessage
+    perlPackages.ImageScale
+    perlPackages.IOSocketSSL
+    perlPackages.IOString
+    perlPackages.JSONXSVersionOneAndTwo
+    perlPackages.Log4Perl
+    perlPackages.LWPUserAgent
+    perlPackages.NetHTTP
+    perlPackages.ProcBackground
+    perlPackages.SubName
+    perlPackages.TemplateToolkit
+    perlPackages.TextUnidecode
+    perlPackages.TieCacheLRU
+    perlPackages.TieCacheLRUExpires
+    perlPackages.TieRegexpHash
+    perlPackages.TimeDate
+    perlPackages.URI
+    perlPackages.URIFind
+    perlPackages.UUIDTiny
+    perlPackages.XMLParser
+    perlPackages.XMLSimple
+    perlPackages.YAMLLibYAML
+  ];
+
+
+  prePatch = ''
+    mkdir CPAN_used
+    # slimserver doesn't work with current DBIx/SQL versions, use bundled copies
+    mv CPAN/DBIx CPAN/SQL CPAN_used
+    rm -rf CPAN
+    rm -rf Bin
+    touch Makefile.PL
+    '';
+
+  preConfigurePhase = "";
+
+  buildPhase = ''
+    mv lib tmp
+    mkdir -p lib/perl5/site_perl
+    mv CPAN_used/* lib/perl5/site_perl
+    cp -rf tmp/* lib/perl5/site_perl
+  '';
+
+  doCheck = false;
+
+  installPhase = ''
+    cp -r . $out
+    wrapProgram $out/slimserver.pl \
+      --prefix PATH : "${stdenv.lib.makeBinPath [ lame flac faad2 sox monkeysAudio wavpack ]}"
+  '';
+
+  outputs = [ "out" ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/Logitech/slimserver;
+    description = "Server for Logitech Squeezebox players. This server is also called Logitech Media Server";
+    # the firmware is not under a free license!
+    # https://github.com/Logitech/slimserver/blob/public/7.9/License.txt
+    license = licenses.unfree;
+    maintainers = [ maintainers.phile314 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/smcroute/default.nix b/pkgs/servers/smcroute/default.nix
new file mode 100644
index 000000000000..40472c59a873
--- /dev/null
+++ b/pkgs/servers/smcroute/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, libcap }:
+
+stdenv.mkDerivation rec {
+  name = "smcroute-${version}";
+  version = "2.4.0";
+
+  src = fetchFromGitHub {
+    owner = "troglobit";
+    repo = "smcroute";
+    rev = version;
+    sha256 = "12xwdwvl9h269armwak7grm4g944j2c89srha4lqx2zndx1ycg1r";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libcap ];
+
+  configureFlags = [
+    "--localstatedir=/var"
+    "--with-systemd=\$(out)/lib/systemd/system"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Static multicast routing daemon";
+    homepage = http://troglobit.com/smcroute.html;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ fpletz ];
+    platforms = with platforms; (linux ++ freebsd ++ netbsd ++ openbsd);
+  };
+}
diff --git a/pkgs/servers/softether/4.18.nix b/pkgs/servers/softether/4.18.nix
index 4b5b67cf85b2..5b0d15136f89 100644
--- a/pkgs/servers/softether/4.18.nix
+++ b/pkgs/servers/softether/4.18.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl
-, openssl, readline, ncurses, zlib }:
+, openssl, readline, ncurses, zlib
+, dataDir ? "/var/lib/softether" }:
 
 let
   os = if stdenv.isLinux then "1"
@@ -17,7 +18,6 @@ stdenv.mkDerivation rec {
   version = "4.18";
   build = "9570";
   compiledDate = "2015.07.26";
-  dataDir = "/var/lib/softether";
 
   src = fetchurl {
     url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz";
@@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
     homepage = https://www.softether.org/;
     license = licenses.gpl2;
     maintainers = [ maintainers.rick68 ];
-    platforms = platforms.all;
+    platforms = filter (p: p != "aarch64-linux") platforms.linux;
   };
 }
diff --git a/pkgs/servers/softether/4.20.nix b/pkgs/servers/softether/4.20.nix
new file mode 100644
index 000000000000..91dd0d0411f8
--- /dev/null
+++ b/pkgs/servers/softether/4.20.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchurl
+, openssl, readline, ncurses, zlib
+, dataDir ? "/var/lib/softether" }:
+
+let
+  os = if stdenv.isLinux then "1"
+       else if stdenv.isFreeBSD then "2"
+       else if stdenv.isSunOS then "3"
+       else if stdenv.isDarwin then "4"
+       else if stdenv.isOpenBSD then "5"
+       else "";
+  cpuBits = if stdenv.is64bit then "2" else "1";
+
+in
+
+stdenv.mkDerivation rec {
+  name = "softether-${version}";
+  version = "4.20";
+  build = "9608";
+  compiledDate = "2016.04.17";
+
+  src = fetchurl {
+    url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz";
+    sha256 = "e559644e34ec6feba43d99f4083f77f9b082dd0574d0bb1e416a65f32ccbc51e";
+  };
+
+  buildInputs = [ openssl readline ncurses zlib ];
+
+  preConfigure = ''
+      echo "${os}
+      ${cpuBits}
+      " | ./configure
+      rm configure
+  '';
+
+  buildPhase = ''
+      mkdir -p $out/bin
+      sed -i \
+          -e "/INSTALL_BINDIR=/s|/usr/bin|/bin|g" \
+          -e "/_DIR=/s|/usr|${dataDir}|g" \
+          -e "s|\$(INSTALL|$out/\$(INSTALL|g" \
+          -e "/echo/s|echo $out/|echo |g" \
+          Makefile
+  '';
+
+  meta = with stdenv.lib; {
+    description = "An Open-Source Free Cross-platform Multi-protocol VPN Program";
+    homepage = https://www.softether.org/;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.rick68 ];
+    platforms = filter (p: p != "aarch64-linux") platforms.linux;
+  };
+}
diff --git a/pkgs/servers/softether/4.25.nix b/pkgs/servers/softether/4.25.nix
new file mode 100644
index 000000000000..04053174f4e4
--- /dev/null
+++ b/pkgs/servers/softether/4.25.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchurl
+, openssl, readline, ncurses, zlib
+, dataDir ? "/var/lib/softether" }:
+
+let
+  os = if stdenv.isLinux then "1"
+       else if stdenv.isFreeBSD then "2"
+       else if stdenv.isSunOS then "3"
+       else if stdenv.isDarwin then "4"
+       else if stdenv.isOpenBSD then "5"
+       else "";
+  cpuBits = if stdenv.is64bit then "2" else "1";
+
+in
+
+stdenv.mkDerivation rec {
+  name = "softether-${version}";
+  version = "4.25";
+  build = "9656";
+  compiledDate = "2018.01.15";
+
+  src = fetchurl {
+    url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz";
+    sha256 = "1y1m8lf0xfh7m70d15wj2jjf5a5qhi3j49ciwqmsscsqvb1xwimr";
+  };
+
+  buildInputs = [ openssl readline ncurses zlib ];
+
+  preConfigure = ''
+      echo "${os}
+      ${cpuBits}
+      " | ./configure
+      rm configure
+  '';
+
+  buildPhase = ''
+      mkdir -p $out/bin
+      sed -i \
+          -e "/INSTALL_BINDIR=/s|/usr/bin|/bin|g" \
+          -e "/_DIR=/s|/usr|${dataDir}|g" \
+          -e "s|\$(INSTALL|$out/\$(INSTALL|g" \
+          -e "/echo/s|echo $out/|echo |g" \
+          Makefile
+  '';
+
+  meta = with stdenv.lib; {
+    description = "An Open-Source Free Cross-platform Multi-protocol VPN Program";
+    homepage = https://www.softether.org/;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.rick68 ];
+    platforms = filter (p: p != "aarch64-linux") platforms.linux;
+  };
+}
diff --git a/pkgs/servers/sonarr/default.nix b/pkgs/servers/sonarr/default.nix
new file mode 100644
index 000000000000..e7114b957dcb
--- /dev/null
+++ b/pkgs/servers/sonarr/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, mono, libmediainfo, sqlite, curl, makeWrapper, ... }:
+
+stdenv.mkDerivation rec {
+  name = "sonarr-${version}";
+  version = "2.0.0.5163";
+
+  src = fetchurl {
+    url = "http://download.sonarr.tv/v2/master/mono/NzbDrone.master.${version}.mono.tar.gz";
+    sha256 = "037rs0cb7dfiblfy02x2l4amv9dmx1wiz5pa97vpczfgk5gq99y3";
+  };
+
+  buildInputs = [
+    makeWrapper
+  ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -r * $out/bin/
+
+    makeWrapper "${mono}/bin/mono" $out/bin/NzbDrone \
+      --add-flags "$out/bin/NzbDrone.exe" \
+      --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [
+          curl sqlite libmediainfo ]}
+  '';
+
+  meta = {
+    description = "Smart PVR for newsgroup and bittorrent users";
+    homepage = https://sonarr.tv/;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.fadenb ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/pkgs/servers/sql/cockroachdb/default.nix b/pkgs/servers/sql/cockroachdb/default.nix
new file mode 100644
index 000000000000..aba997d75f13
--- /dev/null
+++ b/pkgs/servers/sql/cockroachdb/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, buildGoPackage, fetchurl, cmake, xz, which, autoconf, ncurses6, libedit }:
+
+buildGoPackage rec {
+  name = "cockroach-${version}";
+  version = "2.0.0";
+
+  goPackagePath = "github.com/cockroachdb/cockroach";
+
+  src = fetchurl {
+    url = "https://binaries.cockroachdb.com/cockroach-v${version}.src.tgz";
+    sha256 = "0x8hf5qwvgb2w6dcnvy20v77nf19f0l1pb40jf31rm72xhk3bwvy";
+  };
+
+  buildInputs = [ (if stdenv.isDarwin then libedit else ncurses6) ];
+  nativeBuildInputs = [ cmake xz which autoconf ];
+
+  buildPhase = ''
+    runHook preBuild
+    cd $NIX_BUILD_TOP/go/src/${goPackagePath}
+    patchShebangs .
+    make buildoss
+    cd src/${goPackagePath}
+    for asset in man autocomplete; do
+      ./cockroach gen $asset
+    done
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    install -D cockroach $bin/bin/cockroach
+    install -D cockroach.bash $bin/share/bash-completion/completions/cockroach.bash
+    cp -r man $bin/share/man
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.cockroachlabs.com;
+    description = "A scalable, survivable, strongly-consistent SQL database";
+    license = licenses.asl20;
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    maintainers = [ maintainers.rushmorem ];
+  };
+}
diff --git a/pkgs/servers/sql/mariadb/clang-isfinite.patch b/pkgs/servers/sql/mariadb/clang-isfinite.patch
new file mode 100644
index 000000000000..8da527d57847
--- /dev/null
+++ b/pkgs/servers/sql/mariadb/clang-isfinite.patch
@@ -0,0 +1,17 @@
+diff --git a/include/my_global.h b/include/my_global.h
+index cb31ae2..2866f87 100644
+--- a/include/my_global.h
++++ b/include/my_global.h
+@@ -803,12 +803,6 @@ inline unsigned long long my_double2ulonglong(double d)
+ #endif
+ 
+ #ifndef isfinite
+-#ifdef HAVE_FINITE
+-#define isfinite(x) finite(x)
+-#else
+-#define finite(x) (1.0 / fabs(x) > 0.0)
+-#endif /* HAVE_FINITE */
+-#elif (__cplusplus >= 201103L)
+ #include <cmath>
+ static inline bool isfinite(double x) { return std::isfinite(x); }
+ #endif /* isfinite */
diff --git a/pkgs/servers/sql/mariadb/cmake-includedir.patch b/pkgs/servers/sql/mariadb/cmake-includedir.patch
new file mode 100644
index 000000000000..0c4fe7d321e2
--- /dev/null
+++ b/pkgs/servers/sql/mariadb/cmake-includedir.patch
@@ -0,0 +1,11 @@
+--- a/include/CMakeLists.txt	2017-12-25 05:59:07.204144374 +0100
++++ b/include/CMakeLists.txt	2017-12-25 05:59:26.339552817 +0100
+@@ -94,7 +94,7 @@
+ ENDIF()
+ 
+ MACRO(INSTALL_COMPAT_HEADER file footer)
+-  INSTALL(CODE "FILE(WRITE \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDEDIR}/${file}
++  INSTALL(CODE "FILE(WRITE ${INSTALL_INCLUDEDIR}/${file}
+ \"/* Do not edit this file directly, it was auto-generated by cmake */
+ 
+ #warning This file should not be included by clients, include only <mysql.h>
diff --git a/pkgs/servers/sql/mariadb/default.nix b/pkgs/servers/sql/mariadb/default.nix
index 90372142704b..fee35a623330 100644
--- a/pkgs/servers/sql/mariadb/default.nix
+++ b/pkgs/servers/sql/mariadb/default.nix
@@ -1,46 +1,153 @@
-{ stdenv, fetchurl, cmake, ncurses, zlib, openssl, pcre, boost, judy, bison, libxml2
-, libaio, libevent, groff, jemalloc, perl, fixDarwinDylibNames
+{ stdenv, fetchurl, cmake, pkgconfig, ncurses, zlib, xz, lzo, lz4, bzip2, snappy
+, libiconv, openssl, pcre, boost, judy, bison, libxml2
+, libaio, libevent, groff, jemalloc, cracklib, systemd, numactl, perl
+, fixDarwinDylibNames, cctools, CoreServices
+, asio, buildEnv, check, scons
 }:
 
 with stdenv.lib;
-stdenv.mkDerivation rec {
-  name = "mariadb-${version}";
-  version = "10.0.21";
+
+let # in mariadb # spans the whole file
+
+mariadb = everything // {
+  inherit client; # libmysqlclient.so in .out, necessary headers in .dev and utils in .bin
+  server = everything; # a full single-output build, including everything in `client` again
+  inherit connector-c; # libmysqlclient.so
+  inherit galera;
+};
+
+galeraLibs = buildEnv {
+  name = "galera-lib-inputs-united";
+  paths = [ openssl.out boost check ];
+};
+
+common = rec { # attributes common to both builds
+  version = "10.2.15";
 
   src = fetchurl {
-    url    = "https://downloads.mariadb.org/interstitial/mariadb-${version}/source/mariadb-${version}.tar.gz";
-    sha256 = "0i9mzbn35f4lj4y1lqzgbavh5xyx18zfn0ks0nqzvppabkhk56jb";
+    url    = "https://downloads.mariadb.org/f/mariadb-${version}/source/mariadb-${version}.tar.gz";
+    sha256 = "04ds6vkb7k2lqpcdz663z4ll1jx1zz2hqxz5nj7gs8pwb18j1pik";
+    name   = "mariadb-${version}.tar.gz";
   };
 
-  buildInputs = [ cmake ncurses openssl zlib pcre libxml2 boost judy bison libevent ]
-    ++ stdenv.lib.optionals stdenv.isLinux [ jemalloc libaio ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ perl fixDarwinDylibNames ];
+  nativeBuildInputs = [ cmake pkgconfig ];
 
-  patches = stdenv.lib.optional stdenv.isDarwin ./my_context_asm.patch;
+  buildInputs = [
+    ncurses openssl zlib pcre jemalloc libiconv
+  ] ++ stdenv.lib.optionals stdenv.isLinux [ libaio systemd ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ perl fixDarwinDylibNames cctools CoreServices ];
+
+  prePatch = ''
+    sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt
+  '';
+
+  patches = [ ./cmake-includedir.patch ./include-dirs-path.patch ]
+    ++ stdenv.lib.optional stdenv.cc.isClang ./clang-isfinite.patch;
 
   cmakeFlags = [
     "-DBUILD_CONFIG=mysql_release"
+    "-DMANUFACTURER=NixOS.org"
     "-DDEFAULT_CHARSET=utf8"
     "-DDEFAULT_COLLATION=utf8_general_ci"
-    "-DENABLED_LOCAL_INFILE=ON"
+    "-DSECURITY_HARDENED=ON"
+
     "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
+    "-DINSTALL_MYSQLSHAREDIR=share/mysql"
+
+    "-DWITH_ZLIB=system"
+    "-DWITH_SSL=system"
+    "-DWITH_PCRE=system"
+
+    # On Darwin without sandbox, CMake will find the system java and attempt to build with java support, but
+    # then it will fail during the actual build. Let's just disable the flag explicitly until someone decides
+    # to pass in java explicitly. This should have no effect on Linux.
+    "-DCONNECT_WITH_JDBC=OFF"
+
+    # Same as above. Somehow on Darwin CMake decides that we support GSS even though we aren't provding the
+    # library through Nix, and then breaks later on. This should have no effect on Linux.
+    "-DPLUGIN_AUTH_GSSAPI=NO"
+    "-DPLUGIN_AUTH_GSSAPI_CLIENT=NO"
+  ]
+    ++ optional stdenv.isDarwin "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib"
+    ++ optional stdenv.hostPlatform.isMusl "-DWITHOUT_TOKUDB=1" # mariadb docs say disable this for musl
+    ;
+
+  preConfigure = ''
+    cmakeFlags="$cmakeFlags -DINSTALL_INCLUDEDIR=''${!outputDev}/include/mysql"
+  '';
+
+  postInstall = ''
+    rm "$out"/lib/*.a
+    find "''${!outputBin}/bin" -name '*test*' -delete
+  '';
+
+  passthru.mysqlVersion = "5.7";
+
+  meta = with stdenv.lib; {
+    description = "An enhanced, drop-in replacement for MySQL";
+    homepage    = https://mariadb.org/;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ thoughtpolice wkennington ];
+    platforms   = platforms.all;
+  };
+};
+
+client = stdenv.mkDerivation (common // {
+  name = "mariadb-client-${common.version}";
+
+  outputs = [ "bin" "dev" "out" ];
+
+  propagatedBuildInputs = [ openssl zlib ]; # required from mariadb.pc
+
+  cmakeFlags = common.cmakeFlags ++ [
+    "-DWITHOUT_SERVER=ON"
+  ];
+
+  preConfigure = common.preConfigure + ''
+    cmakeFlags="$cmakeFlags \
+      -DINSTALL_BINDIR=$bin/bin \
+      -DINSTALL_SCRIPTDIR=$bin/bin \
+      -DINSTALL_SUPPORTFILESDIR=$bin/share/mysql \
+      -DINSTALL_DOCDIR=$bin/share/doc/mysql \
+      -DINSTALL_DOCREADMEDIR=$bin/share/doc/mysql \
+      "
+  '';
+
+  # prevent cycle; it needs to reference $dev
+  postInstall = common.postInstall + ''
+    moveToOutput bin/mysql_config "$dev"
+    moveToOutput bin/mariadb_config "$dev"
+  '';
+
+  enableParallelBuilding = true; # the client should be OK
+});
+
+everything = stdenv.mkDerivation (common // {
+  name = "mariadb-${common.version}";
+
+  nativeBuildInputs = common.nativeBuildInputs ++ [ bison ];
+
+  buildInputs = common.buildInputs ++ [
+    xz lzo lz4 bzip2 snappy
+    libxml2 boost judy libevent cracklib
+  ] ++ optional (stdenv.isLinux && !stdenv.isAarch32) numactl;
+
+  cmakeFlags = common.cmakeFlags ++ [
     "-DMYSQL_DATADIR=/var/lib/mysql"
     "-DINSTALL_SYSCONFDIR=etc/mysql"
     "-DINSTALL_INFODIR=share/mysql/docs"
     "-DINSTALL_MANDIR=share/man"
     "-DINSTALL_PLUGINDIR=lib/mysql/plugin"
     "-DINSTALL_SCRIPTDIR=bin"
-    "-DINSTALL_INCLUDEDIR=include/mysql"
-    "-DINSTALL_DOCREADMEDIR=share/mysql"
     "-DINSTALL_SUPPORTFILESDIR=share/mysql"
-    "-DINSTALL_MYSQLSHAREDIR=share/mysql"
-    "-DINSTALL_DOCDIR=share/mysql/docs"
+    "-DINSTALL_DOCREADMEDIR=share/doc/mysql"
+    "-DINSTALL_DOCDIR=share/doc/mysql"
     "-DINSTALL_SHAREDIR=share/mysql"
+    "-DINSTALL_MYSQLTESTDIR=OFF"
+    "-DINSTALL_SQLBENCHDIR=OFF"
+
+    "-DENABLED_LOCAL_INFILE=ON"
     "-DWITH_READLINE=ON"
-    "-DWITH_ZLIB=system"
-    "-DWITH_SSL=system"
-    "-DWITH_PCRE=system"
-    "-DWITH_EMBEDDED_SERVER=yes"
     "-DWITH_EXTRA_CHARSETS=complex"
     "-DWITH_EMBEDDED_SERVER=ON"
     "-DWITH_ARCHIVE_STORAGE_ENGINE=1"
@@ -49,74 +156,112 @@ stdenv.mkDerivation rec {
     "-DWITH_PARTITION_STORAGE_ENGINE=1"
     "-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1"
     "-DWITHOUT_FEDERATED_STORAGE_ENGINE=1"
+    "-DWITH_WSREP=ON"
+    "-DWITH_INNODB_DISALLOW_WRITES=ON"
   ] ++ stdenv.lib.optionals stdenv.isDarwin [
     "-DWITHOUT_OQGRAPH_STORAGE_ENGINE=1"
     "-DWITHOUT_TOKUDB=1"
   ];
 
-  # fails to find lex_token.h sometimes
-  enableParallelBuilding = false;
+  postInstall = common.postInstall + ''
+    rm -r "$out"/data # Don't need testing data
+    rm "$out"/share/man/man1/mysql-test-run.pl.1
+    rm "$out"/bin/rcmysql
+  '' + optionalString (! stdenv.isDarwin) ''
+    sed -i 's/-mariadb/-mysql/' "$out"/bin/galera_new_cluster
+  '';
 
-  outputs = [ "out" "lib" ];
+  CXXFLAGS = optionalString stdenv.isi686 "-fpermissive"
+    + optionalString stdenv.isDarwin " -std=c++11";
+});
 
-  prePatch = ''
-    substituteInPlace cmake/libutils.cmake \
-      --replace /usr/bin/libtool libtool
-    sed -i "s,SET(DEFAULT_MYSQL_HOME.*$,SET(DEFAULT_MYSQL_HOME /not/a/real/dir),g" CMakeLists.txt
-    sed -i "s,SET(PLUGINDIR.*$,SET(PLUGINDIR $lib/lib/mysql/plugin),g" CMakeLists.txt
-
-    sed -i "s,SET(pkgincludedir.*$,SET(pkgincludedir $lib/include),g" scripts/CMakeLists.txt
-    sed -i "s,SET(pkglibdir.*$,SET(pkglibdir $lib/lib),g" scripts/CMakeLists.txt
-    sed -i "s,SET(pkgplugindir.*$,SET(pkgplugindir $lib/lib/mysql/plugin),g" scripts/CMakeLists.txt
-
-    sed -i "s,set(libdir.*$,SET(libdir $lib/lib),g" storage/mroonga/vendor/groonga/CMakeLists.txt
-    sed -i "s,set(includedir.*$,SET(includedir $lib/include),g" storage/mroonga/vendor/groonga/CMakeLists.txt
-    sed -i "/\"\$[{]CMAKE_INSTALL_PREFIX}\/\$[{]GRN_RELATIVE_PLUGINS_DIR}\"/d" storage/mroonga/vendor/groonga/CMakeLists.txt
-    sed -i "s,set(GRN_PLUGINS_DIR.*$,SET(GRN_PLUGINS_DIR $lib/\$\{GRN_RELATIVE_PLUGINS_DIR}),g" storage/mroonga/vendor/groonga/CMakeLists.txt
-    sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt
-  '';
+connector-c = stdenv.mkDerivation rec {
+  name = "mariadb-connector-c-${version}";
+  version = "2.3.5";
 
-  postInstall = ''
-    substituteInPlace $out/bin/mysql_install_db \
-      --replace basedir=\"\" basedir=\"$out\"
-
-    # Remove superfluous files
-    rm -r $out/mysql-test $out/sql-bench $out/data # Don't need testing data
-    rm $out/share/man/man1/mysql-test-run.pl.1
-    rm $out/bin/rcmysql # Not needed with nixos units
-    rm $out/bin/mysqlbug # Encodes a path to gcc and not really useful
-    find $out/bin -name \*test\* -exec rm {} \;
-
-    # Separate libs and includes into their own derivation
-    mkdir -p $lib
-    mv $out/lib $lib
-    mv $out/include $lib
-
-    # Fix the mysql_config
-    sed -i $out/bin/mysql_config \
-      -e 's,-lz,-L${zlib}/lib -lz,g' \
-      -e 's,-lssl,-L${openssl}/lib -lssl,g'
-
-    # Add mysql_config to libs since configure scripts use it
-    mkdir -p $lib/bin
-    cp $out/bin/mysql_config $lib/bin
-    sed -i "/\(execdir\|bindir\)/ s,'[^\"']*',$lib/bin,g" $lib/bin/mysql_config
-
-    # Make sure to propagate lib for compatability
-    mkdir -p $out/nix-support
-    echo "$lib" > $out/nix-support/propagated-native-build-inputs
-
-    # Don't install static libraries.
-    rm $lib/lib/libmysqlclient.a $lib/lib/libmysqld.a
+  src = fetchurl {
+    url = "https://downloads.mariadb.org/interstitial/connector-c-${version}/mariadb-connector-c-${version}-src.tar.gz/from/http%3A//ftp.hosteurope.de/mirror/archive.mariadb.org/?serve";
+    sha256 = "0vvlfs56hxin130vh8pcs5w7jpv1yc6g76bhpzg88hnp4v1z8frg";
+    name   = "mariadb-connector-c-${version}-src.tar.gz";
+  };
+
+  # outputs = [ "dev" "out" ]; FIXME: cmake variables don't allow that < 3.0
+  cmakeFlags = [
+    "-DWITH_EXTERNAL_ZLIB=ON"
+    "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
+  ];
+
+  # The cmake setup-hook uses $out/lib by default, this is not the case here.
+  preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
+    cmakeFlagsArray+=("-DCMAKE_INSTALL_NAME_DIR=$out/lib/mariadb")
   '';
 
-  passthru.mysqlVersion = "5.6";
+  nativeBuildInputs = [ cmake ];
+  propagatedBuildInputs = [ openssl zlib ];
+  buildInputs = [ libiconv ];
+
+  enableParallelBuilding = true;
+
+  postFixup = ''
+    ln -sv mariadb_config $out/bin/mysql_config
+    ln -sv mariadb $out/lib/mysql
+    ln -sv mariadb $out/include/mysql
+  '';
 
   meta = with stdenv.lib; {
-    description = "An enhanced, drop-in replacement for MySQL";
-    homepage    = https://mariadb.org/;
-    license     = stdenv.lib.licenses.gpl2;
-    maintainers = with stdenv.lib.maintainers; [ thoughtpolice wkennington ];
-    platforms   = stdenv.lib.platforms.all;
+    description = "Client library that can be used to connect to MySQL or MariaDB";
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ globin ];
+    platforms = platforms.all;
+  };
+};
+
+galera = stdenv.mkDerivation rec {
+  name = "mariadb-galera-${version}";
+  version = "25.3.23";
+
+  src = fetchurl {
+    url = "https://mirrors.nxthost.com/mariadb/mariadb-10.2.14/galera-${version}/src/galera-${version}.tar.gz";
+    sha256 = "11pfc85z29jk0h6g6bmi3hdv4in4yb00xsr2r0qm1b0y7m2wq3ra";
+  };
+
+  buildInputs = [ asio boost check openssl scons ];
+
+  patchPhase = ''
+    substituteInPlace SConstruct \
+      --replace "boost_library_path = '''" "boost_library_path = '${boost}/lib'"
+  '';
+
+  preConfigure = ''
+    export CPPFLAGS="-I${asio}/include -I${boost.dev}/include -I${check}/include -I${openssl.dev}/include"
+    export LIBPATH="${galeraLibs}/lib"
+  '';
+
+  buildPhase = ''
+     scons -j$NIX_BUILD_CORES ssl=1 system_asio=1 strict_build_flags=0
+  '';
+
+  installPhase = ''
+    # copied with modifications from scripts/packages/freebsd.sh
+    GALERA_LICENSE_DIR="$share/licenses/${name}"
+    install -d $out/{bin,lib/galera,share/doc/galera,$GALERA_LICENSE_DIR}
+    install -m 555 "garb/garbd"                       "$out/bin/garbd"
+    install -m 444 "libgalera_smm.so"                 "$out/lib/galera/libgalera_smm.so"
+    install -m 444 "scripts/packages/README"          "$out/share/doc/galera/"
+    install -m 444 "scripts/packages/README-MySQL"    "$out/share/doc/galera/"
+    install -m 444 "scripts/packages/freebsd/LICENSE" "$out/$GALERA_LICENSE_DIR"
+    install -m 444 "LICENSE"                          "$out/$GALERA_LICENSE_DIR/GPLv2"
+    install -m 444 "asio/LICENSE_1_0.txt"             "$out/$GALERA_LICENSE_DIR/LICENSE.asio"
+    install -m 444 "www.evanjones.ca/LICENSE"         "$out/$GALERA_LICENSE_DIR/LICENSE.crc32c"
+    install -m 444 "chromium/LICENSE"                 "$out/$GALERA_LICENSE_DIR/LICENSE.chromium"
+  '';
+
+  meta = {
+    description = "Galera 3 wsrep provider library";
+    homepage = http://galeracluster.com/;
+    license = licenses.lgpl2;
+    maintainers = with maintainers; [ izorkin ];
+    platforms = platforms.all;
   };
-}
+};
+in mariadb
diff --git a/pkgs/servers/sql/mariadb/include-dirs-path.patch b/pkgs/servers/sql/mariadb/include-dirs-path.patch
new file mode 100644
index 000000000000..8d468cf546a4
--- /dev/null
+++ b/pkgs/servers/sql/mariadb/include-dirs-path.patch
@@ -0,0 +1,13 @@
+diff --git a/libmariadb/mariadb_config/mariadb_config.c.in b/libmariadb/mariadb_config/mariadb_config.c.in
+index 45d2f4e..e5666db 100644
+--- a/libmariadb/mariadb_config/mariadb_config.c.in
++++ b/libmariadb/mariadb_config/mariadb_config.c.in
+@@ -5,7 +5,7 @@
+ 
+ static char *mariadb_progname;
+ 
+-#define INCLUDE "-I@CMAKE_INSTALL_PREFIX@/@INSTALL_INCLUDEDIR@ -I@CMAKE_INSTALL_PREFIX@/@INSTALL_INCLUDEDIR@/mysql"
++#define INCLUDE "-I@INSTALL_INCLUDEDIR@ -I@INSTALL_INCLUDEDIR@/mysql"
+ #define LIBS    "-L@CMAKE_INSTALL_PREFIX@/@INSTALL_LIBDIR@/ -lmariadb @extra_dynamic_LDFLAGS@"
+ #define LIBS_SYS "@extra_dynamic_LDFLAGS@"
+ #define CFLAGS  INCLUDE
diff --git a/pkgs/servers/sql/mariadb/my_context_asm.patch b/pkgs/servers/sql/mariadb/my_context_asm.patch
deleted file mode 100644
index 3a747ed1b03c..000000000000
--- a/pkgs/servers/sql/mariadb/my_context_asm.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/mysys/my_context.c
-+++ b/mysys/my_context.c
-@@ -206,15 +206,6 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
-     (
-      "movq %%rsp, (%[save])\n\t"
-      "movq %[stack], %%rsp\n\t"
--#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
--     /*
--       This emits a DWARF DW_CFA_undefined directive to make the return address
--       undefined. This indicates that this is the top of the stack frame, and
--       helps tools that use DWARF stack unwinding to obtain stack traces.
--       (I use numeric constant to avoid a dependency on libdwarf includes).
--     */
--     ".cfi_escape 0x07, 16\n\t"
--#endif
-      "movq %%rbp, 8(%[save])\n\t"
-      "movq %%rbx, 16(%[save])\n\t"
-      "movq %%r12, 24(%[save])\n\t"
diff --git a/pkgs/servers/sql/monetdb/default.nix b/pkgs/servers/sql/monetdb/default.nix
index afd2222918eb..6067d4983865 100644
--- a/pkgs/servers/sql/monetdb/default.nix
+++ b/pkgs/servers/sql/monetdb/default.nix
@@ -1,41 +1,26 @@
-{ composableDerivation, fetchurl, pcre, openssl, readline, libxml2, geos, apacheAnt, jdk5 }:
+{ stdenv, fetchurl, pkgconfig
+, bison, openssl, readline
+}:
 
-let inherit (composableDerivation) edf; in
+let
+  version = "11.29.3";
+in stdenv.mkDerivation rec {
 
-composableDerivation.composableDerivation {} {
-
-  name = "monetdb-2009-05-01";
+  name = "monetdb-${version}";
 
   src = fetchurl {
-    url = http://monetdb.cwi.nl/downloads/sources/May2009-SP1/MonetDB-May2009-SuperBall-SP1.tar.bz2;
-    sha256 = "0r794snnwa4m0x57nv8cgfdxwb689946c1mi2s44wp4iljka2ryj";
-  };
-
-  flags = edf { name = "geom"; enable = { buildInputs = [geos]; }; }
-          // {
-            java = { buildInputs = [ (apacheAnt.override {jdk = jdk5;}) jdk5 /* must be 1.5 */ ]; };
-            /* perl TODO export these (SWIG only if its present) HAVE_PERL=1 HAVE_PERL_DEVEL=1 HAVE_PERL_SWIG=1 */
-          };
-
-  buildInputs = [ (pcre.override { unicodeSupport = true; })
-                   openssl readline libxml2 ]; # optional python perl php java ?
-
-  cfg = {
-    geomSupport = true;
-    javaSupport = true;
+    url = "https://dev.monetdb.org/downloads/sources/archive/MonetDB-${version}.tar.bz2";
+    sha256 = "18l4jkkryki5az5n7gnalfdxz6ibnkg3q2z4cwh1010b313wqi8s";
   };
 
-  configurePhase = ":";
-  buildPhase = ":";
-  
-  installPhase = ''
-    mkdir $TMP/build
-    sh monetdb-install.sh --build=$TMP/build --prefix=$out --enable-sql --enable-xquery
-  '';
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ bison openssl readline ];
 
-  meta = { 
-    description = "A open-source database system for high-performance applications in data mining, OLAP, GIS, XML Query, text and multimedia retrieval";
-    homepage = http://monetdb.cwi.nl/;
-    license = "MonetDB Public License"; # very similar to Mozilla public license (MPL) Version see 1.1 http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html 
+  meta = with stdenv.lib; {
+    description = "An open source database system";
+    homepage = https://www.monetdb.org/;
+    license = licenses.mpl20;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.StillerHarpo ];
   };
 }
diff --git a/pkgs/servers/sql/mysql/5.1.x.nix b/pkgs/servers/sql/mysql/5.1.x.nix
deleted file mode 100644
index caf6149e62c0..000000000000
--- a/pkgs/servers/sql/mysql/5.1.x.nix
+++ /dev/null
@@ -1,42 +0,0 @@
-{ stdenv, fetchurl, ps, ncurses, zlib, perl, openssl }:
-
-# Note: zlib is not required; MySQL can use an internal zlib.
-
-stdenv.mkDerivation rec {
-  name = "mysql-5.1.73";
-
-  src = fetchurl {
-    url = "mirror://mysql/MySQL-5.1/${name}.tar.gz";
-    sha256 = "1dfwi4ck0vq6sdci6gz0031s7zz5lc3pddqlgm0292s00l9y5sq5";
-  };
-
-  buildInputs = [ ncurses zlib perl openssl ] ++ stdenv.lib.optional stdenv.isLinux ps;
-
-  configureFlags = [
-    "--enable-thread-safe-client"
-    "--with-ssl=${openssl}"
-    "--with-embedded-server"
-    "--with-plugins=max-no-ndb"
-    "--with-unix-socket-path=/run/mysqld/mysqld.sock"
-  ] ++ stdenv.lib.optional (stdenv.system == "x86_64-linux") " --with-lib-ccflags=-fPIC";
-
-  NIX_CFLAGS_COMPILE = if stdenv.system == "x86_64-linux" then "-fPIC" else "";
-  NIX_CFLAGS_CXXFLAGS = if stdenv.system == "x86_64-linux" then "-fPIC" else "";
-  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";
-
-  patches = [ ./abi_check.patch ];
-
-  postInstall =
-    ''
-      ln -s mysqld_safe $out/bin/mysqld
-      rm -rf $out/mysql-test $out/sql-bench $out/share/info
-    '';
-
-  passthru.mysqlVersion = "5.1";
-
-  meta = {
-    homepage = http://www.mysql.com/;
-    description = "The world's most popular open source database";
-    platforms = stdenv.lib.platforms.all;
-  };
-}
diff --git a/pkgs/servers/sql/mysql/5.5.x.nix b/pkgs/servers/sql/mysql/5.5.x.nix
index dbbb9223ee46..15f82a90208c 100644
--- a/pkgs/servers/sql/mysql/5.5.x.nix
+++ b/pkgs/servers/sql/mysql/5.5.x.nix
@@ -1,14 +1,16 @@
-{ stdenv, fetchurl, cmake, bison, ncurses, openssl, readline, zlib, perl }:
+{ stdenv, fetchurl, cmake, bison, ncurses, openssl, readline, zlib, perl
+, cctools, CoreServices }:
 
 # Note: zlib is not required; MySQL can use an internal zlib.
 
-stdenv.mkDerivation rec {
+let
+self = stdenv.mkDerivation rec {
   name = "mysql-${version}";
-  version = "5.5.45";
+  version = "5.5.60";
 
   src = fetchurl {
     url = "mirror://mysql/MySQL-5.5/${name}.tar.gz";
-    sha256 = "0clkr3r44j8nsgmjzv6r09pb0vjangn5hpyjxgg5ynr674ygskkl";
+    sha256 = "071xaamqkbscybqzm79gf2w3bkr9lqlzwafis3gzc8w8fkhi4hd3";
   };
 
   patches = if stdenv.isCygwin then [
@@ -22,7 +24,7 @@ stdenv.mkDerivation rec {
   '';
 
   buildInputs = [ cmake bison ncurses openssl readline zlib ]
-     ++ stdenv.lib.optional stdenv.isDarwin perl;
+     ++ stdenv.lib.optionals stdenv.isDarwin [ perl cctools CoreServices ];
 
   enableParallelBuilding = true;
 
@@ -45,8 +47,11 @@ stdenv.mkDerivation rec {
     "-DINSTALL_MYSQLSHAREDIR=share/mysql"
     "-DINSTALL_DOCDIR=share/mysql/docs"
     "-DINSTALL_SHAREDIR=share/mysql"
+    "-DINSTALL_MYSQLTESTDIR="
+    "-DINSTALL_SQLBENCHDIR="
   ];
 
+  NIX_CFLAGS_COMPILE = [ "-fpermissive" ]; # since gcc-7
   NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";
 
   prePatch = ''
@@ -54,14 +59,19 @@ stdenv.mkDerivation rec {
   '';
   postInstall = ''
     sed -i -e "s|basedir=\"\"|basedir=\"$out\"|" $out/bin/mysql_install_db
-    rm -r $out/mysql-test $out/sql-bench $out/data "$out"/lib/*.a
-    rm $out/share/man/man1/mysql-test-run.pl.1
+    rm -r $out/data "$out"/lib/*.a
   '';
 
-  passthru.mysqlVersion = "5.5";
+  passthru = {
+    client = self;
+    connector-c = self;
+    server = self;
+    mysqlVersion = "5.5";
+  };
 
   meta = {
-    homepage = http://www.mysql.com/;
+    homepage = https://www.mysql.com/;
     description = "The world's most popular open source database";
+    platforms = stdenv.lib.platforms.unix;
   };
-}
+}; in self
diff --git a/pkgs/servers/sql/mysql/5.7.x.nix b/pkgs/servers/sql/mysql/5.7.x.nix
new file mode 100644
index 000000000000..146d9d23198b
--- /dev/null
+++ b/pkgs/servers/sql/mysql/5.7.x.nix
@@ -0,0 +1,83 @@
+{ stdenv, fetchurl, cmake, bison
+, boost, libedit, libevent, lz4, ncurses, openssl, protobuf, readline, zlib, perl
+, cctools, CoreServices, developer_cmds }:
+
+# Note: zlib is not required; MySQL can use an internal zlib.
+
+let
+self = stdenv.mkDerivation rec {
+  name = "mysql-${version}";
+  version = "5.7.22";
+
+  src = fetchurl {
+    url = "mirror://mysql/MySQL-5.7/${name}.tar.gz";
+    sha256 = "1wng15j5caz6fsv28avlcxjgq3c5n90ifk79xa0h7jws19dl1f2f";
+  };
+
+  preConfigure = stdenv.lib.optional stdenv.isDarwin ''
+    ln -s /bin/ps $TMPDIR/ps
+    export PATH=$PATH:$TMPDIR
+  '';
+
+  nativeBuildInputs = [ cmake bison ];
+
+  buildInputs = [ boost libedit libevent lz4 ncurses openssl protobuf readline zlib ]
+     ++ stdenv.lib.optionals stdenv.isDarwin [ perl cctools CoreServices developer_cmds ];
+
+  enableParallelBuilding = true;
+
+  outputs = [ "out" "static" ];
+
+  cmakeFlags = [
+    "-DCMAKE_SKIP_BUILD_RPATH=OFF" # To run libmysql/libmysql_api_test during build.
+    "-DWITH_SSL=yes"
+    "-DWITH_EMBEDDED_SERVER=yes"
+    "-DWITH_UNIT_TESTS=no"
+    "-DWITH_EDITLINE=system"
+    "-DWITH_LIBEVENT=system"
+    "-DWITH_LZ4=system"
+    "-DWITH_PROTOBUF=system"
+    "-DWITH_ZLIB=system"
+    "-DWITH_ARCHIVE_STORAGE_ENGINE=yes"
+    "-DWITH_BLACKHOLE_STORAGE_ENGINE=yes"
+    "-DWITH_FEDERATED_STORAGE_ENGINE=yes"
+    "-DHAVE_IPV6=yes"
+    "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
+    "-DMYSQL_DATADIR=/var/lib/mysql"
+    "-DINSTALL_INFODIR=share/mysql/docs"
+    "-DINSTALL_MANDIR=share/man"
+    "-DINSTALL_PLUGINDIR=lib/mysql/plugin"
+    "-DINSTALL_SCRIPTDIR=bin"
+    "-DINSTALL_INCLUDEDIR=include/mysql"
+    "-DINSTALL_DOCREADMEDIR=share/mysql"
+    "-DINSTALL_SUPPORTFILESDIR=share/mysql"
+    "-DINSTALL_MYSQLSHAREDIR=share/mysql"
+    "-DINSTALL_MYSQLTESTDIR="
+    "-DINSTALL_DOCDIR=share/mysql/docs"
+    "-DINSTALL_SHAREDIR=share/mysql"
+  ];
+
+  CXXFLAGS = "-fpermissive";
+  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";
+
+  prePatch = ''
+    sed -i -e "s|/usr/bin/libtool|libtool|" cmake/merge_archives.cmake.in
+  '';
+  postInstall = ''
+    moveToOutput "lib/*.a" $static
+    ln -s libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libmysqlclient_r${stdenv.hostPlatform.extensions.sharedLibrary}
+  '';
+
+  passthru = {
+    client = self;
+    connector-c = self;
+    server = self;
+    mysqlVersion = "5.7";
+  };
+
+  meta = {
+    homepage = https://www.mysql.com/;
+    description = "The world's most popular open source database";
+    platforms = stdenv.lib.platforms.unix;
+  };
+}; in self
diff --git a/pkgs/servers/sql/mysql/jdbc/default.nix b/pkgs/servers/sql/mysql/jdbc/default.nix
index 59643fa3e000..66e62b823d9a 100644
--- a/pkgs/servers/sql/mysql/jdbc/default.nix
+++ b/pkgs/servers/sql/mysql/jdbc/default.nix
@@ -1,13 +1,17 @@
 {stdenv, fetchurl, ant, unzip}:
 
-stdenv.mkDerivation {
-  name = "mysql-connector-java-5.1.32";
+stdenv.mkDerivation rec {
+  name = "mysql-connector-java-5.1.46";
   builder = ./builder.sh;
 
   src = fetchurl {
-    url = http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.32.zip;
-    sha256 = "11vjwws1pa8fdwn86rrmqdwsq3ld3sh2r0pp4lpr2gxw0w18ykc7";
+    url = "http://dev.mysql.com/get/Downloads/Connector-J/${name}.zip";
+    sha256 = "0dfjshrrx0ndfb6xbdpwhn1f1jkw0km57rgpar0ny8ixmgdnlwnm";
   };
 
   buildInputs = [ unzip ant ];
+
+  meta = {
+    platforms = stdenv.lib.platforms.unix;
+  };
 }
diff --git a/pkgs/servers/sql/oracle-xe/default.nix b/pkgs/servers/sql/oracle-xe/default.nix
index cb150fc5fd4c..a50d623acbce 100644
--- a/pkgs/servers/sql/oracle-xe/default.nix
+++ b/pkgs/servers/sql/oracle-xe/default.nix
@@ -1,7 +1,5 @@
 { stdenv, makeWrapper, requireFile, patchelf, rpmextract, libaio }:
 
-assert stdenv.system == "x86_64-linux";
-
 with stdenv.lib;
 
 stdenv.mkDerivation rec {
@@ -70,14 +68,15 @@ stdenv.mkDerivation rec {
       makeWrapper "$i" "$out/bin/''${i##*/}" \
         --set ORACLE_HOME "$out/libexec/oracle" \
         --set ORACLE_SID XE \
-        --set NLS_LANG '$("'"$out"'/libexec/oracle/bin/nls_lang.sh")' \
+        --run "export NLS_LANG=\$($out/libexec/oracle/bin/nls_lang.sh)" \
         --prefix PATH : "$out/libexec/oracle/bin"
     done
   '';
 
   meta = {
     description = "Oracle Database Express Edition";
-    homepage = "http://www.oracle.com/technetwork/products/express-edition/";
+    homepage = http://www.oracle.com/technetwork/products/express-edition/;
     license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
   };
 }
diff --git a/pkgs/servers/sql/percona/5.6.x.nix b/pkgs/servers/sql/percona/5.6.x.nix
new file mode 100644
index 000000000000..e440f11b2e44
--- /dev/null
+++ b/pkgs/servers/sql/percona/5.6.x.nix
@@ -0,0 +1,62 @@
+{ stdenv, fetchurl, cmake, bison, ncurses, openssl, zlib, libaio, perl }:
+
+stdenv.mkDerivation rec {
+  name = "percona-server-${version}";
+  version = "5.6.35-80.0";
+
+  src = fetchurl {
+    url = "https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${version}/source/tarball/percona-server-${version}.tar.gz";
+    sha256 = "0szjywx902da09pg8yqj8l2acplmh69hn5smrk45i291qsi5m6r5";
+  };
+
+  buildInputs = [ cmake bison ncurses openssl zlib libaio perl ];
+
+  enableParallelBuilding = true;
+
+  cmakeFlags = [
+    "-DFEATURE_SET=community"
+    "-DBUILD_CONFIG=mysql_release"
+    "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
+    "-DWITH_SSL=yes"
+    "-DWITH_READLINE=no"
+    "-DWITH_EMBEDDED_SERVER=no"
+    "-DWITH_EDITLINE=bundled"
+    "-DWITH_ZLIB=yes"
+    "-DHAVE_IPV6=no"
+    "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
+    "-DMYSQL_DATADIR=/var/lib/mysql"
+    "-DINSTALL_SYSCONFDIR=etc/mysql"
+    "-DINSTALL_INFODIR=share/mysql/docs"
+    "-DINSTALL_MANDIR=share/man"
+    "-DINSTALL_PLUGINDIR=lib/mysql/plugin"
+    "-DINSTALL_SCRIPTDIR=bin"
+    "-DINSTALL_INCLUDEDIR=include/mysql"
+    "-DINSTALL_DOCREADMEDIR=share/mysql"
+    "-DINSTALL_SUPPORTFILESDIR=share/mysql"
+    "-DINSTALL_MYSQLSHAREDIR=share/mysql"
+    "-DINSTALL_DOCDIR=share/mysql/docs"
+    "-DINSTALL_SHAREDIR=share/mysql"
+  ];
+
+  NIX_LDFLAGS = "-lgcc_s";
+
+  prePatch = ''
+    sed -i -e "s|/usr/bin/libtool|libtool|" cmake/libutils.cmake
+  '';
+  postInstall = ''
+    sed -i -e "s|basedir=\"\"|basedir=\"$out\"|" $out/bin/mysql_install_db
+    rm -r $out/mysql-test $out/sql-bench $out/data "$out"/lib/*.a
+    rm $out/share/man/man1/mysql-test-run.pl.1
+  '';
+
+  passthru.mysqlVersion = "5.6";
+
+  meta = with stdenv.lib; {
+    homepage = https://www.percona.com;
+    description = "a free, fully compatible, enhanced, open source drop-in replacement for MySQL that provides superior performance, scalability and instrumentation";
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ grahamc ];
+    broken = true; # 2018-04-11
+  };
+}
diff --git a/pkgs/servers/sql/pgbouncer/default.nix b/pkgs/servers/sql/pgbouncer/default.nix
new file mode 100644
index 000000000000..7906546ec1ca
--- /dev/null
+++ b/pkgs/servers/sql/pgbouncer/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, openssl, libevent }:
+
+stdenv.mkDerivation rec {
+  name = "pgbouncer-${version}";
+  version = "1.8.1";
+
+  src = fetchurl {
+    url = "https://pgbouncer.github.io/downloads/files/${version}/${name}.tar.gz";
+    sha256 = "1j4d7rkivg3vg27pvirigq9cy4v7pi48x7w57baq131c5lmdx2zs";
+  };
+
+  buildInputs = [ libevent openssl ];
+
+  meta = with stdenv.lib; {
+    homepage = https://pgbouncer.github.io;
+    description = "Lightweight connection pooler for PostgreSQL";
+    license = licenses.isc;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/sql/pgpool/default.nix b/pkgs/servers/sql/pgpool/default.nix
index 775621e64b44..781d25490d21 100644
--- a/pkgs/servers/sql/pgpool/default.nix
+++ b/pkgs/servers/sql/pgpool/default.nix
@@ -1,14 +1,16 @@
 { stdenv, fetchurl, postgresql, openssl, pam ? null, libmemcached ? null }:
 
 stdenv.mkDerivation rec {
-  name = "pgpool-II-3.4.2";
+  name = "pgpool-II-3.4.14";
 
   src = fetchurl {
     name = "${name}.tar.gz";
     url = "http://www.pgpool.net/download.php?f=${name}.tar.gz";
-    sha256 = "0lf3fvwc2ib4md25a3hnv822nhy9ac06vg0ndw8q9bry66hzwcfh";
+    sha256 = "1paak83f4lv48xckmf2znryrvhmdz86w4v97mcw2gxm50hcl74sw";
   };
 
+  patches = [ ./pgpool-II-3.4.14-glibc-2.26.patch ];
+
   buildInputs = [ postgresql openssl pam libmemcached ];
 
   configureFlags = [
@@ -22,6 +24,8 @@ stdenv.mkDerivation rec {
     "sysconfdir=\${out}/etc"
   ];
 
+  enableParallelBuilding = true;
+
   meta = with stdenv.lib; {
     homepage = http://pgpool.net/mediawiki/index.php;
     description = "A middleware that works between postgresql servers and postgresql clients";
diff --git a/pkgs/servers/sql/pgpool/pgpool-II-3.4.14-glibc-2.26.patch b/pkgs/servers/sql/pgpool/pgpool-II-3.4.14-glibc-2.26.patch
new file mode 100644
index 000000000000..6efffff0c6d9
--- /dev/null
+++ b/pkgs/servers/sql/pgpool/pgpool-II-3.4.14-glibc-2.26.patch
@@ -0,0 +1,12 @@
+diff --git a/src/watchdog/wd_lifecheck.c b/src/watchdog/wd_lifecheck.c
+index 1e72307..5cf68a3 100644
+--- a/src/watchdog/wd_lifecheck.c
++++ b/src/watchdog/wd_lifecheck.c
+@@ -26,6 +26,7 @@
+ #include <ctype.h>
+ #include <time.h>
+ #include <string.h>
++#include <stdint.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <netdb.h>
diff --git a/pkgs/servers/sql/postgresql/cstore_fdw/default.nix b/pkgs/servers/sql/postgresql/cstore_fdw/default.nix
new file mode 100644
index 000000000000..70b8abf2502d
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/cstore_fdw/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, postgresql, protobufc }:
+
+stdenv.mkDerivation rec {
+  name = "cstore_fdw-${version}";
+  version = "1.6.0";
+
+  nativeBuildInputs = [ protobufc ];
+  buildInputs = [ postgresql ];
+
+  src = fetchFromGitHub {
+    owner  = "citusdata";
+    repo   = "cstore_fdw";
+    rev    = "refs/tags/v${version}";
+    sha256 = "08jbx4hs2r742flilydp0ajjwv8ffnvq82nidh48irrfa4i7n0l0";
+  };
+
+  installPhase = ''
+    mkdir -p $out/{lib,share/extension}
+
+    cp *.so      $out/lib
+    cp *.sql     $out/share/extension
+    cp *.control $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Columnar storage for PostgreSQL";
+    homepage    = https://www.citusdata.com/;
+    maintainers = with maintainers; [ thoughtpolice ];
+    platforms   = platforms.linux;
+    license     = licenses.asl20;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/default.nix b/pkgs/servers/sql/postgresql/default.nix
index cf4519a82327..5d348c129437 100644
--- a/pkgs/servers/sql/postgresql/default.nix
+++ b/pkgs/servers/sql/postgresql/default.nix
@@ -1,8 +1,9 @@
-{ lib, stdenv, fetchurl, zlib, readline, libossp_uuid, openssl }:
+{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper }:
 
 let
 
-  common = { version, sha256, psqlSchema } @ args: stdenv.mkDerivation (rec {
+  common = { version, sha256, psqlSchema } @ args:
+   let atLeast = lib.versionAtLeast version; in stdenv.mkDerivation (rec {
     name = "postgresql-${version}";
 
     src = fetchurl {
@@ -10,36 +11,72 @@ let
       inherit sha256;
     };
 
-    outputs = [ "out" "doc" ];
+    outputs = [ "out" "lib" "doc" "man" ];
+    setOutputFlags = false; # $out retains configureFlags :-/
 
     buildInputs =
-      [ zlib readline openssl ]
+      [ zlib readline openssl libxml2 makeWrapper ]
       ++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
 
     enableParallelBuilding = true;
 
     makeFlags = [ "world" ];
 
-    configureFlags =
-      [ "--with-openssl" ]
+    configureFlags = [
+      "--with-openssl"
+      "--with-libxml"
+      "--sysconfdir=/etc"
+      "--libdir=$(lib)/lib"
+    ]
       ++ lib.optional (stdenv.isDarwin)  "--with-uuid=e2fs"
       ++ lib.optional (!stdenv.isDarwin) "--with-ossp-uuid";
 
     patches =
-      [ (if lib.versionAtLeast version "9.4" then ./disable-resolve_symlinks-94.patch else ./disable-resolve_symlinks.patch)
-        ./less-is-more.patch
+      [ (if atLeast "9.4" then ./disable-resolve_symlinks-94.patch else ./disable-resolve_symlinks.patch)
+        (if atLeast "9.6" then ./less-is-more-96.patch             else ./less-is-more.patch)
+        (if atLeast "9.6" then ./hardcode-pgxs-path-96.patch       else ./hardcode-pgxs-path.patch)
+        ./specify_pkglibdir_at_runtime.patch
       ];
 
     installTargets = [ "install-world" ];
 
     LC_ALL = "C";
 
+    postConfigure =
+      let path = if atLeast "9.6" then "src/common/config_info.c" else "src/bin/pg_config/pg_config.c"; in
+        ''
+          # Hardcode the path to pgxs so pg_config returns the path in $out
+          substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $out/lib
+        '';
+
     postInstall =
       ''
+        moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
+        moveToOutput "lib/*.a" "$out"
+        moveToOutput "lib/libecpg*" "$out"
+
         # Prevent a retained dependency on gcc-wrapper.
-        substituteInPlace $out/lib/pgxs/src/Makefile.global --replace ${stdenv.cc}/bin/ld ld
+        substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv.cc}/bin/ld ld
+
+        if [ -z "''${dontDisableStatic:-}" ]; then
+          # Remove static libraries in case dynamic are available.
+          for i in $out/lib/*.a; do
+            name="$(basename "$i")"
+            if [ -e "$lib/lib/''${name%.a}.so" ] || [ -e "''${i%.a}.so" ]; then
+              rm "$i"
+            fi
+          done
+        fi
       '';
 
+    postFixup = lib.optionalString (!stdenv.isDarwin && stdenv.hostPlatform.libc == "glibc")
+      ''
+        # initdb needs access to "locale" command from glibc.
+        wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
+      '';
+
+    doInstallCheck = false; # needs a running daemon?
+
     disallowedReferences = [ stdenv.cc ];
 
     passthru = {
@@ -47,45 +84,44 @@ let
     };
 
     meta = with lib; {
-      homepage = http://www.postgresql.org/;
+      homepage = https://www.postgresql.org;
       description = "A powerful, open source object-relational database system";
       license = licenses.postgresql;
       maintainers = [ maintainers.ocharles ];
       platforms = platforms.unix;
-      hydraPlatforms = platforms.linux;
     };
   });
 
 in {
 
-  postgresql90 = common {
-    version = "9.0.22";
-    psqlSchema = "9.0";
-    sha256 = "19gq6axjhvlr5zlrzwnll1fbrvai4xh0nb1jki6gmmschl6v5m4l";
+  postgresql93 = common {
+    version = "9.3.22";
+    psqlSchema = "9.3";
+    sha256 = "06p9rk2bav41ybp8ra1bpf44avw9kl5s1wyql21n5awvlm5fs60v";
   };
 
-  postgresql91 = common {
-    version = "9.1.18";
-    psqlSchema = "9.1";
-    sha256 = "1a44hmcvfaa8j169ladsibmvjakw6maaxqkzz1ab8139cqkda9i7";
+  postgresql94 = common {
+    version = "9.4.17";
+    psqlSchema = "9.4";
+    sha256 = "1inpkwbr2xappz3kq3jr3hsn6mwn167nijcx406q8aq56p9hqcks";
   };
 
-  postgresql92 = common {
-    version = "9.2.13";
-    psqlSchema = "9.2";
-    sha256 = "0i3avdr8mnvn6ldkx0hc4jmclhisb2338hzs0j2m03wck8hddjsx";
+  postgresql95 = common {
+    version = "9.5.12";
+    psqlSchema = "9.5";
+    sha256 = "167nlrpsnqz63gafgn21j4yc2f5g1mpfkz8qxjxk2xs6crf6zs02";
   };
 
-  postgresql93 = common {
-    version = "9.3.9";
-    psqlSchema = "9.3";
-    sha256 = "0j85j69rf54cwz5yhrhk4ca22b82990j5sqb8cr1fl9843nd0fzp";
+  postgresql96 = common {
+    version = "9.6.8";
+    psqlSchema = "9.6";
+    sha256 = "0w7bwf19wbdd3jjbjv03cnx56qka4801srcbsayk9v792awv7zga";
   };
 
-  postgresql94 = common {
-    version = "9.4.4";
-    psqlSchema = "9.4";
-    sha256 = "04q07g209y99xzjh88y52qpvz225rxwifv8nzp3bxzfni2bdk3jk";
+  postgresql100 = common {
+    version = "10.3";
+    psqlSchema = "10.0";
+    sha256 = "06lkcwsf851z49zqcws5yc77s2yrbaazf2nvbk38hpp31rw6i8kf";
   };
 
 }
diff --git a/pkgs/servers/sql/postgresql/hardcode-pgxs-path-96.patch b/pkgs/servers/sql/postgresql/hardcode-pgxs-path-96.patch
new file mode 100644
index 000000000000..6cd449769baa
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/hardcode-pgxs-path-96.patch
@@ -0,0 +1,14 @@
+diff -Naur postgresql-9.6.1-orig/src/common/config_info.c postgresql-9.6.1/src/common/config_info.c
+--- postgresql-9.6.1-orig/src/common/config_info.c	2016-11-22 21:39:29.231929261 +0100
++++ postgresql-9.6.1/src/common/config_info.c	2016-11-22 23:36:53.685163543 +0100
+@@ -118,7 +118,10 @@
+ 	i++;
+
+ 	configdata[i].name = pstrdup("PGXS");
++	strlcpy(path, "HARDCODED_PGXS_PATH", sizeof(path));
++/* commented out to be able to point to nix $out path
+ 	get_pkglib_path(my_exec_path, path);
++*/
+ 	strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
+ 	cleanup_path(path);
+ 	configdata[i].setting = pstrdup(path);
diff --git a/pkgs/servers/sql/postgresql/hardcode-pgxs-path.patch b/pkgs/servers/sql/postgresql/hardcode-pgxs-path.patch
new file mode 100644
index 000000000000..355813ffe20e
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/hardcode-pgxs-path.patch
@@ -0,0 +1,17 @@
+--- a/src/bin/pg_config/pg_config.c
++++ b/src/bin/pg_config/pg_config.c
+@@ -220,11 +220,13 @@ show_sysconfdir(bool all)
+ static void
+ show_pgxs(bool all)
+ {
+-	char		path[MAXPGPATH];
++	char		path[MAXPGPATH] = "HARDCODED_PGXS_PATH";
+ 
+ 	if (all)
+ 		printf("PGXS = ");
++  /* commented out to be able to point to nix $out path
+ 	get_pkglib_path(mypath, path);
++  */
+ 	strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
+ 	cleanup_path(path);
+ 	printf("%s\n", path);
diff --git a/pkgs/servers/sql/postgresql/jdbc/default.nix b/pkgs/servers/sql/postgresql/jdbc/default.nix
index ba5a9ead698f..62ebf6b44533 100644
--- a/pkgs/servers/sql/postgresql/jdbc/default.nix
+++ b/pkgs/servers/sql/postgresql/jdbc/default.nix
@@ -1,28 +1,26 @@
-{ stdenv, fetchurl, ant, jdk }:
-
-let version = "9.3-1100"; in
+{ stdenv, fetchMavenArtifact }:
 
 stdenv.mkDerivation rec {
   name = "postgresql-jdbc-${version}";
+  version = "42.2.2";
 
-  src = fetchurl {
-    url = "http://jdbc.postgresql.org/download/postgresql-jdbc-${version}.src.tar.gz";
-    sha256 = "0mbdzhzg4ws0i7ps98rg0q5n68lsrdm2klj7y7skaix0rpa57gp6";
+  src = fetchMavenArtifact {
+    artifactId = "postgresql";
+    groupId = "org.postgresql";
+    sha256 = "0w7sfi1gmzqhyhr4iq9znv8hff41xwwqcblkyd9ph0m34r0555hr";
+    inherit version;
   };
 
-  buildInputs = [ ant jdk ];
-
-  buildPhase = "ant";
+  phases = [ "installPhase" ];
 
-  installPhase =
-    ''
-      mkdir -p $out/share/java
-      cp jars/*.jar $out/share/java
-    '';
+  installPhase = ''
+    install -D $src/share/java/*_postgresql-${version}.jar $out/share/java/postgresql-jdbc.jar
+  '';
 
   meta = with stdenv.lib; {
-    homepage = http://jdbc.postgresql.org/;
+    homepage = https://jdbc.postgresql.org/;
     description = "JDBC driver for PostgreSQL allowing Java programs to connect to a PostgreSQL database";
     license = licenses.bsd3;
+    platforms = platforms.unix;
   };
 }
diff --git a/pkgs/servers/sql/postgresql/less-is-more-96.patch b/pkgs/servers/sql/postgresql/less-is-more-96.patch
new file mode 100644
index 000000000000..f14af9dc2207
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/less-is-more-96.patch
@@ -0,0 +1,12 @@
+diff -Naur postgresql-9.6.1-orig/src/include/fe_utils/print.h postgresql-9.6.1/src/include/fe_utils/print.h
+--- postgresql-9.6.1-orig/src/include/fe_utils/print.h	2016-11-22 21:39:29.148932827 +0100
++++ postgresql-9.6.1/src/include/fe_utils/print.h	2016-11-22 21:39:36.283626258 +0100
+@@ -18,7 +18,7 @@
+ 
+ /* This is not a particularly great place for this ... */
+ #ifndef __CYGWIN__
+-#define DEFAULT_PAGER "more"
++#define DEFAULT_PAGER "less"
+ #else
+ #define DEFAULT_PAGER "less"
+ #endif
diff --git a/pkgs/servers/sql/postgresql/pg_cron/default.nix b/pkgs/servers/sql/postgresql/pg_cron/default.nix
new file mode 100644
index 000000000000..c5a7a40546ef
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pg_cron/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, postgresql }:
+
+stdenv.mkDerivation rec {
+  name = "pg_cron-${version}";
+  version = "1.0.2";
+
+  buildInputs = [ postgresql ];
+
+  src = fetchFromGitHub {
+    owner  = "citusdata";
+    repo   = "pg_cron";
+    rev    = "refs/tags/v${version}";
+    sha256 = "0z743bbal9j0pvqskznfj0zvjsqvdl7p90d4fdrl0sc0crc3nvyx";
+  };
+
+  installPhase = ''
+    mkdir -p $out/{lib,share/extension}
+
+    cp *.so      $out/lib
+    cp *.sql     $out/share/extension
+    cp *.control $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Run Cron jobs through PostgreSQL";
+    homepage    = https://www.citusdata.com/;
+    maintainers = with maintainers; [ thoughtpolice ];
+    platforms   = platforms.linux;
+    license     = licenses.postgresql;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/pg_hll/default.nix b/pkgs/servers/sql/postgresql/pg_hll/default.nix
new file mode 100644
index 000000000000..6c453f6a40c3
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pg_hll/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, postgresql }:
+
+stdenv.mkDerivation rec {
+  name = "pg_hll-${version}";
+  version = "2.10.2-${builtins.substring 0 7 src.rev}";
+
+  buildInputs = [ postgresql ];
+
+  src = fetchFromGitHub {
+    owner  = "citusdata";
+    repo   = "postgresql-hll";
+    rev    = "9af41684d479a3097bab87d04936702c9e6baf5c";
+    sha256 = "044x9v9kjhxb0idqb9f5i7c3yygxxsqliswl4kspqy9f9qcblckl";
+  };
+
+  installPhase = ''
+    mkdir -p $out/{lib,share/extension}
+
+    cp *.so      $out/lib
+    cp *.sql     $out/share/extension
+    cp *.control $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "HyperLogLog for PostgreSQL";
+    homepage    = https://www.citusdata.com/;
+    maintainers = with maintainers; [ thoughtpolice ];
+    platforms   = platforms.linux;
+    license     = licenses.asl20;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/pg_repack/default.nix b/pkgs/servers/sql/postgresql/pg_repack/default.nix
new file mode 100644
index 000000000000..1b7cd08b082b
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pg_repack/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, postgresql, openssl, zlib, readline }:
+
+stdenv.mkDerivation rec {
+    name = "pg_repack-${version}";
+    version = "1.4.3";
+
+    buildInputs = [ postgresql openssl zlib readline ];
+
+    src = fetchFromGitHub {
+      owner  = "reorg";
+      repo   = "pg_repack";
+      rev    = "refs/tags/ver_${version}";
+      sha256 = "1mmd22nfaxjwnbl3i95f3ivmjvfqwdflgaczlg3129dbpwg265xr";
+    };
+
+    installPhase = ''
+      install -D bin/pg_repack -t $out/bin/
+      install -D lib/pg_repack.so -t $out/lib/
+      install -D lib/{pg_repack--${version}.sql,pg_repack.control} -t $out/share/extension
+    '';
+
+    meta = with stdenv.lib; {
+      description = "Reorganize tables in PostgreSQL databases with minimal locks";
+      longDescription = ''
+        pg_repack is a PostgreSQL extension which lets you remove bloat from tables and indexes, and optionally restore
+        the physical order of clustered indexes. Unlike CLUSTER and VACUUM FULL it works online, without holding an
+        exclusive lock on the processed tables during processing. pg_repack is efficient to boot,
+        with performance comparable to using CLUSTER directly.
+      '';
+      license = licenses.bsd3;
+      maintainers = with maintainers; [ danbst ];
+      inherit (postgresql.meta) platforms;
+      inherit (src.meta) homepage;
+    };
+}
diff --git a/pkgs/servers/sql/postgresql/pg_similarity/default.nix b/pkgs/servers/sql/postgresql/pg_similarity/default.nix
new file mode 100644
index 000000000000..32945c9fa62b
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pg_similarity/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, lib, fetchFromGitHub, gcc, postgresql }:
+
+stdenv.mkDerivation {
+
+  name = "pg_similarity-1.0";
+  src = fetchFromGitHub {
+    owner = "eulerto";
+    repo = "pg_similarity";
+    rev = "be1a8b08c8716e59b89982557da9ea68cdf868c5";
+    sha256 = "1z4v4r2yccdr8kz3935fnk1bc5vj0qj0apscldyap4wxlyi89xim";
+  };
+
+  buildInputs = [ postgresql gcc ];
+  buildPhase = "USE_PGXS=1 make";
+  installPhase = ''
+    mkdir -p $out/bin   # for buildEnv to setup proper symlinks
+    install -D pg_similarity.so -t $out/lib/
+    install -D ./{pg_similarity--unpackaged--1.0.sql,pg_similarity--1.0.sql,pg_similarity.control} -t $out/share/extension
+  '';
+
+  meta = {
+    description = ''
+       pg_similarity is an extension to support similarity queries on PostgreSQL. The implementation
+       is tightly integrated in the RDBMS in the sense that it defines operators so instead of the traditional
+       operators (= and <>) you can use ~~~ and ~!~ (any of these operators represents a similarity function).
+    '';
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = with lib.maintainers; [ danbst ];
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/pgjwt/default.nix b/pkgs/servers/sql/postgresql/pgjwt/default.nix
new file mode 100644
index 000000000000..3e01d9bfe2ca
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pgjwt/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub }:
+stdenv.mkDerivation rec {
+  name = "pgjwt-${version}";
+  version = "unstable-2017-04-24";
+  src = fetchFromGitHub {
+    owner = "michelp";
+    repo = "pgjwt";
+    rev = "546a2911027b716586e241be7fd4c6f1785237cd";
+    sha256 = "1riz0xvwb6y02j0fljbr9hcbqb2jqs4njlivmavy9ysbcrrv1vrf";
+  };
+  dontBuild = true;
+  installPhase = ''
+    mkdir -p $out/bin  # current postgresql extension mechanism in nixos requires bin directory
+    mkdir -p $out/share/extension
+    cp pg*sql *.control $out/share/extension
+  '';
+  meta = with stdenv.lib; {
+    description = "PostgreSQL implementation of JSON Web Tokens";
+    longDescription = ''
+      sign() and verify() functions to create and verify JSON Web Tokens.
+    '';
+    license = licenses.mit;
+    maintainers = with maintainers; [spinus];
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/pgroonga/default.nix b/pkgs/servers/sql/postgresql/pgroonga/default.nix
new file mode 100644
index 000000000000..6dcd19d8d680
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pgroonga/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, pkgconfig, postgresql, libmsgpack, groonga }:
+
+stdenv.mkDerivation rec {
+  name = "pgroonga-${version}";
+  version = "2.0.6";
+
+  src = fetchurl {
+    url = "http://packages.groonga.org/source/pgroonga/${name}.tar.gz";
+    sha256 = "1hfmz3d0xwhsa4vw8i08s15i7pfd0h0smi2rv663x3cjjjn40i68";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ postgresql libmsgpack groonga ];
+
+  makeFlags = [ "HAVE_MSGPACK=1" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install -D pgroonga.so -t $out/lib/
+    install -D ./{pgroonga-*.sql,pgroonga.control} -t $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A PostgreSQL extension to use Groonga as the index";
+    longDescription = "PGroonga is a PostgreSQL extension to use Groonga as the index. PostgreSQL supports full text search against languages that use only alphabet and digit. It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on. You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL.";
+    homepage = https://pgroonga.github.io/;
+    license = licenses.postgresql;
+    maintainers = with maintainers; [ DerTim1 ];
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/pgtap/default.nix b/pkgs/servers/sql/postgresql/pgtap/default.nix
new file mode 100644
index 000000000000..1206e50926ed
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/pgtap/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, postgresql, perl, perlPackages, which }:
+
+stdenv.mkDerivation rec {
+  name = "pgtap-${version}";
+  version = "0.98.0";
+
+  src = fetchFromGitHub {
+    owner = "theory";
+    repo = "pgtap";
+    rev = "v${version}";
+    sha256 = "17r3b409k05pbypmwdwgm1fl669jc6a1391szyxizx784k44a369";
+  };
+
+  nativeBuildInputs = [ postgresql perl perlPackages.TAPParserSourceHandlerpgTAP which ];
+
+  installPhase = ''
+    install -D {sql/pgtap--${version}.sql,pgtap.control} -t $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "pgTAP is a unit testing framework for PostgreSQL";
+    longDescription = ''
+      pgTAP is a unit testing framework for PostgreSQL written in PL/pgSQL and PL/SQL.
+      It includes a comprehensive collection of TAP-emitting assertion functions,
+      as well as the ability to integrate with other TAP-emitting test frameworks.
+      It can also be used in the xUnit testing style.
+    '';
+    maintainers = with maintainers; [ willibutz ];
+    homepage = http://pgtap.org;
+    inherit (postgresql.meta) platforms;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/plv8/default.nix b/pkgs/servers/sql/postgresql/plv8/default.nix
new file mode 100644
index 000000000000..009f65b9d81c
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/plv8/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, v8, perl, postgresql }:
+
+stdenv.mkDerivation rec {
+  name = "plv8-${version}";
+  version = "2.1.0";
+
+  nativeBuildInputs = [ perl ];
+  buildInputs = [ v8 postgresql ];
+
+  src = fetchFromGitHub {
+    owner = "plv8";
+    repo = "plv8";
+    rev = "v${version}";
+    sha256 = "1sfpxz0zcbinn6822j12lkwgrw9kfacrs83ic968rm489rl9w241";
+  };
+
+  preConfigure = ''
+    substituteInPlace Makefile --replace '-lv8_libplatform' '-lv8_libplatform -lv8_libbase'
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install -D plv8.so                                         -t $out/lib
+    install -D {plls,plcoffee,plv8}{--${version}.sql,.control} -t $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "PL/v8 - A Procedural Language in JavaScript powered by V8";
+    homepage = https://pgxn.org/dist/plv8/;
+    maintainers = with maintainers; [ volth ];
+    platforms = platforms.linux;
+    license = licenses.postgresql;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/psqlodbc/default.nix b/pkgs/servers/sql/postgresql/psqlodbc/default.nix
index 72221c0eec01..111b1be80f81 100644
--- a/pkgs/servers/sql/postgresql/psqlodbc/default.nix
+++ b/pkgs/servers/sql/postgresql/psqlodbc/default.nix
@@ -16,5 +16,6 @@ stdenv.mkDerivation rec {
     homepage = http://psqlodbc.projects.postgresql.org/;
     description = "ODBC driver for PostgreSQL";
     license = licenses.lgpl2;
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/servers/sql/postgresql/specify_pkglibdir_at_runtime.patch b/pkgs/servers/sql/postgresql/specify_pkglibdir_at_runtime.patch
new file mode 100644
index 000000000000..fe95d2ee99f0
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/specify_pkglibdir_at_runtime.patch
@@ -0,0 +1,29 @@
+diff -ur postgresql-9.5.3-orig/src/port/path.c postgresql-9.5.3/src/port/path.c
+--- postgresql-9.5.3-orig/src/port/path.c	2016-05-09 22:50:23.000000000 +0200
++++ postgresql-9.5.3/src/port/path.c	2016-08-29 22:44:10.507377613 +0200
+@@ -714,7 +714,11 @@
+ void
+ get_lib_path(const char *my_exec_path, char *ret_path)
+ {
+-	make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path);
++	char const * const nix_pglibdir = getenv("NIX_PGLIBDIR");
++	if(nix_pglibdir == NULL)
++		make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path);
++	else
++		make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path);
+ }
+ 
+ /*
+@@ -723,7 +727,11 @@
+ void
+ get_pkglib_path(const char *my_exec_path, char *ret_path)
+ {
+-	make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path);
++	char const * const nix_pglibdir = getenv("NIX_PGLIBDIR");
++	if(nix_pglibdir == NULL)
++		make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path);
++	else
++		make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path);
+ }
+ 
+ /*
diff --git a/pkgs/servers/sql/postgresql/timescaledb/default.nix b/pkgs/servers/sql/postgresql/timescaledb/default.nix
new file mode 100644
index 000000000000..ce298cb2745d
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/timescaledb/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, cmake, postgresql }:
+
+# # To enable on NixOS:
+# config.services.postgresql = {
+#   extraPlugins = [ pkgs.timescaledb ];
+#   extraConfig = "shared_preload_libraries = 'timescaledb'";
+# }
+
+stdenv.mkDerivation rec {
+  name = "timescaledb-${version}";
+  version = "0.9.2";
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ postgresql ];
+
+  src = fetchFromGitHub {
+    owner  = "timescale";
+    repo   = "timescaledb";
+    rev    = "refs/tags/${version}";
+    sha256 = "1zgyd407skqbsw2zj3l9hixwlisnj82yb6hbq5khjg9k0ifvvgyp";
+  };
+
+  # Fix the install phase which tries to install into the pgsql extension dir,
+  # and cannot be manually overridden. This is rather fragile but works OK.
+  patchPhase = ''
+    for x in CMakeLists.txt sql/CMakeLists.txt; do
+      substituteInPlace "$x" \
+        --replace 'DESTINATION "''${PG_SHAREDIR}/extension"' "DESTINATION \"$out/share/extension\""
+    done
+
+    for x in src/CMakeLists.txt src/loader/CMakeLists.txt; do
+      substituteInPlace "$x" \
+        --replace 'DESTINATION ''${PG_PKGLIBDIR}' "DESTINATION \"$out/lib\""
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Scales PostgreSQL for time-series data via automatic partitioning across time and space";
+    homepage    = https://www.timescale.com/;
+    maintainers = with maintainers; [ volth ];
+    platforms   = platforms.linux;
+    license     = licenses.postgresql;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/topn/default.nix b/pkgs/servers/sql/postgresql/topn/default.nix
new file mode 100644
index 000000000000..6886c80cf50d
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/topn/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, postgresql, protobufc }:
+
+stdenv.mkDerivation rec {
+  name = "pg_topn-${version}";
+  version = "2.0.2";
+
+  nativeBuildInputs = [ protobufc ];
+  buildInputs = [ postgresql ];
+
+  src = fetchFromGitHub {
+    owner  = "citusdata";
+    repo   = "postgresql-topn";
+    rev    = "refs/tags/v${version}";
+    sha256 = "00hc3hgnqv9xaalizbcvprb7s55sydj2qgk3rhgrdlwg2g025h62";
+  };
+
+  installPhase = ''
+    mkdir -p $out/{lib,share/extension}
+
+    cp *.so      $out/lib
+    cp *.sql     $out/share/extension
+    cp *.control $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Efficient querying of 'top values' for PostgreSQL";
+    homepage    = https://www.citusdata.com/;
+    maintainers = with maintainers; [ thoughtpolice ];
+    platforms   = platforms.linux;
+    license     = licenses.agpl3;
+  };
+}
diff --git a/pkgs/servers/sql/postgresql/tsearch_extras/default.nix b/pkgs/servers/sql/postgresql/tsearch_extras/default.nix
new file mode 100644
index 000000000000..5140ae1a228f
--- /dev/null
+++ b/pkgs/servers/sql/postgresql/tsearch_extras/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, pkgconfig, postgresql }:
+
+stdenv.mkDerivation rec {
+  name = "tsearch-extras-${version}";
+  version = "0.3";
+
+  src = fetchFromGitHub {
+    owner = "zulip";
+    repo = "tsearch_extras";
+    rev = version;
+    sha256 = "0i3i99lw80jwd4xflgdqabxmn1dnm1gm7dzf1mqv2drllxcy3yix";
+  };
+
+  nativenativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ postgresql ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install -D tsearch_extras.so -t $out/lib/
+    install -D ./{tsearch_extras--1.0.sql,tsearch_extras.control} -t $out/share/extension
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Provides a few PostgreSQL functions for a lower-level data full text search";
+    homepage = https://github.com/zulip/tsearch_extras/;
+    license = licenses.postgresql;
+    maintainers = with maintainers; [ DerTim1 ];
+  };
+}
diff --git a/pkgs/servers/sql/sqlite/jdbc/default.nix b/pkgs/servers/sql/sqlite/jdbc/default.nix
new file mode 100644
index 000000000000..5b0425c410fc
--- /dev/null
+++ b/pkgs/servers/sql/sqlite/jdbc/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "3.20.0";
+  pname = "sqlite-jdbc";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "https://bitbucket.org/xerial/${pname}/downloads/${name}.jar";
+    sha256 = "0wxfxnq2ghiwy2mwz3rljgmy1lciafhrw80lprvqz6iw8l51qfql";
+  };
+
+  phases = [ "installPhase" ];
+
+  installPhase = ''
+    install -D "${src}" "$out/share/java/${name}.jar"
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/xerial/sqlite-jdbc";
+    description = "SQLite JDBC Driver";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ jraygauthier ];
+  };
+}
+
diff --git a/pkgs/servers/sql/virtuoso/6.x.nix b/pkgs/servers/sql/virtuoso/6.x.nix
index 4de0ace0c03a..b0b8f926d9ec 100644
--- a/pkgs/servers/sql/virtuoso/6.x.nix
+++ b/pkgs/servers/sql/virtuoso/6.x.nix
@@ -8,28 +8,38 @@ stdenv.mkDerivation rec {
     sha256 = "0dx0lp7cngdchi0772hp93zzn6sdap7z8s3vay3mzb9xgf0sdgy6";
   };
 
+  outputs = [ "out" "dev" "doc" ];
+
   buildInputs = [ libxml2 openssl readline gawk ];
 
   CPP = "${stdenv.cc}/bin/gcc -E";
 
   configureFlags = "
-    --enable-shared --disable-all-vads --with-readline=${readline}
+    --enable-shared --disable-all-vads --with-readline=${readline.dev}
     --disable-hslookup --disable-wbxml2 --without-iodbc
-    --enable-openssl=${openssl}
+    --enable-openssl=${openssl.dev}
     ";
 
-  postInstall=''
+  postInstall = ''
     echo Moving documentation
     mkdir -pv $out/share/doc
     mv -v $out/share/virtuoso/doc $out/share/doc/${name}
+
     echo Removing jars and empty directories
     find $out -name "*.a" -delete -o -name "*.jar" -delete -o -type d -empty -delete
-    '';
-  
+
+    for f in $out/lib/*.la; do
+      echo "Fixing $f"
+      substituteInPlace $f \
+        --replace "${readline.dev}" "${readline.out}/lib" \
+        --replace "${openssl.dev}/lib" "${openssl.out}/lib"
+    done
+  '';
+
   meta = with stdenv.lib; {
     description = "SQL/RDF database used by, e.g., KDE-nepomuk";
     homepage = http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/;
-    platforms = platforms.all;
-    maintainers = [ maintainers.urkud ];
+    platforms = platforms.linux;
+    maintainers = [ ];
   };
 }
diff --git a/pkgs/servers/sql/virtuoso/7.x.nix b/pkgs/servers/sql/virtuoso/7.x.nix
index de610f9a7294..bf2a51f65963 100644
--- a/pkgs/servers/sql/virtuoso/7.x.nix
+++ b/pkgs/servers/sql/virtuoso/7.x.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, libxml2, openssl, readline, gawk }:
 
 stdenv.mkDerivation rec {
-  name = "virtuoso-opensource-7.0.0";
+  name = "virtuoso-opensource-7.2.4.2";
 
   src = fetchurl {
     url = "mirror://sourceforge/virtuoso/${name}.tar.gz";
-    sha256 = "1z0jdzayv45y57jj8kii6csqfjhswcs8s2krqqfhab54xy6gynbl";
+    sha256 = "12dqam1gc1v93l0bj0vlpvjqppki6y1hqrlznywxnw0rrz9pb002";
   };
 
   buildInputs = [ libxml2 openssl readline gawk ];
@@ -13,9 +13,9 @@ stdenv.mkDerivation rec {
   CPP = "${stdenv.cc}/bin/gcc -E";
 
   configureFlags = "
-    --enable-shared --disable-all-vads --with-readline=${readline}
+    --enable-shared --disable-all-vads --with-readline=${readline.dev}
     --disable-hslookup --disable-wbxml2 --without-iodbc
-    --enable-openssl=${openssl}
+    --enable-openssl=${openssl.dev}
     ";
 
   postInstall=''
@@ -29,8 +29,8 @@ stdenv.mkDerivation rec {
   meta = with stdenv.lib; {
     description = "SQL/RDF database used by, e.g., KDE-nepomuk";
     homepage = http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/;
-    #configure: The current version [...] can only be build on 64bit platforms
-    platforms = [ "x86_64-linux" "x86_64-darwin" ];
-    maintainers = [ maintainers.urkud ];
+    #configure: The current version [...] can only be built on 64bit platforms
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ ];
   };
 }
diff --git a/pkgs/servers/squid/4.nix b/pkgs/servers/squid/4.nix
new file mode 100644
index 000000000000..4c76173a280e
--- /dev/null
+++ b/pkgs/servers/squid/4.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, perl, openldap, pam, db, cyrus_sasl, libcap
+, expat, libxml2, openssl }:
+
+stdenv.mkDerivation rec {
+  name = "squid-4.0.24";
+
+  src = fetchurl {
+    url = "http://www.squid-cache.org/Versions/v4/${name}.tar.xz";
+    sha256 = "01vayx86sakfy9zz2q5cvzv97865l1zb0jkqbh7wqz9hcgbs0789";
+  };
+
+  buildInputs = [
+    perl openldap db cyrus_sasl expat libxml2 openssl
+  ] ++ stdenv.lib.optionals stdenv.isLinux [ libcap pam ];
+
+  prePatch = ''
+    substituteInPlace configure --replace "/usr/local/include/libxml2" "${libxml2.dev}/include/libxml2"
+  '';
+
+  configureFlags = [
+    "--enable-ipv6"
+    "--disable-strict-error-checking"
+    "--disable-arch-native"
+    "--with-openssl"
+    "--enable-ssl-crtd"
+    "--enable-storeio=ufs,aufs,diskd,rock"
+    "--enable-removal-policies=lru,heap"
+    "--enable-delay-pools"
+    "--enable-x-accelerator-vary"
+  ] ++ stdenv.lib.optional (stdenv.isLinux && !stdenv.hostPlatform.isMusl) "--enable-linux-netfilter";
+
+  meta = with stdenv.lib; {
+    description = "A caching proxy for the Web supporting HTTP, HTTPS, FTP, and more";
+    homepage = http://www.squid-cache.org;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ fpletz raskin ];
+  };
+}
diff --git a/pkgs/servers/squid/default.nix b/pkgs/servers/squid/default.nix
new file mode 100644
index 000000000000..8d39fbbcef44
--- /dev/null
+++ b/pkgs/servers/squid/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchurl, fetchpatch, perl, openldap, pam, db, cyrus_sasl, libcap
+, expat, libxml2, openssl }:
+
+stdenv.mkDerivation rec {
+  name = "squid-3.5.27";
+
+  src = fetchurl {
+    url = "http://www.squid-cache.org/Versions/v3/3.5/${name}.tar.xz";
+    sha256 = "1v7hzvwwghrs751iag90z8909nvyp3c5jynaz4hmjqywy9kl7nsx";
+  };
+
+  buildInputs = [
+    perl openldap db cyrus_sasl expat libxml2 openssl
+  ] ++ stdenv.lib.optionals stdenv.isLinux [ libcap pam ];
+
+  patches = [
+    (fetchpatch {
+      name = "CVE-2018-1000024.patch";
+      url = http://www.squid-cache.org/Versions/v3/3.5/changesets/SQUID-2018_1.patch;
+      sha256 = "0vzxr4rmybz0w4c1hi3szvqawbzl4r4b8wyvq9vgq1mzkk5invpg";
+    })
+    (fetchpatch {
+      name = "CVE-2018-1000027.patch";
+      url = http://www.squid-cache.org/Versions/v3/3.5/changesets/SQUID-2018_2.patch;
+      sha256 = "1a8hwk9z7h1j0c57anfzp3bwjd4pjbyh8aks4ca79nwz4d0y6wf3";
+    })
+  ];
+
+  configureFlags = [
+    "--enable-ipv6"
+    "--disable-strict-error-checking"
+    "--disable-arch-native"
+    "--with-openssl"
+    "--enable-ssl-crtd"
+    "--enable-storeio=ufs,aufs,diskd,rock"
+    "--enable-removal-policies=lru,heap"
+    "--enable-delay-pools"
+    "--enable-x-accelerator-vary"
+  ] ++ stdenv.lib.optional (stdenv.isLinux && !stdenv.hostPlatform.isMusl) "--enable-linux-netfilter";
+
+  meta = with stdenv.lib; {
+    description = "A caching proxy for the Web supporting HTTP, HTTPS, FTP, and more";
+    homepage = http://www.squid-cache.org;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ fpletz ];
+  };
+}
diff --git a/pkgs/servers/squid/squids.nix b/pkgs/servers/squid/squids.nix
deleted file mode 100644
index 35aea7aa1308..000000000000
--- a/pkgs/servers/squid/squids.nix
+++ /dev/null
@@ -1,67 +0,0 @@
-args @ { fetchurl, stdenv, perl, lib, composableDerivation
-, openldap, pam, db, cyrus_sasl, kerberos, libcap, expat, libxml2, libtool
-, openssl, ... }: with args;
-let edf = composableDerivation.edf; in
-rec {
-  squid30 = composableDerivation.composableDerivation {} {
-    name = "squid-3.0-stable26";
-
-    buildInputs = [perl];
-
-    src = args.fetchurl {
-      url = http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE26.tar.bz2;
-      sha256 = "3e54ae3ad09870203862f0856c7d0cca16a85f62d5012085009003ee3d5467b4";
-    };
-
-    configureFlags = ["--enable-ipv6" "--disable-strict-error-checking" "--disable-arch-native"];
-
-    meta = {
-      description = "http-proxy";
-      homepage = "http://www.squid-cache.org";
-      license = stdenv.lib.licenses.gpl2;
-    };
-
-  };
-
-  squid31 = squid30.merge {
-    name = "squid-3.1.23";
-    src = args.fetchurl {
-      url = http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.23.tar.bz2;
-      sha256 = "13g4y0gg48xnlzrvpymb08gh25xi50y383faapkxws7i7v94305s";
-    };
-  };
-
-  squid32 = squid30.merge rec {
-    name = "squid-3.2.13";
-    src = args.fetchurl {
-      url = "http://www.squid-cache.org/Versions/v3/3.2/${name}.tar.bz2";
-      sha256 = "0dafqv00dr3nyrm9k47d6r7gv2r3f9hjd1ykl3kkvjca11r4n54j";
-    };
-    buildInputs = [openldap pam db cyrus_sasl libcap expat libxml2
-      libtool openssl];
-  };
-
-  squid34 = squid30.merge rec {
-    name = "squid-3.4.11";
-    src = args.fetchurl {
-      url = "http://www.squid-cache.org/Versions/v3/3.4/${name}.tar.bz2";
-      sha256 = "0p9dbsz541cpcc88albwpgq15jgpczv12j9b9g5xw6d3i977qm1h";
-    };
-    buildInputs = [openldap pam db cyrus_sasl libcap expat libxml2
-      libtool openssl];
-    configureFlags = ["--enable-ssl" "--enable-ssl-crtd"];
-  };
-
-  squid35 = squid30.merge rec {
-    name = "squid-3.5.1";
-    src = args.fetchurl {
-      url = "http://www.squid-cache.org/Versions/v3/3.5/${name}.tar.bz2";
-      sha256 = "0rfv1v5vkk7l08v4j16l0lz2grrzd8qf2n25i73qd7c8rgwd6a3x";
-    };
-    buildInputs = [openldap pam db cyrus_sasl libcap expat libxml2
-      libtool openssl];
-    configureFlags = ["--with-openssl" "--enable-ssl-crtd"];
-  };
-
-  latest = squid35;
-}
diff --git a/pkgs/servers/sslh/default.nix b/pkgs/servers/sslh/default.nix
index 0de4dfff153f..bbb9b6ca5191 100644
--- a/pkgs/servers/sslh/default.nix
+++ b/pkgs/servers/sslh/default.nix
@@ -1,17 +1,17 @@
-{ stdenv, fetchurl, libcap, libconfig, perl, tcp_wrappers }:
+{ stdenv, fetchurl, libcap, libconfig, perl, tcp_wrappers, pcre }:
 
 stdenv.mkDerivation rec {
   name = "sslh-${version}";
-  version = "1.17";
+  version = "1.19c";
 
   src = fetchurl {
-    url = "https://github.com/yrutschle/sslh/archive/v${version}.tar.gz";
-    sha256 = "1l8ssm47f0hwiisgfj0ca5j2z8j98pir4pf2acrj1798fnzw6mxm";
+    url = "http://www.rutschle.net/tech/sslh/sslh-v${version}.tar.gz";
+    sha256 = "1wvvqj9r293skgqi28q4ixz7zwf301h1bf514p41xbi7ifldy4dv";
   };
 
   postPatch = "patchShebangs *.sh";
 
-  buildInputs = [ libcap libconfig perl tcp_wrappers ];
+  buildInputs = [ libcap libconfig perl tcp_wrappers pcre ];
 
   makeFlags = "USELIBCAP=1 USELIBWRAP=1";
 
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
     description = "Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)";
     license = licenses.gpl2Plus;
     homepage = http://www.rutschle.net/tech/sslh.shtml;
-    maintainers = [ maintainers.koral ];
+    maintainers = with maintainers; [ koral fpletz ];
     platforms = platforms.all;
   };
 }
diff --git a/pkgs/servers/teleport/default.nix b/pkgs/servers/teleport/default.nix
new file mode 100644
index 000000000000..0f08d94a052f
--- /dev/null
+++ b/pkgs/servers/teleport/default.nix
@@ -0,0 +1,41 @@
+# This file was generated by https://github.com/kamilchm/go2nix v2.0-dev
+{ stdenv, buildGoPackage, zip, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "teleport-${version}";
+  version = "2.4.1";
+
+  # This repo has a private submodule "e" which fetchgit cannot handle without failing.
+  src = fetchFromGitHub {
+    owner = "gravitational";
+    repo = "teleport";
+    rev = "v${version}";
+    sha256 = "09kmlihv4aqc39f9cyv2vm0kqgdf9vmdrgds5krnzqdgy3svyg7y";
+  };
+
+  goPackagePath = "github.com/gravitational/teleport";
+  subPackages = [ "tool/tctl" "tool/teleport" "tool/tsh" ];
+  buildInputs = [ zip ];
+  postBuild = ''
+    pushd .
+    cd $NIX_BUILD_TOP/go/src/github.com/gravitational/teleport
+    mkdir -p build
+    echo "making webassets"
+    make build/webassets.zip
+    cat build/webassets.zip >> $NIX_BUILD_TOP/go/bin/teleport
+    rm -fr build/webassets.zip
+    cd $NIX_BUILD_TOP/go/bin
+    zip -q -A teleport
+    popd
+    '';
+
+  dontStrip = true;
+
+  meta = {
+    description = "A SSH CA management suite";
+    homepage = "https://gravitational.com/teleport/";
+    license = stdenv.lib.licenses.asl20;
+    maintainers = [ stdenv.lib.maintainers.tomberek ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/pkgs/servers/traefik/default.nix b/pkgs/servers/traefik/default.nix
new file mode 100644
index 000000000000..1ed50a65e91a
--- /dev/null
+++ b/pkgs/servers/traefik/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, buildGoPackage, fetchFromGitHub, bash, go-bindata}:
+
+buildGoPackage rec {
+  name = "traefik-${version}";
+  version = "1.6.2";
+
+  goPackagePath = "github.com/containous/traefik";
+
+  src = fetchFromGitHub {
+    owner = "containous";
+    repo = "traefik";
+    rev = "v${version}";
+    sha256 = "1gklji9zwdprvv7fvy7rhgazfslwsyjq97w193v9dpsriz1rk5qa";
+  };
+
+  buildInputs = [ go-bindata bash ];
+
+  buildPhase = ''
+    runHook preBuild
+    (
+      cd go/src/github.com/containous/traefik
+      bash ./script/make.sh generate
+
+      CODENAME=$(awk -F "=" '/CODENAME=/ { print $2}' script/binary)
+      go build -ldflags "\
+        -X github.com/containous/traefik/version.Version=${version} \
+        -X github.com/containous/traefik/version.Codename=$CODENAME \
+      " -a -o $bin/bin/traefik ./cmd/traefik
+    )
+    runHook postBuild
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://traefik.io;
+    description = "A modern reverse proxy";
+    license = licenses.mit;
+    maintainers = with maintainers; [ hamhut1066 vdemeester ];
+  };
+}
diff --git a/pkgs/servers/trezord/default.nix b/pkgs/servers/trezord/default.nix
new file mode 100644
index 000000000000..a3c505646214
--- /dev/null
+++ b/pkgs/servers/trezord/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "trezord-go-${version}";
+  version = "2.0.12";
+
+  # Fixes Cgo related build failures (see https://github.com/NixOS/nixpkgs/issues/25959 )
+  hardeningDisable = [ "fortify" ];
+
+  goPackagePath = "github.com/trezor/trezord-go";
+
+  src = fetchFromGitHub {
+    owner  = "trezor";
+    repo   = "trezord-go";
+    rev    = "v${version}";
+    sha256 = "03pz223jjfbd0g9gkk21q6d27jc8vd1bc1jz00i0f3dzvsyfx5g6";
+  };
+
+  meta = with stdenv.lib; {
+    description = "TREZOR Communication Daemon aka TREZOR Bridge";
+    homepage = https://mytrezor.com;
+    license = licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ canndrew jb55 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/servers/tt-rss/default.nix b/pkgs/servers/tt-rss/default.nix
new file mode 100644
index 000000000000..6f584bfabd3d
--- /dev/null
+++ b/pkgs/servers/tt-rss/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "tt-rss-${version}";
+  version = "2018-04-05";
+  rev = "963c22646b3e1bd544bd957bf34175b996bd6e53";
+
+  src = fetchurl {
+    url = "https://git.tt-rss.org/git/tt-rss/archive/${rev}.tar.gz";
+    sha256 = "02vjw5cag5x0rpiqalfrqf7iz21rp8ml5wnfd8pdkxbr8182bw3h";
+  };
+
+  installPhase = ''
+    mkdir $out
+    cp -ra * $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Web-based news feed (RSS/Atom) aggregator";
+    license = licenses.gpl2Plus;
+    homepage = http://tt-rss.org;
+    maintainers = with maintainers; [ globin zohl ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/tvheadend/default.nix b/pkgs/servers/tvheadend/default.nix
index c7b4e5153176..c0a3b5a28c31 100644
--- a/pkgs/servers/tvheadend/default.nix
+++ b/pkgs/servers/tvheadend/default.nix
@@ -1,35 +1,66 @@
-{avahi, dbus, fetchurl, git, gzip, libav, libiconv, openssl, pkgconfig, python
-, stdenv, which, zlib}:
+{ stdenv, fetchFromGitHub, cmake, makeWrapper, pkgconfig
+, avahi, dbus, gettext, git, gnutar, gzip, bzip2, ffmpeg, libiconv, openssl, python
+, which, zlib }:
 
-let version = "4.0.4";
-    pkgName = "tvheadend"; in
+let
+  version = "4.2.6";
 
-stdenv.mkDerivation rec {
-  name = "${pkgName}-${version}";
+in stdenv.mkDerivation rec {
+  name = "tvheadend-${version}";
 
-  src = fetchurl {
-    url = "https://github.com/tvheadend/tvheadend/archive/v${version}.tar.gz";
-    sha256 = "acc5c852bccb32d6a281f523e78a1cceb4d41987fe015aba3f66e1898b02c168";
+  src = fetchFromGitHub {
+    owner  = "tvheadend";
+    repo   = "tvheadend";
+    rev    = "v${version}";
+    sha256 = "0rnhk0r34mfmz3cnf735nzkkyal7pnv16hfyrs0g4v5rk99rlab3";
   };
 
+  buildInputs = [
+    avahi dbus gettext git gnutar gzip bzip2 ffmpeg libiconv openssl python
+    which zlib
+  ];
+
+  nativeBuildInputs = [ cmake makeWrapper pkgconfig ];
+
   enableParallelBuilding = true;
 
-  configureFlags = [ "--disable-dvbscan" ];
+  # disable dvbscan, as having it enabled causes a network download which
+  # cannot happen during build.
+  configureFlags = [
+    "--disable-dvbscan"
+    "--disable-bintray_cache"
+    "--disable-ffmpeg_static"
+    "--disable-hdhomerun_client"
+    "--disable-hdhomerun_static"
+  ];
+
+  dontUseCmakeConfigure = true;
+
+  preConfigure = ''
+    patchShebangs ./configure
+
+    substituteInPlace src/config.c \
+      --replace /usr/bin/tar ${gnutar}/bin/tar
 
-  buildInputs = [ avahi dbus git gzip libav libiconv openssl pkgconfig python
-    which zlib ];
+    # the version detection script `support/version` reads this file if it
+    # exists, so let's just use that
+    echo ${version} > rpm/version
+  '';
 
-  preConfigure = "patchShebangs ./configure";
+  postInstall = ''
+    wrapProgram $out/bin/tvheadend \
+      --prefix PATH : ${stdenv.lib.makeBinPath [ bzip2 ]}
+  '';
 
-  meta = {
-    description = "TV steaming server";
+  meta = with stdenv.lib; {
+    description = "TV streaming server";
     longDescription = ''
-	Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android 
+	Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android
         supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, IPTV, SAT>IP and HDHomeRun as input sources.
 	Tvheadend offers the HTTP (VLC, MPlayer), HTSP (Kodi, Movian) and SAT>IP streaming.'';
-    homepage = "https://tvheadend.org";
-    license = stdenv.lib.licenses.gpl3;
-    platforms = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.simonvandel ];
+    homepage = https://tvheadend.org;
+    license = licenses.gpl3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ simonvandel ];
   };
 }
diff --git a/pkgs/servers/u9fs/default.nix b/pkgs/servers/u9fs/default.nix
index e60a74eaf89f..b42fe004af33 100644
--- a/pkgs/servers/u9fs/default.nix
+++ b/pkgs/servers/u9fs/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
     { description = "Serve 9P from Unix";
       homepage = http://plan9.bell-labs.com/magic/man2html/4/u9fs;
       license = licenses.free;
-      maintainers = [ maintainers.emery ];
+      maintainers = [ maintainers.ehmry ];
       platforms = platforms.unix;
     };
 }
diff --git a/pkgs/servers/udpt/default.nix b/pkgs/servers/udpt/default.nix
new file mode 100644
index 000000000000..9e9816c941d9
--- /dev/null
+++ b/pkgs/servers/udpt/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchFromGitHub, boost, sqlite, cmake, gtest }:
+
+stdenv.mkDerivation rec {
+  name = "udpt-${version}";
+  version = "2017-09-27";
+
+  enableParallelBuilding = true;
+
+  # Suitable for a network facing daemon.
+  hardeningEnable = [ "pie" ];
+
+  src = fetchFromGitHub {
+    owner = "naim94a";
+    repo = "udpt";
+    rev = "e0dffc83c8ce76b08a41a4abbd5f8065535d534f";
+    sha256 = "187dw96mzgcmh4k9pvfpb7ckbb8d4vlikamr2x8vkpwzgjs3xd6g";
+  };
+
+  doCheck = true;
+
+  checkPhase = ''
+    runHook preCheck
+
+    make test
+
+    runHook postCheck
+  '';
+
+  buildInputs = [ boost sqlite cmake gtest ];
+
+  postPatch = ''
+    # Enabling optimization (implied by fortify hardening) causes htons
+    # to be re-defined as a macro, turning this use of :: into a syntax error.
+    sed -i '104a#undef htons' src/udpTracker.cpp
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/etc/
+    cp udpt $out/bin
+    cp ../udpt.conf $out/etc/
+    # without this, the resulting binary is unstripped.
+    runHook postInstall
+  '';
+
+  meta = {
+    description = "A lightweight UDP torrent tracker";
+    homepage = https://naim94a.github.io/udpt;
+    license = stdenv.lib.licenses.gpl3;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ makefu ];
+  };
+}
diff --git a/pkgs/servers/uftp/default.nix b/pkgs/servers/uftp/default.nix
new file mode 100644
index 000000000000..a484e0382104
--- /dev/null
+++ b/pkgs/servers/uftp/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, openssl }:
+
+stdenv.mkDerivation rec {
+  name = "uftp-${version}";
+  version = "4.9.7";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/uftp-multicast/source-tar/uftp-${version}.tar.gz";
+    sha256 = "1gh1zpc6dh690xjhfp5x2ajhwjkchyh5wazr8agm6axxwqhd9gn8";
+  };
+
+  buildInputs = [ openssl ];
+
+  outputs = [ "out" "man" ];
+
+  patchPhase = ''
+    substituteInPlace makefile --replace gcc cc
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $man/share/man/man1
+    cp {uftp,uftpd,uftp_keymgt,uftpproxyd} $out/bin/
+    cp {uftp.1,uftpd.1,uftp_keymgt.1,uftpproxyd.1} $man/share/man/man1
+  '';
+
+  meta = {
+    description = "Encrypted UDP based FTP with multicast";
+    homepage = http://uftp-multicast.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.fadenb ];
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/pkgs/servers/uhub/default.nix b/pkgs/servers/uhub/default.nix
index a6e0d474d897..0ccf4c5bd0be 100644
--- a/pkgs/servers/uhub/default.nix
+++ b/pkgs/servers/uhub/default.nix
@@ -3,30 +3,38 @@
 
 assert tlsSupport -> openssl != null;
 
-let version = "0.4.1"; in
-stdenv.mkDerivation {
+stdenv.mkDerivation rec {
   name = "uhub-${version}";
+  version = "0.5.0";
 
   src = fetchurl {
     url = "http://www.extatic.org/downloads/uhub/uhub-${version}-src.tar.bz2";
-    sha256 = "1q0n74fb0h5w0k9fhfkznxb4r46qyfb8g2ss3wflivx4l0m1f9x2";
+    sha256 = "1xcqjz20lxikzn96f4f69mqyl9y985h9g0gyc9f7ckj18q22b5j5";
   };
 
-  buildInputs = [ cmake sqlite pkgconfig systemd ] ++ stdenv.lib.optional tlsSupport openssl;
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ cmake sqlite systemd ] ++ stdenv.lib.optional tlsSupport openssl;
 
   outputs = [ "out"
     "mod_example"
     "mod_welcome"
     "mod_logging"
     "mod_auth_simple"
-    "mod_auth_sqlite"
     "mod_chat_history"
     "mod_chat_only"
     "mod_topic"
     "mod_no_guest_downloads"
   ];
 
-  patches = [ ./plugin-dir.patch ./systemd.patch ];
+  patches = [
+    ./plugin-dir.patch
+
+    # Fixed compilation on systemd > 210
+    (fetchurl {
+      url = "https://github.com/janvidar/uhub/commit/70f2a43f676cdda5961950a8d9a21e12d34993f8.diff";
+      sha256 = "1jp8fvw6f9jh0sdjml9mahkk6p6b96p6rzg2y601mnnbcdj8y8xp";
+    })
+  ];
 
   cmakeFlags = ''
     -DSYSTEMD_SUPPORT=ON
@@ -37,7 +45,7 @@ stdenv.mkDerivation {
     description = "High performance peer-to-peer hub for the ADC network";
     homepage = https://www.uhub.org/;
     license = licenses.gpl3;
-    maintainers = [ maintainers.emery ];
+    maintainers = [ maintainers.ehmry ];
     platforms = platforms.unix;
   };
-}
\ No newline at end of file
+}
diff --git a/pkgs/servers/uhub/plugin-dir.patch b/pkgs/servers/uhub/plugin-dir.patch
index 95ebfd6706ff..01cbcbb31cf3 100644
--- a/pkgs/servers/uhub/plugin-dir.patch
+++ b/pkgs/servers/uhub/plugin-dir.patch
@@ -1,23 +1,19 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 40e996e..d3b7e6d 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -185,10 +185,16 @@ else()
- 	# add_definitions(-DDEBUG)
- endif()
+@@ -241,8 +241,14 @@
  
-+set( PLUGINS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_only mod_topic mod_no_guest_downloads )
-+
  if (UNIX)
- 	install( TARGETS uhub RUNTIME DESTINATION bin )
--	install( TARGETS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_only mod_topic mod_no_guest_downloads DESTINATION /usr/lib/uhub/ OPTIONAL )
+ 	install( TARGETS uhub uhub-passwd RUNTIME DESTINATION bin )
+-	install( TARGETS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_history_sqlite mod_chat_only mod_topic mod_no_guest_downloads DESTINATION /usr/lib/uhub/ OPTIONAL )
 -	install( FILES ${CMAKE_SOURCE_DIR}/doc/uhub.conf ${CMAKE_SOURCE_DIR}/doc/plugins.conf ${CMAKE_SOURCE_DIR}/doc/rules.txt ${CMAKE_SOURCE_DIR}/doc/motd.txt DESTINATION /etc/uhub OPTIONAL )
 +
-+        foreach( PLUGIN ${PLUGINS} )
-+		install( TARGETS ${PLUGIN} DESTINATION $ENV{${PLUGIN}} OPTIONAL )
-+        endforeach( PLUGIN )
++    set( PLUGINS mod_example mod_welcome mod_logging mod_auth_simple mod_chat_history mod_chat_only mod_topic mod_no_guest_downloads )
++
++    foreach( PLUGIN ${PLUGINS} )
++        install( TARGETS ${PLUGIN} DESTINATION $ENV{${PLUGIN}} OPTIONAL )
++    endforeach( PLUGIN )
 +
 +	install( FILES ${CMAKE_SOURCE_DIR}/doc/uhub.conf ${CMAKE_SOURCE_DIR}/doc/plugins.conf ${CMAKE_SOURCE_DIR}/doc/rules.txt ${CMAKE_SOURCE_DIR}/doc/motd.txt DESTINATION doc/ OPTIONAL )
+ endif()
+ 
  
- 	if (SQLITE_SUPPORT)
- 		install( TARGETS uhub-passwd RUNTIME DESTINATION bin )
diff --git a/pkgs/servers/uhub/systemd.patch b/pkgs/servers/uhub/systemd.patch
deleted file mode 100644
index 05e7571d18d5..000000000000
--- a/pkgs/servers/uhub/systemd.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 40e996e..fc4fb01 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -19,6 +19,7 @@ option(LINK_SUPPORT "Allow hub linking" OFF)
- option(SSL_SUPPORT "Enable SSL support" ON)
- option(USE_OPENSSL "Use OpenSSL's SSL support" ON )
- option(SQLITE_SUPPORT "Enable SQLite support" ON)
-+option(SYSTEMD_SUPPORT "Enable systemd notify and journal logging" OFF)
- option(ADC_STRESS "Enable the stress tester client" OFF)
- 
- find_package(Git)
-@@ -34,6 +35,12 @@ if (SSL_SUPPORT)
- 	endif()
- endif()
- 
-+if (SYSTEMD_SUPPORT)
-+        INCLUDE(FindPkgConfig)
-+        pkg_search_module(SD_DAEMON REQUIRED libsystemd-daemon)
-+        pkg_search_module(SD_JOURNAL REQUIRED libsystemd-journal)
-+endif()
-+
- if (MSVC)
- 	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
- endif()
-@@ -175,6 +182,18 @@ if(SSL_SUPPORT)
- 	endif()
- endif()
- 
-+if (SYSTEMD_SUPPORT)
-+        target_link_libraries(uhub ${SD_DAEMON_LIBRARIES})
-+        target_link_libraries(uhub ${SD_JOURNAL_LIBRARIES})
-+        target_link_libraries(test ${SD_DAEMON_LIBRARIES})
-+        target_link_libraries(test ${SD_JOURNAL_LIBRARIES})
-+        target_link_libraries(uhub-passwd ${SD_JOURNAL_LIBRARIES})
-+        target_link_libraries(uhub-admin ${SD_JOURNAL_LIBRARIES})
-+        include_directories(${SD_DAEMON_INCLUDE_DIRS})
-+        include_directories(${SD_JOURNAL_INCLUDE_DIRS})
-+        add_definitions(-DSYSTEMD)
-+endif()
-+
- configure_file ("${PROJECT_SOURCE_DIR}/version.h.in" "${PROJECT_SOURCE_DIR}/version.h")
- 
- mark_as_advanced(FORCE CMAKE_BUILD_TYPE)
-diff --git a/src/core/main.c b/src/core/main.c
-index bb78672..ac2d2a8 100644
---- a/src/core/main.c
-+++ b/src/core/main.c
-@@ -19,6 +19,10 @@
- 
- #include "uhub.h"
- 
-+#ifdef SYSTEMD
-+#include <systemd/sd-daemon.h>
-+#endif
-+
- static int arg_verbose = 5;
- static int arg_fork    = 0;
- static int arg_check_config = 0;
-@@ -145,7 +149,16 @@ int main_loop()
- 			}
- #if !defined(WIN32)
- 			setup_signal_handlers(hub);
--#endif
-+#ifdef SYSTEMD
-+                        /* Notify the service manager that this daemon has 
-+                         * been successfully initalized and shall enter the
-+                         * main loop.
-+                         */
-+                        sd_notifyf(0, "READY=1\n"
-+                                      "MAINPID=%lu", (unsigned long) getpid());
-+#endif /* SYSTEMD */
-+
-+#endif /* ! WIN32 */
- 		}
- 
- 		hub_set_variables(hub, &acl);
-@@ -216,13 +229,17 @@ void print_usage(char* program)
- 		"   -q          Quiet mode - no output\n"
- 		"   -f          Fork to background\n"
- 		"   -l <file>   Log messages to given file (default: stderr)\n"
--		"   -L          Log messages to syslog\n"
- 		"   -c <file>   Specify configuration file (default: " SERVER_CONFIG ")\n"
- 		"   -C          Check configuration and return\n"
- 		"   -s          Show configuration parameters\n"
- 		"   -S          Show configuration parameters, but ignore defaults\n"
- 		"   -h          This message\n"
- #ifndef WIN32
-+#ifdef SYSTEMD
-+		"   -L          Log messages to journal\n"
-+#else
-+		"   -L          Log messages to syslog\n"
-+#endif
- 		"   -u <user>   Run as given user\n"
- 		"   -g <group>  Run with given group permissions\n"
- 		"   -p <file>   Store pid in file (process id)\n"
-diff --git a/src/util/log.c b/src/util/log.c
-index 42badb3..2d97528 100644
---- a/src/util/log.c
-+++ b/src/util/log.c
-@@ -21,7 +21,15 @@
- #include <locale.h>
- 
- #ifndef WIN32
-+
-+#ifdef SYSTEMD
-+#define SD_JOURNAL_SUPPRESS_LOCATION
-+#include <systemd/sd-journal.h>
-+
-+#else
- #include <syslog.h>
-+#endif
-+
- static int use_syslog = 0;
- #endif
- 
-@@ -83,7 +91,9 @@ void hub_log_initialize(const char* file, int syslog)
- 	if (syslog)
- 	{
- 		use_syslog = 1;
-+                #ifndef SYSTEMD
- 		openlog("uhub", LOG_PID, LOG_USER);
-+                #endif
- 	}
- #endif
- 
-@@ -132,7 +142,9 @@ void hub_log_shutdown()
- 	if (use_syslog)
- 	{
- 		use_syslog = 0;
-+                #ifndef SYSTEMD
- 		closelog();
-+                #endif
- 	}
- #endif
- }
-@@ -212,7 +224,12 @@ void hub_log(int log_verbosity, const char *format, ...)
- 			case log_fatal:    level = LOG_CRIT; break;
- 			case log_error:    level = LOG_ERR; break;
- 			case log_warning:  level = LOG_WARNING; break;
--			case log_user:     level = LOG_INFO | LOG_AUTH; break;
-+                        #ifdef SYSTEMD
-+                        case log_user:     level = LOG_INFO; break;
-+
-+                        #else
-+                        case log_user:     level = LOG_INFO | LOG_AUTH; break;
-+                        #endif
- 			case log_info:     level = LOG_INFO; break;
- 			case log_debug:    level = LOG_DEBUG; break;
- 			
-@@ -224,8 +241,13 @@ void hub_log(int log_verbosity, const char *format, ...)
- 		if (level == 0)
- 			return;
- 		
-+                #ifdef SYSTEMD
-+		sd_journal_print(level, "%s", logmsg);
-+
-+                #else
- 		level |= (LOG_USER | LOG_DAEMON);
- 		syslog(level, "%s", logmsg);
-+                #endif
- 	}
- #endif
- 	
diff --git a/pkgs/servers/ums/default.nix b/pkgs/servers/ums/default.nix
new file mode 100644
index 000000000000..9bccd5b99fb0
--- /dev/null
+++ b/pkgs/servers/ums/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, makeWrapper
+, libzen, libmediainfo , jre8
+}:
+
+stdenv.mkDerivation rec {
+  name = "ums-${version}";
+  version = "6.2.2";
+  
+  src = fetchurl {
+    url = "mirror://sourceforge/project/unimediaserver/Official%20Releases/Linux/" + stdenv.lib.toUpper "${name}" + "-Java8.tgz";
+    sha256 = "1qa999la9hixy0pdj9phjvr6lwqycgdvm94nc1606vz0ivf95b15";
+    name = "${name}.tgz";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    cp -a . $out/
+    mkdir $out/bin
+    mv $out/documentation /$out/doc
+
+    makeWrapper "$out/UMS.sh" "$out/bin/ums" \
+      --prefix LD_LIBRARY_PATH ":" "${stdenv.lib.makeLibraryPath [ libzen libmediainfo] }" \
+      --set JAVA_HOME "${jre8}"
+  '';
+
+  meta = {
+      description = "Universal Media Server: a DLNA-compliant UPnP Media Server";
+      license = stdenv.lib.licenses.gpl2;
+      platforms = stdenv.lib.platforms.linux;
+      maintainers = [ stdenv.lib.maintainers.thall ];
+  };
+}
diff --git a/pkgs/servers/unifi/default.nix b/pkgs/servers/unifi/default.nix
index 5d0e7455d946..9002987c387b 100644
--- a/pkgs/servers/unifi/default.nix
+++ b/pkgs/servers/unifi/default.nix
@@ -1,32 +1,61 @@
-{ stdenv, fetchurl, unzip }:
+{ stdenv, dpkg, fetchurl }:
 
-stdenv.mkDerivation rec {
-  name = "unifi-controller-${version}";
-  version = "4.7.5";
+let
+  generic = { version, sha256, suffix ? "" }:
+  stdenv.mkDerivation rec {
+    name = "unifi-controller-${version}";
 
-  src = fetchurl {
-    url = "http://dl.ubnt.com/unifi/${version}/UniFi.unix.zip";
-    sha256 = "1d5jkpwnz4wvcjr5i73m8i5aah6rkxwd0r9239l90v1ja9lkyk7w";
+    src = fetchurl {
+      url = "https://dl.ubnt.com/unifi/${version}${suffix}/unifi_sysvinit_all.deb";
+      inherit sha256;
+    };
+
+    nativeBuildInputs = [ dpkg ];
+
+    unpackPhase = ''
+      runHook preUnpack
+      dpkg-deb -x $src ./
+      runHook postUnpack
+    '';
+
+    doConfigure = false;
+
+    installPhase = ''
+      runHook preInstall
+
+      mkdir -p $out
+      cd ./usr/lib/unifi
+      cp -ar dl lib webapps $out
+
+      runHook postInstall
+    '';
+
+    meta = with stdenv.lib; {
+      homepage = http://www.ubnt.com/;
+      description = "Controller for Ubiquiti UniFi access points";
+      license = licenses.unfree;
+      platforms = platforms.unix;
+      maintainers = with maintainers; [ wkennington ];
+    };
   };
 
-  buildInputs = [ unzip ];
+in rec {
 
-  doConfigure = false;
+  # https://help.ubnt.com/hc/en-us/articles/115000441548-UniFi-Current-Controller-Versions
 
-  buildPhase = ''
-    rm -rf bin conf readme.txt
-  '';
+  unifiLTS = generic {
+    version = "5.6.37";
+    sha256  = "0kiksqsbmmfva1blbpg2wl4c3w7j6dzzqmwp6028g7bh303c47qa";
+  };
 
-  installPhase = ''
-    mkdir -p $out
-    cp -ar * $out
-  '';
+  unifiStable = generic {
+    version = "5.7.23";
+    sha256  = "14jkhp9jl341zsyk5adh3g98mhqwfbd42c7wahzc31bxq8a0idp7";
+  };
 
-  meta = with stdenv.lib; {
-    homepage = http://www.ubnt.com/;
-    description = "Controller for Ubiquiti UniFi accesspoints";
-    license = licenses.unfree;
-    platforms = platforms.unix;
-    maintainers = with maintainers; [ wkennington ];
+  unifiTesting = generic {
+    version = "5.8.14";
+    suffix  = "-7ef9535d1b";
+    sha256  = "09gr7zkck6npjhhmd27c9ymyna6anwj3w9v9zjicz9skbrddkccq";
   };
 }
diff --git a/pkgs/servers/uwsgi/default.nix b/pkgs/servers/uwsgi/default.nix
index e7e7502665fb..bb3f79855330 100644
--- a/pkgs/servers/uwsgi/default.nix
+++ b/pkgs/servers/uwsgi/default.nix
@@ -1,49 +1,72 @@
 { stdenv, lib, fetchurl, pkgconfig, jansson
+# plugins: list of strings, eg. [ "python2" "python3" ]
 , plugins
-, pam, withPAM ? stdenv.isLinux
-, systemd, withSystemd ? stdenv.isLinux
+, pam, withPAM ? false
+, systemd, withSystemd ? false
 , python2, python3, ncurses
+, ruby, php-embed, mysql
 }:
 
-let pythonPlugin = pkg : { name = "python${if pkg ? isPy2 then "2" else "3"}";
-                           interpreter = pkg;
+let pythonPlugin = pkg : lib.nameValuePair "python${if pkg ? isPy2 then "2" else "3"}" {
+                           interpreter = pkg.interpreter;
                            path = "plugins/python";
-                           deps = [ pkg ncurses ];
+                           inputs = [ pkg ncurses ];
                            install = ''
                              install -Dm644 uwsgidecorators.py $out/${pkg.sitePackages}/uwsgidecorators.py
                              ${pkg.executable} -m compileall $out/${pkg.sitePackages}/
                              ${pkg.executable} -O -m compileall $out/${pkg.sitePackages}/
                            '';
                          };
-    available = [ (pythonPlugin python2)
+
+    available = lib.listToAttrs [
+                  (pythonPlugin python2)
                   (pythonPlugin python3)
+                  (lib.nameValuePair "rack" {
+                    path = "plugins/rack";
+                    inputs = [ ruby ];
+                  })
+                  (lib.nameValuePair "cgi" {
+                    # usage: https://uwsgi-docs.readthedocs.io/en/latest/CGI.html?highlight=cgi
+                    path = "plugins/cgi";
+                    inputs = [ ];
+                  })
+                  (lib.nameValuePair "php" {
+                    # usage: https://uwsgi-docs.readthedocs.io/en/latest/PHP.html#running-php-apps-with-nginx
+                    path = "plugins/php";
+                    inputs = [ php-embed ] ++ php-embed.buildInputs;
+                    NIX_CFLAGS_LINK = [ "-L${mysql.connector-c}/lib/mysql" ];
+                  })
                 ];
-     needed = builtins.filter (x: lib.any (y: x.name == y) plugins) available;
-in
 
-assert builtins.filter (x: lib.all (y: y.name != x) available) plugins == [];
+    getPlugin = name:
+      let all = lib.concatStringsSep ", " (lib.attrNames available);
+      in if lib.hasAttr name available
+         then lib.getAttr name available // { inherit name; }
+         else throw "Unknown UWSGI plugin ${name}, available : ${all}";
+
+    needed = builtins.map getPlugin plugins;
+in
 
 stdenv.mkDerivation rec {
-  name = "uwsgi-2.0.11.1";
+  name = "uwsgi-${version}";
+  version = "2.0.17";
 
   src = fetchurl {
     url = "http://projects.unbit.it/downloads/${name}.tar.gz";
-    sha256 = "11v2j9n204hlvi1p1wp4r3nn22fqyd1qlbqcfqddi77sih9x79vm";
+    sha256 = "1wlbaairsmhp6bx5wv282q9pgh6w7w6yrb8vxjznfaxrinsfkhix";
   };
 
   nativeBuildInputs = [ python3 pkgconfig ];
 
-  buildInputs =  with stdenv.lib;
-                 [ jansson ]
-              ++ optional withPAM pam
-              ++ optional withSystemd systemd
-              ++ lib.concatMap (x: x.deps) needed
+  buildInputs =  [ jansson ]
+              ++ lib.optional withPAM pam
+              ++ lib.optional withSystemd systemd
+              ++ lib.concatMap (x: x.inputs) needed
               ;
 
-  basePlugins =  with stdenv.lib;
-                 concatStringsSep ","
-                 (  optional withPAM "pam"
-                 ++ optional withSystemd "systemd_logger"
+  basePlugins =  lib.concatStringsSep ","
+                 (  lib.optional withPAM "pam"
+                 ++ lib.optional withSystemd "systemd_logger"
                  );
 
   passthru = {
@@ -58,19 +81,21 @@ stdenv.mkDerivation rec {
   buildPhase = ''
     mkdir -p $pluginDir
     python3 uwsgiconfig.py --build nixos
-    ${lib.concatMapStringsSep ";" (x: "${x.interpreter.interpreter} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed}
+    ${lib.concatMapStringsSep ";" (x: "${x.preBuild or ""}\n ${x.interpreter or "python3"} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed}
   '';
 
   installPhase = ''
     install -Dm755 uwsgi $out/bin/uwsgi
-    #cp *_plugin.so $pluginDir || true
-    ${lib.concatMapStringsSep "\n" (x: x.install) needed}
+    ${lib.concatMapStringsSep "\n" (x: x.install or "") needed}
   '';
 
+  NIX_CFLAGS_LINK = [ "-lsystemd" ] ++ lib.concatMap (x: x.NIX_CFLAGS_LINK or []) needed;
+
   meta = with stdenv.lib; {
     homepage = http://uwsgi-docs.readthedocs.org/en/latest/;
     description = "A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C";
     license = licenses.gpl2;
-    maintainers = with maintainers; [ abbradar ];
+    maintainers = with maintainers; [ abbradar schneefux ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/servers/uwsgi/nixos.ini b/pkgs/servers/uwsgi/nixos.ini
index 454eb51893fc..51bc6da33f6c 100644
--- a/pkgs/servers/uwsgi/nixos.ini
+++ b/pkgs/servers/uwsgi/nixos.ini
@@ -2,4 +2,5 @@
 plugin_dir = @pluginDir@
 main_plugin = @basePlugins@
 json = true
+yaml = false
 inherit = base
diff --git a/pkgs/servers/varnish/default.nix b/pkgs/servers/varnish/default.nix
index 358afb3dfb36..85192b11c30f 100644
--- a/pkgs/servers/varnish/default.nix
+++ b/pkgs/servers/varnish/default.nix
@@ -1,23 +1,53 @@
-{ stdenv, fetchurl, pcre, libxslt, groff, ncurses, pkgconfig, readline, python
-, pythonPackages }:
+{ stdenv, fetchurl, pcre, libxslt, groff, ncurses, pkgconfig, readline, libedit
+, python, pythonPackages, makeWrapper }:
 
-stdenv.mkDerivation rec {
-  version = "4.0.3";
-  name = "varnish-${version}";
+let
+  common = { version, sha256 }:
+    stdenv.mkDerivation rec {
+      name = "varnish-${version}";
 
-  src = fetchurl {
-    url = "http://repo.varnish-cache.org/source/${name}.tar.gz";
-    sha256 = "01l2iypajkdanxpbvzfxm6vs4jay4dgw7lmchqidnivz15sa3fcl";
-  };
+      src = fetchurl {
+        url = "http://varnish-cache.org/_downloads/${name}.tgz";
+        inherit sha256;
+      };
+
+      nativeBuildInputs = [ pkgconfig ];
+      buildInputs = [
+        pcre libxslt groff ncurses readline python libedit
+        pythonPackages.docutils makeWrapper
+      ];
+
+      buildFlags = "localstatedir=/var/spool";
+
+      postInstall = ''
+        wrapProgram "$out/sbin/varnishd" --prefix PATH : "${stdenv.lib.makeBinPath [ stdenv.cc ]}"
+      '';
 
-  buildInputs = [ pcre libxslt groff ncurses pkgconfig readline python
-    pythonPackages.docutils];
+      # https://github.com/varnishcache/varnish-cache/issues/1875
+      NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isi686 "-fexcess-precision=standard";
 
-  meta = {
-    description = "Web application accelerator also known as a caching HTTP reverse proxy";
-    homepage = "https://www.varnish-cache.org";
-    license = stdenv.lib.licenses.bsd2;
-    maintainers = [ stdenv.lib.maintainers.garbas ];
-    platforms = stdenv.lib.platforms.linux;
+      outputs = [ "out" "dev" "man" ];
+
+      meta = with stdenv.lib; {
+        description = "Web application accelerator also known as a caching HTTP reverse proxy";
+        homepage = https://www.varnish-cache.org;
+        license = licenses.bsd2;
+        maintainers = with maintainers; [ garbas fpletz ];
+        platforms = platforms.unix;
+      };
+    };
+in
+{
+  varnish4 = common {
+    version = "4.1.9";
+    sha256 = "11zwyasz2fn9qxc87r175wb5ba7388sd79mlygjmqn3yv2m89n12";
+  };
+  varnish5 = common {
+    version = "5.2.1";
+    sha256 = "1cqlj12m426c1lak1hr1fx5zcfsjjvka3hfirz47hvy1g2fjqidq";
+  };
+  varnish6 = common {
+    version = "6.0.0";
+    sha256 = "1vhbdch33m6ig4ijy57zvrramhs9n7cba85wd8rizgxjjnf87cn7";
   };
 }
diff --git a/pkgs/servers/varnish/digest.nix b/pkgs/servers/varnish/digest.nix
new file mode 100644
index 000000000000..2ccb0419c042
--- /dev/null
+++ b/pkgs/servers/varnish/digest.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, varnish, libmhash, docutils }:
+
+stdenv.mkDerivation rec {
+  version = "1.0.2";
+  name = "${varnish.name}-digest-${version}";
+
+  src = fetchFromGitHub {
+    owner = "varnish";
+    repo = "libvmod-digest";
+    rev = "libvmod-digest-${version}";
+    sha256 = "0jwkqqalydn0pwfdhirl5zjhbc3hldvhh09hxrahibr72fgmgpbx";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig docutils ];
+  buildInputs = [ varnish libmhash ];
+
+  postPatch = ''
+    substituteInPlace autogen.sh  --replace "''${dataroot}/aclocal"                  "${varnish.dev}/share/aclocal"
+    substituteInPlace Makefile.am --replace "''${LIBVARNISHAPI_DATAROOTDIR}/aclocal" "${varnish.dev}/share/aclocal"
+  '';
+
+  configureFlags = [ "VMOD_DIR=$(out)/lib/varnish/vmods" ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Digest and HMAC vmod";
+    homepage = https://github.com/varnish/libvmod-digest;
+    inherit (varnish.meta) license platforms maintainers;
+  };
+}
diff --git a/pkgs/servers/varnish/dynamic.nix b/pkgs/servers/varnish/dynamic.nix
new file mode 100644
index 000000000000..711bc1cf78f5
--- /dev/null
+++ b/pkgs/servers/varnish/dynamic.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, varnish, python, docutils }:
+
+stdenv.mkDerivation rec {
+  version = "0.3";
+  name = "${varnish.name}-dynamic-${version}";
+
+  src = fetchFromGitHub {
+    owner = "nigoroll";
+    repo = "libvmod-dynamic";
+    rev = "475be183fddbd727c3d2523f0518effa9aa881f8"; # 5.2 branch for Varnish-5.2 https://github.com/nigoroll/libvmod-dynamic/commits/5.2
+    sha256 = "12a42lbv0vf6fn3qnvngw893kmbd006f8pgab4ir7irc8855xjgf";
+  };
+
+  nativeBuildInputs = [ pkgconfig docutils autoreconfHook ];
+  buildInputs = [ varnish python ];
+  postPatch = ''
+    substituteInPlace Makefile.am --replace "''${LIBVARNISHAPI_DATAROOTDIR}/aclocal" "${varnish.dev}/share/aclocal"
+  '';
+  configureFlags = [ "VMOD_DIR=$(out)/lib/varnish/vmods" ];
+
+  meta = with stdenv.lib; {
+    description = "Dynamic director similar to the DNS director from Varnish 3";
+    homepage = https://github.com/nigoroll/libvmod-dynamic;
+    inherit (varnish.meta) license platforms maintainers;
+  };
+}
diff --git a/pkgs/servers/varnish/geoip.nix b/pkgs/servers/varnish/geoip.nix
new file mode 100644
index 000000000000..d1790252065c
--- /dev/null
+++ b/pkgs/servers/varnish/geoip.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchpatch, fetchFromGitHub, autoreconfHook, pkgconfig, varnish, geoip, docutils }:
+
+stdenv.mkDerivation rec {
+  version = "1.0.2";
+  name = "${varnish.name}-geoip-${version}";
+
+  src = fetchFromGitHub {
+    owner = "varnish";
+    repo = "libvmod-geoip";
+    rev = "libvmod-geoip-${version}";
+    sha256 = "1gmadayqh3dais14c4skvd47w8h4kyifg7kcw034i0777z5hfpyn";
+  };
+
+  patches = [
+    # IPv6 support
+    (fetchpatch {
+      url = https://github.com/volth/libvmod-geoip-1/commit/0966fe8.patch;
+      sha256 = "053im8h2y8qzs37g95ksr00sf625p23r5ps1j0a2h4lfg70vf4ry";
+    })
+  ];
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig docutils ];
+  buildInputs = [ varnish geoip ];
+  configureFlags = [ "VMOD_DIR=$(out)/lib/varnish/vmods" ];
+
+  meta = with stdenv.lib; {
+    description = "GeoIP Varnish module by Varnish Software";
+    homepage = https://github.com/varnish/libvmod-geoip;
+    inherit (varnish.meta) license platforms maintainers;
+  };
+}
diff --git a/pkgs/servers/varnish/modules.nix b/pkgs/servers/varnish/modules.nix
new file mode 100644
index 000000000000..7775221d1638
--- /dev/null
+++ b/pkgs/servers/varnish/modules.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, varnish, python, docutils, removeReferencesTo }:
+
+stdenv.mkDerivation rec {
+  version = "0.14.0";
+  name = "${varnish.name}-modules-${version}";
+
+  src = fetchFromGitHub {
+    owner = "varnish";
+    repo = "varnish-modules";
+    rev = version;
+    sha256 = "17fkbr4i70qgdqsrx1x28ag20xkfyz1v3q3d3ywmv409aczqhm40";
+  };
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook docutils removeReferencesTo ];
+  buildInputs = [ varnish python ];
+
+  postPatch = ''
+    substituteInPlace bootstrap   --replace "''${dataroot}/aclocal"                  "${varnish.dev}/share/aclocal"
+    substituteInPlace Makefile.am --replace "''${LIBVARNISHAPI_DATAROOTDIR}/aclocal" "${varnish.dev}/share/aclocal"
+  '';
+
+  postInstall = "find $out -type f -exec remove-references-to -t ${varnish.dev} '{}' +"; # varnish.dev captured only as __FILE__ in assert messages
+
+  meta = with stdenv.lib; {
+    description = "Collection of Varnish Cache modules (vmods) by Varnish Software";
+    homepage = https://github.com/varnish/varnish-modules;
+    inherit (varnish.meta) license platforms maintainers;
+  };
+}
diff --git a/pkgs/servers/varnish/packages.nix b/pkgs/servers/varnish/packages.nix
new file mode 100644
index 000000000000..f468ac58e6cd
--- /dev/null
+++ b/pkgs/servers/varnish/packages.nix
@@ -0,0 +1,22 @@
+{ callPackage, varnish4, varnish5, varnish6 }:
+
+{
+  varnish4Packages = {
+    varnish = varnish4;
+    digest   = callPackage ./digest.nix   { varnish = varnish4; };
+    rtstatus = callPackage ./rtstatus.nix { varnish = varnish4; }; # varnish4 only
+    modules  = callPackage ./modules.nix  { varnish = varnish4; }; # varnish4 and varnish5 only
+    geoip    = callPackage ./geoip.nix    { varnish = varnish4; }; # varnish4 and varnish5 only
+  };
+  varnish5Packages = {
+    varnish = varnish5;
+    digest   = callPackage ./digest.nix   { varnish = varnish5; };
+    dynamic  = callPackage ./dynamic.nix  { varnish = varnish5; }; # varnish5 only (upstream has a separate branch for varnish4)
+    modules  = callPackage ./modules.nix  { varnish = varnish5; }; # varnish4 and varnish5 only
+    geoip    = callPackage ./geoip.nix    { varnish = varnish5; }; # varnish4 and varnish5 only
+  };
+  varnish6Packages = {
+    varnish = varnish6;
+    digest   = callPackage ./digest.nix   { varnish = varnish6; };
+  };
+}
diff --git a/pkgs/servers/varnish/rtstatus.nix b/pkgs/servers/varnish/rtstatus.nix
new file mode 100644
index 000000000000..99c0bb176597
--- /dev/null
+++ b/pkgs/servers/varnish/rtstatus.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, varnish, python, docutils }:
+
+stdenv.mkDerivation rec {
+  version = "1.2.0";
+  name = "${varnish.name}-rtstatus-${version}";
+
+  src = fetchurl {
+    url = "https://download.varnish-software.com/libvmod-rtstatus/libvmod-rtstatus-${version}.tar.gz";
+    sha256 = "0hll1aspgpv1daw5sdbn5w1d6birchxgapzb6zi1nhahjlimy4ly";
+  };
+
+  nativeBuildInputs = [ pkgconfig docutils ];
+  buildInputs = [ varnish python ];
+  configureFlags = [ "VMOD_DIR=$(out)/lib/varnish/vmods" ];
+
+  meta = with stdenv.lib; {
+    description = "Varnish realtime status page";
+    homepage = https://github.com/varnish/libvmod-rtstatus;
+    inherit (varnish.meta) license platforms maintainers;
+  };
+}
diff --git a/pkgs/servers/web-apps/fileshelter/default.nix b/pkgs/servers/web-apps/fileshelter/default.nix
new file mode 100644
index 000000000000..d0be4f575dd6
--- /dev/null
+++ b/pkgs/servers/web-apps/fileshelter/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, libzip, boost, wt3, libconfig, pkgconfig } :
+
+stdenv.mkDerivation rec {
+  name = "fileshelter";
+  version = "3.0.0";
+
+  src = fetchFromGitHub {
+    owner = "epoupon";
+    repo = "fileshelter";
+    rev = "v${version}";
+    sha256 = "1n9hrls3l9gf8wfz6m9bylma1b1hdvdqsksv2dlp1zdgjdzv200b";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libzip boost wt3 libconfig ];
+
+  postInstall = ''
+    ln -s ${wt3}/share/Wt/resources $out/share/fileshelter/docroot/resources
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/epoupon/fileshelter;
+    description = "FileShelter is a 'one-click' file sharing web application";
+    maintainers = [ maintainers.willibutz ];
+    license = licenses.gpl3;
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/servers/web-apps/frab/Gemfile b/pkgs/servers/web-apps/frab/Gemfile
new file mode 100644
index 000000000000..098b8f3d7d7a
--- /dev/null
+++ b/pkgs/servers/web-apps/frab/Gemfile
@@ -0,0 +1,88 @@
+source 'https://rubygems.org'
+
+if ENV['CUSTOM_RUBY_VERSION']
+  ruby ENV['CUSTOM_RUBY_VERSION'] # i.e.: '2.3'
+end
+
+gem 'rails', '~> 4.2'
+
+# Use SCSS for stylesheets
+gem 'sass-rails', '~> 5.0'
+# Use Uglifier as compressor for JavaScript assets
+gem 'uglifier', '>= 1.3.0'
+# Use CoffeeScript for .coffee assets and views
+gem 'coffee-rails', '~> 4.1.0'
+
+gem 'mysql2', group: :mysql
+gem 'pg', group: :postgresql
+gem 'sqlite3', group: :sqlite3
+
+# Use Puma as the app server
+gem 'puma'
+
+# Capistrano for deployment
+group :capistrano do
+  gem 'airbrussh'
+  gem 'capistrano', '~> 3.4.0', require: false
+  gem 'capistrano-rails',   require: false
+  gem 'capistrano-bundler', require: false
+  gem 'capistrano-rvm',     require: false
+  gem 'capistrano3-puma',   require: false
+end
+
+# Use jquery as the JavaScript library
+gem 'jquery-rails'
+gem 'jquery-migrate-rails'
+gem 'jquery-ui-rails'
+
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.0'
+
+gem 'activeresource'
+gem 'acts_as_commentable'
+gem 'bcrypt'
+gem 'cancancan'
+gem 'cocoon'
+gem 'dotenv-rails'
+gem 'haml'
+gem 'localized_language_select', github: 'frab/localized_language_select', branch: 'master'
+gem 'nokogiri'
+gem 'paperclip', '~> 4.1'
+gem 'paper_trail'
+gem 'prawn', '< 1.0'
+gem 'prawn_rails'
+gem 'ransack'
+gem 'ri_cal'
+gem 'roust'
+gem 'rqrcode'
+#gem 'roust', :git => 'git@github.com:bulletproofnetworks/roust.git'
+gem 'simple_form'
+gem 'sucker_punch'
+gem 'transitions', require: ['transitions', 'active_record/transitions']
+gem 'will_paginate'
+
+group :production do
+  gem 'exception_notification'
+end
+
+group :development, :test do
+  gem 'bullet'
+  gem 'pry-rails'
+  gem 'pry-byebug'
+  gem 'letter_opener'
+  gem 'faker'
+end
+
+group :test do
+  gem 'database_cleaner'
+  gem 'factory_girl_rails', '~> 4.0'
+  gem 'shoulda'
+end
+
+group :doc do
+  gem 'redcarpet'       # documentation
+  gem 'github-markdown' # documentation
+  gem 'yard'            # documentation
+  # gem 'rails-erd'      # graph
+  # gem 'ruby-graphviz', require: 'graphviz' # Optional: only required for graphing
+end
diff --git a/pkgs/servers/web-apps/frab/Gemfile.lock b/pkgs/servers/web-apps/frab/Gemfile.lock
new file mode 100644
index 000000000000..06502ef59ad5
--- /dev/null
+++ b/pkgs/servers/web-apps/frab/Gemfile.lock
@@ -0,0 +1,329 @@
+GIT
+  remote: git://github.com/frab/localized_language_select.git
+  revision: 85df6b97789de6e29c630808b630e56a1b76f80c
+  branch: master
+  specs:
+    localized_language_select (0.3.0)
+      rails (>= 4.1.0)
+
+GEM
+  remote: https://rubygems.org/
+  specs:
+    actionmailer (4.2.7.1)
+      actionpack (= 4.2.7.1)
+      actionview (= 4.2.7.1)
+      activejob (= 4.2.7.1)
+      mail (~> 2.5, >= 2.5.4)
+      rails-dom-testing (~> 1.0, >= 1.0.5)
+    actionpack (4.2.7.1)
+      actionview (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      rack (~> 1.6)
+      rack-test (~> 0.6.2)
+      rails-dom-testing (~> 1.0, >= 1.0.5)
+      rails-html-sanitizer (~> 1.0, >= 1.0.2)
+    actionview (4.2.7.1)
+      activesupport (= 4.2.7.1)
+      builder (~> 3.1)
+      erubis (~> 2.7.0)
+      rails-dom-testing (~> 1.0, >= 1.0.5)
+      rails-html-sanitizer (~> 1.0, >= 1.0.2)
+    activejob (4.2.7.1)
+      activesupport (= 4.2.7.1)
+      globalid (>= 0.3.0)
+    activemodel (4.2.7.1)
+      activesupport (= 4.2.7.1)
+      builder (~> 3.1)
+    activerecord (4.2.7.1)
+      activemodel (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      arel (~> 6.0)
+    activeresource (4.1.0)
+      activemodel (~> 4.0)
+      activesupport (~> 4.0)
+      rails-observers (~> 0.1.2)
+    activesupport (4.2.7.1)
+      i18n (~> 0.7)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
+      thread_safe (~> 0.3, >= 0.3.4)
+      tzinfo (~> 1.1)
+    acts_as_commentable (4.0.2)
+    addressable (2.4.0)
+    airbrussh (1.1.1)
+      sshkit (>= 1.6.1, != 1.7.0)
+    arel (6.0.3)
+    bcrypt (3.1.11)
+    builder (3.2.2)
+    bullet (5.4.0)
+      activesupport (>= 3.0.0)
+      uniform_notifier (~> 1.10.0)
+    byebug (9.0.5)
+    cancancan (1.15.0)
+    capistrano (3.4.1)
+      i18n
+      rake (>= 10.0.0)
+      sshkit (~> 1.3)
+    capistrano-bundler (1.1.4)
+      capistrano (~> 3.1)
+      sshkit (~> 1.2)
+    capistrano-rails (1.1.8)
+      capistrano (~> 3.1)
+      capistrano-bundler (~> 1.1)
+    capistrano-rvm (0.1.2)
+      capistrano (~> 3.0)
+      sshkit (~> 1.2)
+    capistrano3-puma (1.2.1)
+      capistrano (~> 3.0)
+      puma (>= 2.6)
+    chunky_png (1.3.7)
+    climate_control (0.0.3)
+      activesupport (>= 3.0)
+    cocaine (0.5.8)
+      climate_control (>= 0.0.3, < 1.0)
+    cocoon (1.2.9)
+    coderay (1.1.1)
+    coffee-rails (4.1.1)
+      coffee-script (>= 2.2.0)
+      railties (>= 4.0.0, < 5.1.x)
+    coffee-script (2.4.1)
+      coffee-script-source
+      execjs
+    coffee-script-source (1.10.0)
+    concurrent-ruby (1.0.2)
+    database_cleaner (1.5.3)
+    dotenv (2.1.1)
+    dotenv-rails (2.1.1)
+      dotenv (= 2.1.1)
+      railties (>= 4.0, < 5.1)
+    erubis (2.7.0)
+    exception_notification (4.2.1)
+      actionmailer (>= 4.0, < 6)
+      activesupport (>= 4.0, < 6)
+    execjs (2.7.0)
+    factory_girl (4.7.0)
+      activesupport (>= 3.0.0)
+    factory_girl_rails (4.7.0)
+      factory_girl (~> 4.7.0)
+      railties (>= 3.0.0)
+    faker (1.6.6)
+      i18n (~> 0.5)
+    github-markdown (0.6.9)
+    globalid (0.3.7)
+      activesupport (>= 4.1.0)
+    haml (4.0.7)
+      tilt
+    httparty (0.14.0)
+      multi_xml (>= 0.5.2)
+    i18n (0.7.0)
+    jbuilder (2.6.0)
+      activesupport (>= 3.0.0, < 5.1)
+      multi_json (~> 1.2)
+    jquery-migrate-rails (1.2.1)
+    jquery-rails (4.2.1)
+      rails-dom-testing (>= 1, < 3)
+      railties (>= 4.2.0)
+      thor (>= 0.14, < 2.0)
+    jquery-ui-rails (5.0.5)
+      railties (>= 3.2.16)
+    json (1.8.3)
+    launchy (2.4.3)
+      addressable (~> 2.3)
+    letter_opener (1.4.1)
+      launchy (~> 2.2)
+    loofah (2.0.3)
+      nokogiri (>= 1.5.9)
+    mail (2.6.4)
+      mime-types (>= 1.16, < 4)
+    method_source (0.8.2)
+    mime-types (3.1)
+      mime-types-data (~> 3.2015)
+    mime-types-data (3.2016.0521)
+    mimemagic (0.3.0)
+    mini_portile2 (2.1.0)
+    minitest (5.9.1)
+    multi_json (1.12.1)
+    multi_xml (0.5.5)
+    mysql2 (0.4.4)
+    net-scp (1.2.1)
+      net-ssh (>= 2.6.5)
+    net-ssh (3.2.0)
+    nokogiri (1.6.7.2)
+      mini_portile2 (~> 2.0.0.rc2)
+      pkg-config (~> 1.1.7)
+    paper_trail (5.2.2)
+      activerecord (>= 3.0, < 6.0)
+      request_store (~> 1.1)
+    paperclip (4.3.7)
+      activemodel (>= 3.2.0)
+      activesupport (>= 3.2.0)
+      cocaine (~> 0.5.5)
+      mime-types
+      mimemagic (= 0.3.0)
+    pdf-core (0.1.6)
+    pg (0.19.0)
+    pkg-config (1.1.7)
+    polyamorous (1.3.1)
+      activerecord (>= 3.0)
+    prawn (0.15.0)
+      pdf-core (~> 0.1.3)
+      ttfunk (~> 1.1.0)
+    prawn_rails (0.0.11)
+      prawn (>= 0.11.1)
+      railties (>= 3.0.0)
+    pry (0.10.4)
+      coderay (~> 1.1.0)
+      method_source (~> 0.8.1)
+      slop (~> 3.4)
+    pry-byebug (3.4.0)
+      byebug (~> 9.0)
+      pry (~> 0.10)
+    pry-rails (0.3.4)
+      pry (>= 0.9.10)
+    puma (3.9.1)
+    rack (1.6.4)
+    rack-test (0.6.3)
+      rack (>= 1.0)
+    rails (4.2.7.1)
+      actionmailer (= 4.2.7.1)
+      actionpack (= 4.2.7.1)
+      actionview (= 4.2.7.1)
+      activejob (= 4.2.7.1)
+      activemodel (= 4.2.7.1)
+      activerecord (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      bundler (>= 1.3.0, < 2.0)
+      railties (= 4.2.7.1)
+      sprockets-rails
+    rails-deprecated_sanitizer (1.0.3)
+      activesupport (>= 4.2.0.alpha)
+    rails-dom-testing (1.0.7)
+      activesupport (>= 4.2.0.beta, < 5.0)
+      nokogiri (~> 1.6.0)
+      rails-deprecated_sanitizer (>= 1.0.1)
+    rails-html-sanitizer (1.0.3)
+      loofah (~> 2.0)
+    rails-observers (0.1.2)
+      activemodel (~> 4.0)
+    railties (4.2.7.1)
+      actionpack (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      rake (>= 0.8.7)
+      thor (>= 0.18.1, < 2.0)
+    rake (11.3.0)
+    ransack (1.8.2)
+      actionpack (>= 3.0)
+      activerecord (>= 3.0)
+      activesupport (>= 3.0)
+      i18n
+      polyamorous (~> 1.3)
+    redcarpet (3.3.4)
+    request_store (1.3.1)
+    ri_cal (0.8.8)
+    roust (1.8.9)
+      activesupport (>= 4.0.10)
+      httparty (>= 0.13.1)
+      mail (>= 2.5.4)
+    rqrcode (0.10.1)
+      chunky_png (~> 1.0)
+    sass (3.4.22)
+    sass-rails (5.0.6)
+      railties (>= 4.0.0, < 6)
+      sass (~> 3.1)
+      sprockets (>= 2.8, < 4.0)
+      sprockets-rails (>= 2.0, < 4.0)
+      tilt (>= 1.1, < 3)
+    shoulda (3.5.0)
+      shoulda-context (~> 1.0, >= 1.0.1)
+      shoulda-matchers (>= 1.4.1, < 3.0)
+    shoulda-context (1.2.1)
+    shoulda-matchers (2.8.0)
+      activesupport (>= 3.0.0)
+    simple_form (3.3.1)
+      actionpack (> 4, < 5.1)
+      activemodel (> 4, < 5.1)
+    slop (3.6.0)
+    sprockets (3.7.0)
+      concurrent-ruby (~> 1.0)
+      rack (> 1, < 3)
+    sprockets-rails (3.2.0)
+      actionpack (>= 4.0)
+      activesupport (>= 4.0)
+      sprockets (>= 3.0.0)
+    sqlite3 (1.3.11)
+    sshkit (1.11.3)
+      net-scp (>= 1.1.2)
+      net-ssh (>= 2.8.0)
+    sucker_punch (2.0.2)
+      concurrent-ruby (~> 1.0.0)
+    thor (0.19.1)
+    thread_safe (0.3.5)
+    tilt (2.0.5)
+    transitions (1.2.0)
+    ttfunk (1.1.1)
+    tzinfo (1.2.2)
+      thread_safe (~> 0.1)
+    uglifier (3.0.2)
+      execjs (>= 0.3.0, < 3)
+    uniform_notifier (1.10.0)
+    will_paginate (3.1.3)
+    yard (0.9.5)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  activeresource
+  acts_as_commentable
+  airbrussh
+  bcrypt
+  bullet
+  cancancan
+  capistrano (~> 3.4.0)
+  capistrano-bundler
+  capistrano-rails
+  capistrano-rvm
+  capistrano3-puma
+  cocoon
+  coffee-rails (~> 4.1.0)
+  database_cleaner
+  dotenv-rails
+  exception_notification
+  factory_girl_rails (~> 4.0)
+  faker
+  github-markdown
+  haml
+  jbuilder (~> 2.0)
+  jquery-migrate-rails
+  jquery-rails
+  jquery-ui-rails
+  letter_opener
+  localized_language_select!
+  mysql2
+  nokogiri
+  paper_trail
+  paperclip (~> 4.1)
+  pg
+  prawn (< 1.0)
+  prawn_rails
+  pry-byebug
+  pry-rails
+  puma
+  rails (~> 4.2)
+  ransack
+  redcarpet
+  ri_cal
+  roust
+  rqrcode
+  sass-rails (~> 5.0)
+  shoulda
+  simple_form
+  sqlite3
+  sucker_punch
+  transitions
+  uglifier (>= 1.3.0)
+  will_paginate
+  yard
+
+BUNDLED WITH
+   1.13.1
diff --git a/pkgs/servers/web-apps/frab/default.nix b/pkgs/servers/web-apps/frab/default.nix
new file mode 100644
index 000000000000..8ee6afaa8499
--- /dev/null
+++ b/pkgs/servers/web-apps/frab/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, bundlerEnv, fetchFromGitHub, ruby, nodejs }:
+
+let
+  env = bundlerEnv {
+    name = "frab";
+    inherit ruby;
+    gemfile = ./Gemfile;
+    lockfile = ./Gemfile.lock;
+    gemset = ./gemset.nix;
+  };
+
+in
+
+stdenv.mkDerivation rec {
+  name = "frab-2016-12-28";
+
+  src = fetchFromGitHub {
+    owner = "frab";
+    repo = "frab";
+    rev = "e4bbcfd1a9db7f89f53a8702c236d9628bafb72c";
+    sha256 = "04pzmif8jxjww3fdf2zbg3k7cm49vxc9hhf4xhmvdmvywgin6fqp";
+  };
+
+  buildInputs = [ env nodejs ];
+
+  buildPhase = ''
+    cp config/database.yml.template config/database.yml
+    cp .env.development .env.production
+    bundler exec rake assets:precompile RAILS_ENV=production
+    rm .env.production
+  '';
+
+  installPhase = ''
+    mkdir -p $out/share
+    cp -r . $out/share/frab
+
+    ln -sf /run/frab/database.yml $out/share/frab/config/database.yml
+    rm -rf $out/share/frab/tmp $out/share/frab/public/system
+    ln -sf /run/frab/system $out/share/frab/public/system
+    ln -sf /tmp $out/share/frab/tmp
+  '';
+
+  passthru = {
+    inherit env ruby;
+  };
+}
diff --git a/pkgs/servers/web-apps/frab/gemset.nix b/pkgs/servers/web-apps/frab/gemset.nix
new file mode 100644
index 000000000000..449fbf1a5b6b
--- /dev/null
+++ b/pkgs/servers/web-apps/frab/gemset.nix
@@ -0,0 +1,932 @@
+{
+  actionmailer = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0lw1pss1mrjm7x7qcg9pvxv55rz3d994yf3mwmlfg1y12fxq00n3";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  actionpack = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1ray5bvlmkimjax011zsw0mz9llfkqrfm7q1avjlp4i0kpcz8zlh";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  actionview = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11m2x5nlbqrw79fh6h7m444lrka7wwy32b0dvgqg7ilbzih43k0c";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  activejob = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0ish5wd8nvmj7f6x1i22aw5ycizy5n1z1c7f3kyxmqwhw7lb0gaz";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  activemodel = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0acz0mbmahsc9mn41275fpfnrqwig5k09m3xhz3455kv90fn79v5";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  activerecord = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1lk8l6i9p7qfl0pg261v5yph0w0sc0vysrdzc6bm5i5rxgi68flj";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  activeresource = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0nr5is20cx18s7vg8bdrdc996s2abl3h7fsi1q6mqsrzw7nrv2fa";
+      type = "gem";
+    };
+    version = "4.1.0";
+  };
+  activesupport = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1gds12k7nxrcc09b727a458ndidy1nfcllj9x22jcaj7pppvq6r4";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  acts_as_commentable = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1p4bwyqmm4ybcscn292aixschdzvns2dpl8a7w4zm0rqy2619cc9";
+      type = "gem";
+    };
+    version = "4.0.2";
+  };
+  addressable = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0mpn7sbjl477h56gmxsjqb89r5s3w7vx5af994ssgc3iamvgzgvs";
+      type = "gem";
+    };
+    version = "2.4.0";
+  };
+  airbrussh = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0pv22d2kjdbsg9q45jca3f5gsylr2r1wfpn58g58xj4s4q4r95nx";
+      type = "gem";
+    };
+    version = "1.1.1";
+  };
+  arel = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk";
+      type = "gem";
+    };
+    version = "6.0.3";
+  };
+  bcrypt = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1d254sdhdj6mzak3fb5x3jam8b94pvl1srladvs53j05a89j5z50";
+      type = "gem";
+    };
+    version = "3.1.11";
+  };
+  builder = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "14fii7ab8qszrvsvhz6z2z3i4dw0h41a62fjr2h1j8m41vbrmyv2";
+      type = "gem";
+    };
+    version = "3.2.2";
+  };
+  bullet = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "06pba7bdjnazbl0yhhvlina08nkawnm76zihkaam4k7fm0yrq1k0";
+      type = "gem";
+    };
+    version = "5.4.0";
+  };
+  byebug = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "18sdnscwwm76i2kbcib2ckwfwpq8b1dbfr97gdcx3j1x547yqv9x";
+      type = "gem";
+    };
+    version = "9.0.5";
+  };
+  cancancan = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "05kb459laaw339n7mas37v4k83nwz228bfpaghgybza347341x85";
+      type = "gem";
+    };
+    version = "1.15.0";
+  };
+  capistrano = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0f73w6gpml0ickmwky1cn6d8392q075zy10a323f3vmyvxyhr0jb";
+      type = "gem";
+    };
+    version = "3.4.1";
+  };
+  capistrano-bundler = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1f4iikm7pn0li2lj6p53wl0d6y7svn0h76z9c6c582mmwxa9c72p";
+      type = "gem";
+    };
+    version = "1.1.4";
+  };
+  capistrano-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "03lzihrq72rwcqq7jiqak79wy0xbdnymn5gxj0bfgfjlg5kpgssw";
+      type = "gem";
+    };
+    version = "1.1.8";
+  };
+  capistrano-rvm = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "15sy8zcal041yy5kb7fcdqnxvndgdhg3w1kvb5dk7hfjk3ypznsa";
+      type = "gem";
+    };
+    version = "0.1.2";
+  };
+  capistrano3-puma = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0ynz1arnr07kcl0vsaa1znhp2ywhhs4fwndnkw8sasr9bydksln8";
+      type = "gem";
+    };
+    version = "1.2.1";
+  };
+  chunky_png = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1p1zy4gyfp7rapr2yxcljkw6qh0chkwf356i387b3fg85cwdj4xh";
+      type = "gem";
+    };
+    version = "1.3.7";
+  };
+  climate_control = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0krknwk6b8lwv1j9kjbxib6kf5zh4pxkf3y2vcyycx5d6nci1s55";
+      type = "gem";
+    };
+    version = "0.0.3";
+  };
+  cocaine = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "01kk5xd7lspbkdvn6nyj0y51zhvia3z6r4nalbdcqw5fbsywwi7d";
+      type = "gem";
+    };
+    version = "0.5.8";
+  };
+  cocoon = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1gzznkrs6qy31v85cvdqyn5wd3vwlciwibf9clmd6gi4dns21pmv";
+      type = "gem";
+    };
+    version = "1.2.9";
+  };
+  coderay = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1x6z923iwr1hi04k6kz5a6llrixflz8h5sskl9mhaaxy9jx2x93r";
+      type = "gem";
+    };
+    version = "1.1.1";
+  };
+  coffee-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1mv1kaw3z4ry6cm51w8pfrbby40gqwxanrqyqr0nvs8j1bscc1gw";
+      type = "gem";
+    };
+    version = "4.1.1";
+  };
+  coffee-script = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0rc7scyk7mnpfxqv5yy4y5q1hx3i7q3ahplcp4bq2g5r24g2izl2";
+      type = "gem";
+    };
+    version = "2.4.1";
+  };
+  coffee-script-source = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1k4fg39rrkl3bpgchfj94fbl9s4ysaz16w8dkqncf2vyf79l3qz0";
+      type = "gem";
+    };
+    version = "1.10.0";
+  };
+  concurrent-ruby = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1kb4sav7yli12pjr8lscv8z49g52a5xzpfg3z9h8clzw6z74qjsw";
+      type = "gem";
+    };
+    version = "1.0.2";
+  };
+  database_cleaner = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0fx6zmqznklmkbjl6f713jyl11d4g9q220rcl86m2jp82r8kfwjj";
+      type = "gem";
+    };
+    version = "1.5.3";
+  };
+  dotenv = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1p6zz0xzb15vq8jphpw2fh6m4dianw7s76ci8vj9x3zxayrn4lfm";
+      type = "gem";
+    };
+    version = "2.1.1";
+  };
+  dotenv-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "17s6c0yqaz01xd5wywjscbvv0pa3grak2lhwby91j84qm6h95vxz";
+      type = "gem";
+    };
+    version = "2.1.1";
+  };
+  erubis = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1fj827xqjs91yqsydf0zmfyw9p4l2jz5yikg3mppz6d7fi8kyrb3";
+      type = "gem";
+    };
+    version = "2.7.0";
+  };
+  exception_notification = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1vclsr0rjfy1khvqyj67lgpa0v14nb542vvjkyaswn367nnmijhw";
+      type = "gem";
+    };
+    version = "4.2.1";
+  };
+  execjs = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1yz55sf2nd3l666ms6xr18sm2aggcvmb8qr3v53lr4rir32y1yp1";
+      type = "gem";
+    };
+    version = "2.7.0";
+  };
+  factory_girl = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1xzl4z9z390fsnyxp10c9if2n46zan3n6zwwpfnwc33crv4s410i";
+      type = "gem";
+    };
+    version = "4.7.0";
+  };
+  factory_girl_rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0hzpirb33xdqaz44i1mbcfv0icjrghhgaz747llcfsflljd4pa4r";
+      type = "gem";
+    };
+    version = "4.7.0";
+  };
+  faker = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "09amnh5d0m3q2gpb0vr9spbfa8l2nc0kl3s79y6sx7a16hrl4vvc";
+      type = "gem";
+    };
+    version = "1.6.6";
+  };
+  github-markdown = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0nax4fyyhz9xmi7q6mmc6d1h8hc0cxda9d7q5z0pba88mj00s9fj";
+      type = "gem";
+    };
+    version = "0.6.9";
+  };
+  globalid = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11plkgyl3w9k4y2scc1igvpgwyz4fnmsr63h2q4j8wkb48nlnhak";
+      type = "gem";
+    };
+    version = "0.3.7";
+  };
+  haml = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0mrzjgkygvfii66bbylj2j93na8i89998yi01fin3whwqbvx0m1p";
+      type = "gem";
+    };
+    version = "4.0.7";
+  };
+  httparty = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1msa213hclsv14ijh49i1wggf9avhnj2j4xr58m9jx6fixlbggw6";
+      type = "gem";
+    };
+    version = "0.14.0";
+  };
+  i18n = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1i5z1ykl8zhszsxcs8mzl8d0dxgs3ylz8qlzrw74jb0gplkx6758";
+      type = "gem";
+    };
+    version = "0.7.0";
+  };
+  jbuilder = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1jbh1296imd0arc9nl1m71yfd7kg505p8srr1ijpsqv4hhbz5qci";
+      type = "gem";
+    };
+    version = "2.6.0";
+  };
+  jquery-migrate-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0pcfs339wki4ax4imb4qi2xb04bbj6j4xvn8x3yn6yf95frrvch6";
+      type = "gem";
+    };
+    version = "1.2.1";
+  };
+  jquery-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0prqyixv7j2qlq67qdr3miwcyvi27b9a82j51gbpb6vcl0ig2rik";
+      type = "gem";
+    };
+    version = "4.2.1";
+  };
+  jquery-ui-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1gfygrv4bjpjd2c377lw7xzk1b77rxjyy3w6wl4bq1gkqvyrkx77";
+      type = "gem";
+    };
+    version = "5.0.5";
+  };
+  json = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1nsby6ry8l9xg3yw4adlhk2pnc7i0h0rznvcss4vk3v74qg0k8lc";
+      type = "gem";
+    };
+    version = "1.8.3";
+  };
+  launchy = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "190lfbiy1vwxhbgn4nl4dcbzxvm049jwc158r2x7kq3g5khjrxa2";
+      type = "gem";
+    };
+    version = "2.4.3";
+  };
+  letter_opener = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1pcrdbxvp2x5six8fqn8gf09bn9rd3jga76ds205yph5m8fsda21";
+      type = "gem";
+    };
+    version = "1.4.1";
+  };
+  localized_language_select = {
+    source = {
+      fetchSubmodules = false;
+      rev = "85df6b97789de6e29c630808b630e56a1b76f80c";
+      sha256 = "1b2pd8120nrl3s3idpgdzhrjkn9g5sxnkx4j671fjiyhadlr0q5j";
+      type = "git";
+      url = "git://github.com/frab/localized_language_select.git";
+    };
+    version = "0.3.0";
+  };
+  loofah = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "109ps521p0sr3kgc460d58b4pr1z4mqggan2jbsf0aajy9s6xis8";
+      type = "gem";
+    };
+    version = "2.0.3";
+  };
+  mail = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0c9vqfy0na9b5096i5i4qvrvhwamjnmajhgqi3kdsdfl8l6agmkp";
+      type = "gem";
+    };
+    version = "2.6.4";
+  };
+  method_source = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1g5i4w0dmlhzd18dijlqw5gk27bv6dj2kziqzrzb7mpgxgsd1sf2";
+      type = "gem";
+    };
+    version = "0.8.2";
+  };
+  mime-types = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0087z9kbnlqhci7fxh9f6il63hj1k02icq2rs0c6cppmqchr753m";
+      type = "gem";
+    };
+    version = "3.1";
+  };
+  mime-types-data = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "04my3746hwa4yvbx1ranhfaqkgf6vavi1kyijjnw8w3dy37vqhkm";
+      type = "gem";
+    };
+    version = "3.2016.0521";
+  };
+  mimemagic = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "101lq4bnjs7ywdcicpw3vbz9amg5gbb4va1626fybd2hawgdx8d9";
+      type = "gem";
+    };
+    version = "0.3.0";
+  };
+  mini_portile2 = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1y25adxb1hgg1wb2rn20g3vl07qziq6fz364jc5694611zz863hb";
+      type = "gem";
+    };
+    version = "2.1.0";
+  };
+  minitest = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0300naf4ilpd9sf0k8si9h9sclkizaschn8bpnri5fqmvm9ybdbq";
+      type = "gem";
+    };
+    version = "5.9.1";
+  };
+  multi_json = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1wpc23ls6v2xbk3l1qncsbz16npvmw8p0b38l8czdzri18mp51xk";
+      type = "gem";
+    };
+    version = "1.12.1";
+  };
+  multi_xml = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0i8r7dsz4z79z3j023l8swan7qpbgxbwwz11g38y2vjqjk16v4q8";
+      type = "gem";
+    };
+    version = "0.5.5";
+  };
+  mysql2 = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1v537b7865f4z610rljy8prwmq1yhk3zalp9mcbxn7aqb3g75pra";
+      type = "gem";
+    };
+    version = "0.4.4";
+  };
+  net-scp = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0b0jqrcsp4bbi4n4mzyf70cp2ysyp6x07j8k8cqgxnvb4i3a134j";
+      type = "gem";
+    };
+    version = "1.2.1";
+  };
+  net-ssh = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11djaq0h3bzzy61dca3l84rrs91702hha4vgg387gviipgz7f3yy";
+      type = "gem";
+    };
+    version = "3.2.0";
+  };
+  nokogiri = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11sbmpy60ynak6s3794q32lc99hs448msjy8rkp84ay7mq7zqspv";
+      type = "gem";
+    };
+    version = "1.6.7.2";
+  };
+  paper_trail = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1w3y2h1w0kml2fmzx4sdcrhnbj273npwrs0cx91xdgy2qfjj6hmr";
+      type = "gem";
+    };
+    version = "5.2.2";
+  };
+  paperclip = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0r8krh5xg790845wzlc2r7l0jwskw4c4wk9xh4bpprqykwaghg0r";
+      type = "gem";
+    };
+    version = "4.3.7";
+  };
+  pdf-core = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1x121sznmhfmjnk0rzpp6djxgi28afpc8avnhn3kzlmpc87r7fyi";
+      type = "gem";
+    };
+    version = "0.1.6";
+  };
+  pg = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0bplv27d0f8vwdj51967498pl1cjxq19hhcj4hdjr4h3s72l2z4j";
+      type = "gem";
+    };
+    version = "0.19.0";
+  };
+  pkg-config = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0lljiqnm0b4z6iy87lzapwrdfa6ps63x2z5zbs038iig8dqx2g0z";
+      type = "gem";
+    };
+    version = "1.1.7";
+  };
+  polyamorous = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1501y9l81b2lwb93fkycq8dr1bi6qcdhia3qv4fddnmrdihkl3pv";
+      type = "gem";
+    };
+    version = "1.3.1";
+  };
+  prawn = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "04pxzfmmy8a6bv3zvh1mmyy5zi4bj994kq1v6qnlq2xlhvg4cxjc";
+      type = "gem";
+    };
+    version = "0.15.0";
+  };
+  prawn_rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "19m1pv2rsl3rf9rni78l8137dy2sq1r2443biv19wi9nis2pvgdg";
+      type = "gem";
+    };
+    version = "0.0.11";
+  };
+  pry = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "05xbzyin63aj2prrv8fbq2d5df2mid93m81hz5bvf2v4hnzs42ar";
+      type = "gem";
+    };
+    version = "0.10.4";
+  };
+  pry-byebug = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0pvc94kgxd33p6iz41ghyadq8zfbjhkk07nvz2mbh3yhrc8w7gmw";
+      type = "gem";
+    };
+    version = "3.4.0";
+  };
+  pry-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0a2iinvabis2xmv0z7z7jmh7bbkkngxj2qixfdg5m6qj9x8k1kx6";
+      type = "gem";
+    };
+    version = "0.3.4";
+  };
+  puma = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1k13n500r7v480rcbxm7k09hip0zi7p8zvy3vajj8g9hb7gdcwnp";
+      type = "gem";
+    };
+    version = "3.9.1";
+  };
+  rack = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "09bs295yq6csjnkzj7ncj50i6chfxrhmzg1pk6p0vd2lb9ac8pj5";
+      type = "gem";
+    };
+    version = "1.6.4";
+  };
+  rack-test = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0h6x5jq24makgv2fq5qqgjlrk74dxfy62jif9blk43llw8ib2q7z";
+      type = "gem";
+    };
+    version = "0.6.3";
+  };
+  rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1avd16ir7qx23dcnz1b3cafq1lja6rq0w222bs658p9n33rbw54l";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  rails-deprecated_sanitizer = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0qxymchzdxww8bjsxj05kbf86hsmrjx40r41ksj0xsixr2gmhbbj";
+      type = "gem";
+    };
+    version = "1.0.3";
+  };
+  rails-dom-testing = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1v8jl6803mbqpxh4hn0szj081q1a3ap0nb8ni0qswi7z4la844v8";
+      type = "gem";
+    };
+    version = "1.0.7";
+  };
+  rails-html-sanitizer = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "138fd86kv073zqfx0xifm646w6bgw2lr8snk16lknrrfrss8xnm7";
+      type = "gem";
+    };
+    version = "1.0.3";
+  };
+  rails-observers = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1lsw19jzmvipvrfy2z04hi7r29dvkfc43h43vs67x6lsj9rxwwcy";
+      type = "gem";
+    };
+    version = "0.1.2";
+  };
+  railties = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "04rz7cn64zzvq7lnhc9zqmaqmqkq84q25v0ym9lcw75j1cj1mrq4";
+      type = "gem";
+    };
+    version = "4.2.7.1";
+  };
+  rake = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0cnjmbcyhm4hacpjn337mg1pnaw6hj09f74clwgh6znx8wam9xla";
+      type = "gem";
+    };
+    version = "11.3.0";
+  };
+  ransack = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0cya3wygwjhj8rckckkl387bmva4nyfvqcl0qhp9hk3zv8y6wxjc";
+      type = "gem";
+    };
+    version = "1.8.2";
+  };
+  redcarpet = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "04v85p0bnpf1c7w4n0yr03s35yimxh0idgdrrybl9y13zbw5kgvg";
+      type = "gem";
+    };
+    version = "3.3.4";
+  };
+  request_store = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1va9x0b3ww4chcfqlmi8b14db39di1mwa7qrjbh7ma0lhndvs2zv";
+      type = "gem";
+    };
+    version = "1.3.1";
+  };
+  ri_cal = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1flga63anfpfpdwz6lpm3icpdqmvjq757hihfaw63rlkwq4pf390";
+      type = "gem";
+    };
+    version = "0.8.8";
+  };
+  roust = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1zdnwxxh34psv0iybcdnk9w4dpgpr07j3w1fvigkpccgz5vs82qk";
+      type = "gem";
+    };
+    version = "1.8.9";
+  };
+  rqrcode = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0h1pnnydgs032psakvg3l779w3ghbn08ajhhhw19hpmnfhrs8k0a";
+      type = "gem";
+    };
+    version = "0.10.1";
+  };
+  sass = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0dkj6v26fkg1g0majqswwmhxva7cd6p3psrhdlx93qal72dssywy";
+      type = "gem";
+    };
+    version = "3.4.22";
+  };
+  sass-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0iji20hb8crncz14piss1b29bfb6l89sz3ai5fny3iw39vnxkdcb";
+      type = "gem";
+    };
+    version = "5.0.6";
+  };
+  shoulda = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0csmf15a7mcinfq54lfa4arp0f4b2jmwva55m0p94hdf3pxnjymy";
+      type = "gem";
+    };
+    version = "3.5.0";
+  };
+  shoulda-context = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "06wv2ika5zrbxn0m3qxwk0zkbspxids3zmlq3xxays5qmvl1qb55";
+      type = "gem";
+    };
+    version = "1.2.1";
+  };
+  shoulda-matchers = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0d3ryqcsk1n9y35bx5wxnqbgw4m8b3c79isazdjnnbg8crdp72d0";
+      type = "gem";
+    };
+    version = "2.8.0";
+  };
+  simple_form = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0ii3rkkbj5cc10f5rdiny18ncdh36kijr25cah0ybbr7kigh3v3b";
+      type = "gem";
+    };
+    version = "3.3.1";
+  };
+  slop = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "00w8g3j7k7kl8ri2cf1m58ckxk8rn350gp4chfscmgv6pq1spk3n";
+      type = "gem";
+    };
+    version = "3.6.0";
+  };
+  sprockets = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0jzsfiladswnzbrwqfiaj1xip68y58rwx0lpmj907vvq47k87gj1";
+      type = "gem";
+    };
+    version = "3.7.0";
+  };
+  sprockets-rails = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1zr9vk2vn44wcn4265hhnnnsciwlmqzqc6bnx78if1xcssxj6x44";
+      type = "gem";
+    };
+    version = "3.2.0";
+  };
+  sqlite3 = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "19r06wglnm6479ffj9dl0fa4p5j2wi6dj7k6k3d0rbx7036cv3ny";
+      type = "gem";
+    };
+    version = "1.3.11";
+  };
+  sshkit = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0wpqvr2dyxwp3shwh0221i1ahyg8vd2hyilmjvdi026l00gk2j4l";
+      type = "gem";
+    };
+    version = "1.11.3";
+  };
+  sucker_punch = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0l8b53mlzl568kdl4la8kcjjcnawmbl0q6hq9c3kkyippa5c0x55";
+      type = "gem";
+    };
+    version = "2.0.2";
+  };
+  thor = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "08p5gx18yrbnwc6xc0mxvsfaxzgy2y9i78xq7ds0qmdm67q39y4z";
+      type = "gem";
+    };
+    version = "0.19.1";
+  };
+  thread_safe = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1hq46wqsyylx5afkp6jmcihdpv4ynzzq9ygb6z2pb1cbz5js0gcr";
+      type = "gem";
+    };
+    version = "0.3.5";
+  };
+  tilt = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0lgk8bfx24959yq1cn55php3321wddw947mgj07bxfnwyipy9hqf";
+      type = "gem";
+    };
+    version = "2.0.5";
+  };
+  transitions = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "11byymi45s4pxbhj195277r16dyhxkqc2jwf7snbhan23izzay2c";
+      type = "gem";
+    };
+    version = "1.2.0";
+  };
+  ttfunk = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1jvgqhp0i6v9d7davwdn20skgi508yd0xcf1h4p9f5dlslmpnkhj";
+      type = "gem";
+    };
+    version = "1.1.1";
+  };
+  tzinfo = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1c01p3kg6xvy1cgjnzdfq45fggbwish8krd0h864jvbpybyx7cgx";
+      type = "gem";
+    };
+    version = "1.2.2";
+  };
+  uglifier = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0f30s1631k03x4wm7xyc79g92pppzvyysa773zsaq2kcry1pmifc";
+      type = "gem";
+    };
+    version = "3.0.2";
+  };
+  uniform_notifier = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1jha0l7x602g5rvah960xl9r0f3q25gslj39i0x1vai8i5z6zr1l";
+      type = "gem";
+    };
+    version = "1.10.0";
+  };
+  will_paginate = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1xlls78hkkmk33q1rb84rgg2xr39g06a1z1239nq59c825g83k01";
+      type = "gem";
+    };
+    version = "3.1.3";
+  };
+  yard = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1gjl0sh7h0a9s67pllagw8192kscljg4y8nddfrqhji4g21yvcas";
+      type = "gem";
+    };
+    version = "0.9.5";
+  };
+}
diff --git a/pkgs/servers/web-apps/matomo/bootstrap.php b/pkgs/servers/web-apps/matomo/bootstrap.php
new file mode 100644
index 000000000000..a8163f33e5c0
--- /dev/null
+++ b/pkgs/servers/web-apps/matomo/bootstrap.php
@@ -0,0 +1,6 @@
+<?php
+// get PIWIK_USER_PATH from environment variable,
+// so this bootstrap.php can be read-only but still configure PIWIK_USER_PATH at runtime
+if ($path = getenv('PIWIK_USER_PATH')) {
+  define('PIWIK_USER_PATH', $path);
+}
diff --git a/pkgs/servers/web-apps/matomo/default.nix b/pkgs/servers/web-apps/matomo/default.nix
new file mode 100644
index 000000000000..a4a26fd506bc
--- /dev/null
+++ b/pkgs/servers/web-apps/matomo/default.nix
@@ -0,0 +1,60 @@
+{ stdenv, fetchurl, makeWrapper, php }:
+
+stdenv.mkDerivation rec {
+  name = "matomo-${version}";
+  version = "3.5.1";
+
+  src = fetchurl {
+    # TODO: As soon as the tarballs are renamed as well on future releases, this should be enabled again
+    # url = "https://builds.matomo.org/${name}.tar.gz";
+    url = "https://builds.matomo.org/piwik-${version}.tar.gz";
+    sha256 = "0ifrgaw30h4d6hwwzrz8i9k036dxzkxgh71y9s0ds10lhr8vidym";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  # make-localhost-default-database-server.patch:
+  #   This changes the default value of the database server field
+  #   from 127.0.0.1 to localhost.
+  #   unix socket authentication only works with localhost,
+  #   but password-based SQL authentication works with both.
+  # TODO: is upstream interested in this?
+  # -> discussion at https://github.com/matomo-org/matomo/issues/12646
+  patches = [ ./make-localhost-default-database-host.patch ];
+
+  # this bootstrap.php adds support for getting PIWIK_USER_PATH
+  # from an environment variable. Point it to a mutable location
+  # to be able to use matomo read-only from the nix store
+  postPatch = ''
+    cp ${./bootstrap.php} bootstrap.php
+  '';
+
+  # TODO: future versions might rename the PIWIK_… variables to MATOMO_…
+  # TODO: Move more unnecessary files from share/, especially using PIWIK_INCLUDE_PATH.
+  #       See https://forum.matomo.org/t/bootstrap-php/5926/10 and
+  #       https://github.com/matomo-org/matomo/issues/11654#issuecomment-297730843
+  installPhase = ''
+    runHook preInstall
+
+    # copy evertything to share/, used as webroot folder, and then remove what's known to be not needed
+    mkdir -p $out/share
+    cp -ra * $out/share/
+    # tmp/ is created by matomo in PIWIK_USER_PATH
+    rmdir $out/share/tmp
+    # config/ needs to be copied to PIWIK_USER_PATH anyway
+    mv $out/share/config $out/
+
+    makeWrapper ${php}/bin/php $out/bin/matomo-console \
+      --add-flags "$out/share/console"
+
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A real-time web analytics application";
+    license = licenses.gpl3Plus;
+    homepage = https://matomo.org/;
+    platforms = platforms.all;
+    maintainers = [ maintainers.florianjacob ];
+  };
+}
diff --git a/pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch b/pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch
new file mode 100644
index 000000000000..48808ac2ccca
--- /dev/null
+++ b/pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch
@@ -0,0 +1,13 @@
+diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php
+index 9364f49870..2625cbb91b 100644
+--- a/plugins/Installation/FormDatabaseSetup.php
++++ b/plugins/Installation/FormDatabaseSetup.php
+@@ -82,7 +82,7 @@ class FormDatabaseSetup extends QuickForm2
+ 
+         // default values
+         $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
+-                                                                       'host'          => '127.0.0.1',
++                                                                       'host'          => 'localhost',
+                                                                        'type'          => $defaultDatabaseType,
+                                                                        'tables_prefix' => 'matomo_',
+                                                                   )));
diff --git a/pkgs/servers/web-apps/morty/default.nix b/pkgs/servers/web-apps/morty/default.nix
new file mode 100644
index 000000000000..eeb19f81c54d
--- /dev/null
+++ b/pkgs/servers/web-apps/morty/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, buildGoPackage, fetchgit }:
+
+buildGoPackage rec {
+  name = "morty-${version}";
+  version = "0.2.0";
+
+  goPackagePath = "github.com/asciimoo/morty";
+
+  src = fetchgit {
+    rev = "v${version}";
+    url = "https://github.com/asciimoo/morty";
+    sha256 = "1wvrdlwbpzizfg7wrcfyf1x6qllp3aw425n88z516wc9jalfqrrm";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/asciimoo/morty";
+    maintainers = with maintainers; [ leenaars ];
+    description = "Privacy aware web content sanitizer proxy as a service";
+    longDescription = ''
+      Morty is a web content sanitizer proxy as a service. It rewrites web
+      pages to exclude malicious HTML tags and attributes. It also replaces
+      external resource references to prevent third party information leaks.
+
+      The main goal of morty is to provide a result proxy for searx, but it
+      can be used as a standalone sanitizer service too.
+
+      Features:
+
+      * HTML sanitization
+      * Rewrites HTML/CSS external references to locals
+      * JavaScript blocking
+      * No Cookies forwarded
+      * No Referrers
+      * No Caching/Etag
+      * Supports GET/POST forms and IFrames
+      * Optional HMAC URL verifier key to prevent service abuse
+'';
+   };
+}
diff --git a/pkgs/servers/web-apps/morty/deps.nix b/pkgs/servers/web-apps/morty/deps.nix
new file mode 100644
index 000000000000..643fc5bb7636
--- /dev/null
+++ b/pkgs/servers/web-apps/morty/deps.nix
@@ -0,0 +1,57 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/klauspost/compress";
+    fetch = {
+      type = "git";
+      url = "https://github.com/klauspost/compress";
+      rev = "5698df94daded084fa836b7df2ffbf6cbd3dd63a";
+      sha256 = "1jligmzsyv08dysdaih3r95ki0dqnay9wlzganl4r0mamwhq22wz";
+    };
+  }
+  {
+    goPackagePath = "github.com/klauspost/cpuid";
+    fetch = {
+      type = "git";
+      url = "https://github.com/klauspost/cpuid";
+      rev = "ae832f27941af41db13bd6d8efd2493e3b22415a";
+      sha256 = "1h46y0lbzx0zjdnwbh0znf2ghgbvpzk1p269kkn7v8645xk3apk9";
+    };
+  }
+  {
+    goPackagePath = "github.com/valyala/bytebufferpool";
+    fetch = {
+      type = "git";
+      url = "https://github.com/valyala/bytebufferpool";
+      rev = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7";
+      sha256 = "01lqzjddq6kz9v41nkky7wbgk7f1cw036sa7ldz10d82g5klzl93";
+    };
+  }
+  {
+    goPackagePath = "github.com/valyala/fasthttp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/valyala/fasthttp";
+      rev = "e5f51c11919d4f66400334047b897ef0a94c6f3c";
+      sha256 = "0g24gys7xk449jd9ja89vr33i3amcb12jnmhsrmd5r2q8byv3l09";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "f5dfe339be1d06f81b22525fe34671ee7d2c8904";
+      sha256 = "01y9j7pjnnld4ipmzjvs0hls0hh698f2sga8cxaw5y6r5j7igaah";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "4e4a3210bb54bb31f6ab2cdca2edcc0b50c420c1";
+      sha256 = "10505r4xw1njnr2ns1s5r62s4pwif0kfaa30xxpgpz6qxrrmw15s";
+    };
+  }
+]
diff --git a/pkgs/servers/web-apps/pgpkeyserver-lite/default.nix b/pkgs/servers/web-apps/pgpkeyserver-lite/default.nix
new file mode 100644
index 000000000000..c4f49b36bf80
--- /dev/null
+++ b/pkgs/servers/web-apps/pgpkeyserver-lite/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, lib } : 
+
+stdenv.mkDerivation rec {
+  name = "pgpkeyserver-lite-${version}";
+  version = "2017-07-18";
+
+  src = fetchFromGitHub {
+    owner = "mattrude";
+    repo = "pgpkeyserver-lite";
+    rev = "a038cb7";
+    sha256 = "12pn92pcpv38b2gmamppn9yzdn7x52pgxnzpal22gqsxwimhs2rx";
+  };
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R 404.html assets favicon.ico index.html robots.txt $out
+  '';
+
+  meta = {
+    homepage = https://github.com/mattrude/pgpkeyserver-lite;
+    description = "A lightweight static front-end for a sks keyserver.";
+    license = lib.licenses.gpl3;
+    maintainers = [ lib.maintainers.calbrecht ];
+  };
+}
diff --git a/pkgs/servers/web-apps/restya-board/default.nix b/pkgs/servers/web-apps/restya-board/default.nix
new file mode 100644
index 000000000000..946606e37013
--- /dev/null
+++ b/pkgs/servers/web-apps/restya-board/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchurl, unzip }:
+
+let
+
+  hide-card-id = fetchurl {
+    url = "https://github.com/RestyaPlatform/board-apps/releases/download/v2/r_hide_card_id-v0.1.2.zip";
+    sha256 = "1scm696rs8wx0z2y0g6r9vf01b0yay79azw8n785c6zdvrbqw7dp";
+  };
+
+  togetherjs = fetchurl {
+    url = "https://github.com/RestyaPlatform/board-apps/releases/download/v2/r_togetherjs-v0.1.2.zip";
+    sha256 = "1kms7z0ci15plwbs6nxvz15w0ym3in39msbncaj3cn0p72kvx5cm";
+  };
+
+in
+
+stdenv.mkDerivation rec {
+  name = "rstya-board-${version}";
+  version = "0.6";
+
+  src = fetchurl {
+    url = "https://github.com/RestyaPlatform/board/releases/download/v${version}/board-v${version}.zip";
+    sha256 = "1js8c69qmga7bikp66fqhch3n2vw49918z32q88lz3havqzai8gd";
+  };
+
+  nativeBuildInputs = [ unzip ];
+
+  buildCommand = ''
+    mkdir $out
+    unzip -d $out $src
+
+    cd $out
+    patch -p1 < ${./fix_request-uri.patch}
+
+    chmod +x $out/server/php/shell/*.sh
+
+    mkdir $out/client/apps
+    unzip -d $out/client/apps ${hide-card-id}
+    unzip -d $out/client/apps ${togetherjs}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Web-based kanban board";
+    license = licenses.osl3;
+    homepage = http://restya.com;
+    maintainers = with maintainers; [ tstrobel ];
+    platforms = platforms.linux;
+  };
+}
+
diff --git a/pkgs/servers/web-apps/restya-board/fix_request-uri.patch b/pkgs/servers/web-apps/restya-board/fix_request-uri.patch
new file mode 100644
index 000000000000..9b96756e8299
--- /dev/null
+++ b/pkgs/servers/web-apps/restya-board/fix_request-uri.patch
@@ -0,0 +1,12 @@
+diff --git a/server/php/R/r.php b/server/php/R/r.php
+--- a/server/php/R/r.php
++++ b/server/php/R/r.php
+@@ -18,7 +18,7 @@ $r_debug = '';
+ $authUser = $client = $form = array();
+ $_server_protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https' : 'http';
+ $_server_domain_url = $_server_protocol . '://' . $_SERVER['HTTP_HOST']; // http://localhost
+-header('x-response-url:' . $_SERVER[REQUEST_URI]);
++header('x-response-url:' . $_SERVER['REQUEST_URI']);
+ header('Access-Control-Allow-Origin: *');
+ header('Access-Control-Allow-Methods: *');
+ require_once '../config.inc.php';
diff --git a/pkgs/servers/web-apps/searx/default.nix b/pkgs/servers/web-apps/searx/default.nix
new file mode 100644
index 000000000000..3835f5ae3324
--- /dev/null
+++ b/pkgs/servers/web-apps/searx/default.nix
@@ -0,0 +1,47 @@
+{ lib, pythonPackages, fetchFromGitHub }:
+
+with pythonPackages;
+
+buildPythonApplication rec {
+  pname = "searx";
+  version = "0.14.0";
+
+  # Can not use PyPI because certain test files are missing.
+  src = fetchFromGitHub {
+    owner = "asciimoo";
+    repo = "searx";
+    rev = "v${version}";
+    sha256 = "046xg6xcs1mxgahz7kwf3fsmwd99q3hhms6pdjlvyczidlfhpmxl";
+  };
+
+  postPatch = ''
+    substituteInPlace requirements.txt \
+      --replace 'certifi==2017.11.5' 'certifi' \
+      --replace 'flask==0.12.2' 'flask==0.12.*' \
+      --replace 'flask-babel==0.11.2' 'flask-babel==0.11.*' \
+      --replace 'lxml==4.1.1' 'lxml==4.1.*' \
+      --replace 'idna==2.5' 'idna' \
+      --replace 'pygments==2.1.3' 'pygments>=2.1,<3.0' \
+      --replace 'pyopenssl==17.4.0' 'pyopenssl' \
+      --replace 'python-dateutil==2.6.1' 'python-dateutil==2.6.*'
+  '';
+
+  propagatedBuildInputs = [
+    pyyaml lxml grequests flaskbabel flask requests
+    gevent speaklater Babel pytz dateutil pygments
+    pyasn1 pyasn1-modules ndg-httpsclient certifi pysocks
+  ];
+
+  checkInputs = [ splinter mock plone-testing robotsuite unittest2 ];
+
+  preCheck = ''
+    rm tests/test_robot.py # A variable that is imported is commented out
+  '';
+
+  meta = with lib; {
+    homepage = https://github.com/asciimoo/searx;
+    description = "A privacy-respecting, hackable metasearch engine";
+    license = licenses.agpl3Plus;
+    maintainers = with maintainers; [ matejc fpletz ];
+  };
+}
diff --git a/pkgs/servers/web-apps/selfoss/default.nix b/pkgs/servers/web-apps/selfoss/default.nix
new file mode 100644
index 000000000000..4ed9d96510c8
--- /dev/null
+++ b/pkgs/servers/web-apps/selfoss/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, unzip }:
+
+stdenv.mkDerivation rec {
+  name = "selfoss-${version}";
+  version = "2.18";
+
+  src = fetchurl {
+    url = "https://github.com/SSilence/selfoss/releases/download/${version}/${name}.zip";
+    sha256 = "1vd699r1kjc34n8avggckx2b0daj5rmgrj997sggjw2inaq4cg8b";
+  };
+
+  sourceRoot = ".";
+  nativeBuildInputs = [ unzip ];
+
+  installPhase = ''
+    mkdir $out
+    cp -ra * $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Web-based news feed (RSS/Atom) aggregator";
+    license = licenses.gpl3;
+    homepage = http://http://selfoss.aditu.de/;
+    platforms = platforms.all;
+    maintainers = [ maintainers.regnat ];
+  };
+}
+
diff --git a/pkgs/servers/web-apps/shaarli/default.nix b/pkgs/servers/web-apps/shaarli/default.nix
new file mode 100644
index 000000000000..8f6722ed86ec
--- /dev/null
+++ b/pkgs/servers/web-apps/shaarli/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "shaarli-${version}";
+  version = "0.9.6";
+
+  src = fetchurl {
+    url = "https://github.com/shaarli/Shaarli/releases/download/v${version}/shaarli-v${version}-full.tar.gz";
+    sha256 = "0vi59988bjxb1cyifh0fynpxa7l6cl0v57hrxima5c9iid10pw54";
+  };
+
+  outputs = [ "out" "doc" ];
+
+  patchPhase = ''
+    substituteInPlace index.php \
+      --replace "new ConfigManager();" "new ConfigManager(getenv('SHAARLI_CONFIG'));"
+  '';
+
+#    Point $SHAARLI_CONFIG to your configuration file, see https://github.com/shaarli/Shaarli/wiki/Shaarli-configuration.
+#    For example:
+#      <?php /*
+#      {
+#          "credentials": {
+#              "login": "user",
+#              "hash": "(password hash)",
+#              "salt": "(password salt)"
+#          },
+#          "resource": {
+#              "data_dir": "\/var\/lib\/shaarli",
+#              "config": "\/var\/lib\/shaarli\/config.json.php",
+#              "datastore": "\/var\/lib\/shaarli\/datastore.php",
+#              "ban_file": "\/var\/lib\/shaarli\/ipbans.php",
+#              "updates": "\/var\/lib\/shaarli\/updates.txt",
+#              "log": "\/var\/lib\/shaarli\/log.txt",
+#              "update_check": "\/var\/lib\/shaarli\/lastupdatecheck.txt",
+#              "raintpl_tmp": "\/var\/lib\/shaarli\/tmp",
+#              "thumbnails_cache": "\/var\/lib\/shaarli\/cache",
+#              "page_cache": "\/var\/lib\/shaarli\/pagecache"
+#          },
+#          "updates": {
+#              "check_updates": false
+#          }
+#      }
+#      */ ?>
+
+  installPhase = ''
+    rm -r {cache,pagecache,tmp,data}/
+    mkdir -p $doc/share/doc
+    mv doc/ $doc/share/doc/shaarli
+    mkdir $out/
+    cp -R ./* $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "The personal, minimalist, super-fast, database free, bookmarking service";
+    license = licenses.gpl3Plus;
+    homepage = https://github.com/shaarli/Shaarli;
+    maintainers = with maintainers; [ schneefux ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/web-apps/shaarli/material-theme.nix b/pkgs/servers/web-apps/shaarli/material-theme.nix
new file mode 100644
index 000000000000..939976b0a269
--- /dev/null
+++ b/pkgs/servers/web-apps/shaarli/material-theme.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  name = "shaarli-material-${version}";
+  version = "0.9.5";
+
+  src = fetchFromGitHub {
+    owner = "kalvn";
+    repo = "Shaarli-Material";
+    rev = "v${version}";
+    sha256 = "1bxw74ksvfv46995iwc7jhvl78hd84lcq3h9iyxvs8gpkhkapv55";
+  };
+
+  patchPhase = ''
+    for f in material/*.html
+    do
+      substituteInPlace $f \
+        --replace '.min.css?v={$version_hash}"' '.min.css#"' \
+        --replace '.min.js?v={$version_hash}"'  '.min.js#"' \
+        --replace '.png"'     '.png#"'
+    done
+  '';
+
+  installPhase = ''
+    mv material/ $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A theme base on Google's Material Design for Shaarli, the superfast delicious clone";
+    license = licenses.mit;
+    homepage = https://github.com/kalvn/Shaarli-Material;
+    maintainers = with maintainers; [ schneefux ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/web-apps/wallabag/default.nix b/pkgs/servers/web-apps/wallabag/default.nix
new file mode 100644
index 000000000000..c0d5876a3a2d
--- /dev/null
+++ b/pkgs/servers/web-apps/wallabag/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "wallabag-${version}";
+  version = "2.3.2";
+
+  # remember to rm -r var/cache/* after a rebuild or unexpected errors will occur
+
+  src = fetchurl {
+    url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz";
+    sha256 = "17yczdvgl43j6wa7hksxi2b51afvyd56vdya6hbbv68iiba4jyh4";
+  };
+
+  outputs = [ "out" ];
+
+  patches = [ ./wallabag-data.patch ]; # exposes $WALLABAG_DATA
+
+  prePatch = ''
+    rm Makefile # use the "shared hosting" package with bundled dependencies
+  '';
+
+  installPhase = ''
+    mkdir $out/
+    cp -R * $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Web page archiver";
+    longDescription = ''
+      wallabag is a self hostable application for saving web pages.
+
+      Point the environment variable $WALLABAG_DATA to a data directory that contains the folder `app/config` which must be a clone of wallabag's configuration files with your customized `parameters.yml`. These need to be updated every package upgrade.
+      After a package upgrade, empty the `var/cache` folder.
+    '';
+    license = licenses.mit;
+    homepage = http://wallabag.org;
+    maintainers = with maintainers; [ schneefux ];
+    platforms = platforms.all;
+  };
+}
+
diff --git a/pkgs/servers/web-apps/wallabag/wallabag-data.patch b/pkgs/servers/web-apps/wallabag/wallabag-data.patch
new file mode 100644
index 000000000000..086e93959800
--- /dev/null
+++ b/pkgs/servers/web-apps/wallabag/wallabag-data.patch
@@ -0,0 +1,26 @@
+diff --git a/app/AppKernel.php b/app/AppKernel.php
+index 40726f05..7d44e600 100644
+--- a/app/AppKernel.php
++++ b/app/AppKernel.php
+@@ -58,14 +58,19 @@ class AppKernel extends Kernel
+         return $bundles;
+     }
+ 
++    public function getProjectDir()
++    {
++        return getenv('WALLABAG_DATA') ?: dirname(__DIR__);
++    }
++
+     public function getCacheDir()
+     {
+-        return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
++        return $this->getProjectDir() . '/var/cache/' . $this->getEnvironment();
+     }
+ 
+     public function getLogDir()
+     {
+-        return dirname(__DIR__) . '/var/logs';
++        return $this->getProjectDir() . '/var/logs';
+     }
+ 
+     public function registerContainerConfiguration(LoaderInterface $loader)
diff --git a/pkgs/servers/web-apps/wordpress/default.nix b/pkgs/servers/web-apps/wordpress/default.nix
new file mode 100644
index 000000000000..57254713f4b0
--- /dev/null
+++ b/pkgs/servers/web-apps/wordpress/default.nix
@@ -0,0 +1,13 @@
+  # Upgrading? We have a test! nix-build ./nixos/tests/wordpress.nix
+{ fetchFromGitHub, lib } : fetchFromGitHub {
+  owner = "WordPress";
+  repo = "WordPress";
+  rev = "4.9.1";
+  sha256 = "0d931mv6wbgnc7f15nisnn5al0ffi19zya2iwdzw98s4klpaq955";
+  meta = {
+    homepage = https://wordpress.org;
+    description = "WordPress is open source software you can use to create a beautiful website, blog, or app.";
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.basvandijk ];
+  };
+}
diff --git a/pkgs/servers/webmetro/default.nix b/pkgs/servers/webmetro/default.nix
new file mode 100644
index 000000000000..45369f5f5a06
--- /dev/null
+++ b/pkgs/servers/webmetro/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, rustPlatform }:
+
+rustPlatform.buildRustPackage rec {
+  pname = "webmetro";
+  name = "${pname}-${version}";
+  version = "unstable-20180426";
+
+  src = fetchFromGitHub {
+    owner = "Tangent128";
+    repo = pname;
+    rev = "4f6cc00fe647bd311d00a8a4cb53ab08f20a04f9";
+    sha256 = "1n2c7ygs8qsd5zgii6fqqcwg427bsij082bg4ijnzkq5630dx651";
+  };
+
+  cargoSha256 = "0drf331qic1gf58j7izwp0q2l4w0dyrhr19rd2y5k43cw4m1nq59";
+
+  meta = with stdenv.lib; {
+    description = "Simple relay server for broadcasting a WebM stream";
+    longDescription = ''
+    Webmetro is a simple relay server for broadcasting a WebM stream
+    from one uploader to many downloaders, via HTTP.
+    The initialization segment is remembered, so that viewers can join
+    mid-stream.  Cluster timestamps are rewritten to be monotonic, so multiple
+    (compatibly-encoded) webm files can be chained together without
+    clients needing to reconnect.
+    '';
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ leenaars ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/servers/x11/quartz-wm/default.nix b/pkgs/servers/x11/quartz-wm/default.nix
index 8f5885a48565..d724a81debbb 100644
--- a/pkgs/servers/x11/quartz-wm/default.nix
+++ b/pkgs/servers/x11/quartz-wm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, xorg, pixman, pkgconfig }:
+{ stdenv, lib, fetchurl, xorg, pixman, pkgconfig, AppKit, Xplugin, darwin }:
 
 let version = "1.3.1";
 in stdenv.mkDerivation {
@@ -19,9 +19,11 @@ in stdenv.mkDerivation {
     xorg.libXext
     pixman
     pkgconfig
+    AppKit Xplugin darwin.apple_sdk.frameworks.Foundation
   ];
   meta = with lib; {
     license = licenses.apsl20;
     platforms = platforms.darwin;
+    maintainers = with maintainers; [ matthewbauer ];
   };
 }
diff --git a/pkgs/servers/x11/xorg/builder.sh b/pkgs/servers/x11/xorg/builder.sh
index f5b8803a98a3..5a832cb14d53 100644
--- a/pkgs/servers/x11/xorg/builder.sh
+++ b/pkgs/servers/x11/xorg/builder.sh
@@ -10,33 +10,20 @@ postInstall() {
 
     local r p requires
     set +o pipefail
-    requires=$(grep "Requires:" $out/lib/pkgconfig/*.pc | \
+    requires=$(grep "Requires:" ${!outputDev}/lib/pkgconfig/*.pc | \
         sed "s/Requires://" | sed "s/,/ /g")
     set -o pipefail
 
     echo "propagating requisites $requires"
 
     for r in $requires; do
-        if test -n "$crossConfig"; then
-            for p in $crossPkgs; do
-                if test -e $p/lib/pkgconfig/$r.pc; then
-                    echo "  found requisite $r in $p"
-                    propagatedBuildInputs="$propagatedBuildInputs $p"
-                fi
-            done
-        else
-            for p in $nativePkgs; do
-                if test -e $p/lib/pkgconfig/$r.pc; then
-                    echo "  found requisite $r in $p"
-                    propagatedNativeBuildInputs="$propagatedNativeBuildInputs $p"
-                fi
-            done
-        fi
+        for p in "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}"; do
+            if test -e $p/lib/pkgconfig/$r.pc; then
+                echo "  found requisite $r in $p"
+                propagatedBuildInputs+=" $p"
+            fi
+        done
     done
-
-    mkdir -p "$out/nix-support"
-    echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
-    echo "$propagatedNativeBuildInputs" > "$out/nix-support/propagated-native-build-inputs"
 }
 
 
@@ -50,5 +37,4 @@ fi
 
 enableParallelBuilding=1
 
-
 genericBuild
diff --git a/pkgs/servers/x11/xorg/darwin/0001-XQuartz-GLX-Use-__glXEnableExtension-to-build-extens.patch b/pkgs/servers/x11/xorg/darwin/0001-XQuartz-GLX-Use-__glXEnableExtension-to-build-extens.patch
deleted file mode 100644
index ff297a8df96a..000000000000
--- a/pkgs/servers/x11/xorg/darwin/0001-XQuartz-GLX-Use-__glXEnableExtension-to-build-extens.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-From fff30cdea46616eb92f4dd9402ebd27fdb55e13b Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Date: Sun, 1 Jun 2014 04:29:19 -0700
-Subject: [PATCH 1/6] XQuartz: GLX: Use __glXEnableExtension to build
- extensions list
-
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-(cherry picked from commit 3790001ea29658872aebda00a03170e392b47878)
----
- hw/xquartz/GL/indirect.c | 37 +++++++++++++++++++++++++++++++------
- 1 file changed, 31 insertions(+), 6 deletions(-)
-
-diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
-index 19b7d86..4e6ab3d 100644
---- a/hw/xquartz/GL/indirect.c
-+++ b/hw/xquartz/GL/indirect.c
-@@ -52,6 +52,7 @@
- 
- #include "visualConfigs.h"
- #include "dri.h"
-+#include "extension_string.h"
- 
- #include "darwin.h"
- #define GLAQUA_DEBUG_MSG(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", \
-@@ -111,6 +112,10 @@ typedef struct __GLXAquaDrawable __GLXAquaDrawable;
-  */
- struct __GLXAquaScreen {
-     __GLXscreen base;
-+
-+    /* Supported GLX extensions */
-+    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
-+
-     int index;
-     int num_vis;
- };
-@@ -541,13 +546,33 @@ __glXAquaScreenProbe(ScreenPtr pScreen)
- 
-     screen->base.GLXmajor = 1;
-     screen->base.GLXminor = 4;
--    screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
--                                        "GLX_SGIS_multisample "
--                                        "GLX_ARB_multisample "
--                                        "GLX_EXT_visual_info "
--                                        "GLX_EXT_import_context ");
- 
--    /*We may be able to add more GLXextensions at a later time. */
-+    memset(screen->glx_enable_bits, 0, __GLX_EXT_BYTES);
-+
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_info");
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_rating");
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_import_context");
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_OML_swap_method");
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_fbconfig");
-+
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIS_multisample");
-+    __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_multisample");
-+
-+    //__glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_create_context");
-+    //__glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_create_context_profile");
-+
-+    // Generate the GLX extensions string (overrides that set by __glXScreenInit())
-+    {
-+        unsigned int buffer_size =
-+            __glXGetExtensionString(screen->glx_enable_bits, NULL);
-+        if (buffer_size > 0) {
-+            free(screen->base.GLXextensions);
-+
-+            screen->base.GLXextensions = xnfalloc(buffer_size);
-+            __glXGetExtensionString(screen->glx_enable_bits,
-+                                    screen->base.GLXextensions);
-+        }
-+    }
- 
-     return &screen->base;
- }
--- 
-2.3.2 (Apple Git-55)
-
diff --git a/pkgs/servers/x11/xorg/darwin/0002-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch b/pkgs/servers/x11/xorg/darwin/0002-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch
deleted file mode 100644
index ed0518da5ce1..000000000000
--- a/pkgs/servers/x11/xorg/darwin/0002-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 91971455ee46b1059de75260ef0d1a45170d8b65 Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston <jeremyhu@apple.com>
-Date: Fri, 13 Jan 2012 12:00:57 -0800
-Subject: [PATCH 2/6] sdksyms.sh: Use CPPFLAGS, not CFLAGS
-
-CFLAGS can include flags which are not useful to the preprocessor
-or can even cause it to fail.  This fixes a build issue on darwin
-when building for more than one architecture.
-
-Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-Reviewed-by: Keith Packard <keithp@keithp.com>
----
- hw/xfree86/Makefile.am | 5 ++---
- 1 file changed, 2 insertions(+), 3 deletions(-)
-
-diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
-index 27f2cc6..d898c43 100644
---- a/hw/xfree86/Makefile.am
-+++ b/hw/xfree86/Makefile.am
-@@ -48,8 +48,7 @@ DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
- bin_PROGRAMS = Xorg
- nodist_Xorg_SOURCES = sdksyms.c
- 
--AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
--AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
-+AM_CPPFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
- 	-I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac \
- 	-I$(srcdir)/dri -I$(srcdir)/dri2 -I$(top_srcdir)/dri3
- 
-@@ -135,7 +134,7 @@ CLEANFILES = sdksyms.c sdksyms.dep Xorg.sh
- EXTRA_DIST += sdksyms.sh
- 
- sdksyms.dep sdksyms.c: sdksyms.sh
--	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS)
-+	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CPPFLAGS) $(AM_CPPFLAGS)
- 
- SDKSYMS_DEP = sdksyms.dep
- -include $(SDKSYMS_DEP)
--- 
-2.3.2 (Apple Git-55)
-
diff --git a/pkgs/servers/x11/xorg/darwin/0003-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch b/pkgs/servers/x11/xorg/darwin/0003-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch
deleted file mode 100644
index 395853f940fe..000000000000
--- a/pkgs/servers/x11/xorg/darwin/0003-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch
+++ /dev/null
@@ -1,165 +0,0 @@
-From fa5c83fe9129c9cd9cde1420a32112ca2f17566c Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston <jeremyhu@apple.com>
-Date: Fri, 30 Apr 2010 13:08:25 -0700
-Subject: [PATCH 3/6] Workaround the GC clipping problem in miPaintWindow and
- add some debugging output.
-
-Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
----
- mi/miexpose.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
- 1 file changed, 94 insertions(+), 10 deletions(-)
-
-diff --git a/mi/miexpose.c b/mi/miexpose.c
-index fc4dbc0..5e31b83 100644
---- a/mi/miexpose.c
-+++ b/mi/miexpose.c
-@@ -408,7 +408,8 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
- void RootlessStartDrawing(WindowPtr pWin);
- void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
- Bool IsFramedWindow(WindowPtr pWin);
--#endif
-+#include "../fb/fb.h"
-+#endif 
- 
- void
- miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
-@@ -437,23 +438,37 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
-     Bool solid = TRUE;
-     DrawablePtr drawable = &pWin->drawable;
- 
-+#ifdef XQUARTZ_CLIP_DEBUG
-+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
-+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
-+	                               prgn->extents.x2 - prgn->extents.x1,
-+	                               prgn->extents.y2 - prgn->extents.y1);
-+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
-+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
-+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
-+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
-+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
-+				       pWin->drawable.width, pWin->drawable.height);
-+#endif
-+
- #ifdef ROOTLESS
-     if (!drawable || drawable->type == UNDRAWABLE_WINDOW)
-         return;
-+#endif
-+    
-+    if (what == PW_BACKGROUND)
-+    {
-+#ifdef ROOTLESS
-+        if(IsFramedWindow(pWin)) {
-+            RootlessStartDrawing(pWin);
-+            RootlessDamageRegion(pWin, prgn);
- 
--    if (IsFramedWindow(pWin)) {
--        RootlessStartDrawing(pWin);
--        RootlessDamageRegion(pWin, prgn);
--
--        if (pWin->backgroundState == ParentRelative) {
--            if ((what == PW_BACKGROUND) ||
--                (what == PW_BORDER && !pWin->borderIsPixel))
-+            if(pWin->backgroundState == ParentRelative) {
-                 RootlessSetPixmapOfAncestors(pWin);
-+            }
-         }
--    }
- #endif
- 
--    if (what == PW_BACKGROUND) {
-         while (pWin->backgroundState == ParentRelative)
-             pWin = pWin->parent;
- 
-@@ -478,6 +493,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
-     else {
-         PixmapPtr pixmap;
- 
-+#ifdef ROOTLESS
-+	if(IsFramedWindow(pWin)) {
-+	    RootlessStartDrawing(pWin);
-+	    RootlessDamageRegion(pWin, prgn);
-+	    
-+	    if(!pWin->borderIsPixel &&
-+		pWin->backgroundState == ParentRelative) {
-+		RootlessSetPixmapOfAncestors(pWin);
-+	    }
-+	}
-+#endif
-+
-         tile_x_off = drawable->x;
-         tile_y_off = drawable->y;
- 
-@@ -486,6 +513,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
-             return;
-         pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
-         drawable = &pixmap->drawable;
-+
-+#ifdef XQUARTZ_CLIP_DEBUG
-+        ErrorF("     Draw: %d %d %d %d\n",
-+               drawable->x, drawable->y, drawable->width, drawable->height);    
-+#endif
-+	
- #ifdef COMPOSITE
-         draw_x_off = pixmap->screen_x;
-         draw_y_off = pixmap->screen_y;
-@@ -548,6 +581,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
-     ChangeGC(NullClient, pGC, gcmask, gcval);
-     ValidateGC(drawable, pGC);
- 
-+#ifdef XQUARTZ_CLIP_DEBUG
-+    ErrorF("       GC: %d %d %d %d\n",
-+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
-+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
-+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
-+#endif
-+    
-+#ifdef XQUARTZ
-+    /* Looks like our clipping isn't set right for some reason:
-+     * http://xquartz.macosforge.org/trac/ticket/290
-+     */
-+    if(what == PW_BORDER) {
-+
-+#if 0
-+	if(solid) {
-+#if 1
-+	    fbFillRegionSolid(&pWin->drawable,
-+			      prgn,
-+			      0,
-+			      fbReplicatePixel(fill.pixel,
-+					       pWin->drawable.bitsPerPixel));
-+#else
-+	    fbFillRegionSolid(drawable,
-+			      prgn,
-+			      0,
-+			      fbReplicatePixel(fill.pixel,
-+					       drawable->bitsPerPixel));
-+#endif
-+	    return;
-+	}
-+#endif
-+    
-+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
-+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
-+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
-+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
-+	
-+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
-+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
-+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
-+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
-+    }
-+#endif
-+
-+#ifdef XQUARTZ_CLIP_DEBUG
-+    ErrorF("       GC: %d %d %d %d\n",
-+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
-+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
-+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
-+#endif
-+
-     numRects = RegionNumRects(prgn);
-     pbox = RegionRects(prgn);
-     for (i = numRects; --i >= 0; pbox++, prect++) {
--- 
-2.3.2 (Apple Git-55)
-
diff --git a/pkgs/servers/x11/xorg/darwin/0004-Use-old-miTrapezoids-and-miTriangles-routines.patch b/pkgs/servers/x11/xorg/darwin/0004-Use-old-miTrapezoids-and-miTriangles-routines.patch
deleted file mode 100644
index 4027227bb53f..000000000000
--- a/pkgs/servers/x11/xorg/darwin/0004-Use-old-miTrapezoids-and-miTriangles-routines.patch
+++ /dev/null
@@ -1,297 +0,0 @@
-From b229a04bde765424542eeba17a7e2bc25785a890 Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Date: Sat, 2 Nov 2013 11:00:23 -0700
-Subject: [PATCH 4/6] Use old miTrapezoids and miTriangles routines
-
-Reverts commits:
-    788ccb9a8bcf6a4fb4054c507111eec3338fb969
-    566f1931ee2916269e164e114bffaf2da1d039d1
-
-http://xquartz.macosforge.org/trac/ticket/525
-
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
----
- fb/fbpict.c     |   2 -
- render/mipict.c |   4 +-
- render/mipict.h |  27 ++++++++++++++
- render/mitrap.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- render/mitri.c  |  61 +++++++++++++++++++++++++++++++
- 5 files changed, 201 insertions(+), 4 deletions(-)
-
-diff --git a/fb/fbpict.c b/fb/fbpict.c
-index c8378ad..cafb027 100644
---- a/fb/fbpict.c
-+++ b/fb/fbpict.c
-@@ -499,10 +499,8 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
-     ps->UnrealizeGlyph = fbUnrealizeGlyph;
-     ps->CompositeRects = miCompositeRects;
-     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
--    ps->Trapezoids = fbTrapezoids;
-     ps->AddTraps = fbAddTraps;
-     ps->AddTriangles = fbAddTriangles;
--    ps->Triangles = fbTriangles;
- 
-     return TRUE;
- }
-diff --git a/render/mipict.c b/render/mipict.c
-index a725104..e14293a 100644
---- a/render/mipict.c
-+++ b/render/mipict.c
-@@ -575,8 +575,8 @@ miPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
-     ps->Composite = 0;          /* requires DDX support */
-     ps->Glyphs = miGlyphs;
-     ps->CompositeRects = miCompositeRects;
--    ps->Trapezoids = 0;
--    ps->Triangles = 0;
-+    ps->Trapezoids = miTrapezoids;
-+    ps->Triangles = miTriangles;
- 
-     ps->RasterizeTrapezoid = 0; /* requires DDX support */
-     ps->AddTraps = 0;           /* requires DDX support */
-diff --git a/render/mipict.h b/render/mipict.h
-index 23ce9e8..e0f1d4c 100644
---- a/render/mipict.h
-+++ b/render/mipict.h
-@@ -122,6 +122,16 @@ miCompositeRects(CARD8 op,
-                  xRenderColor * color, int nRect, xRectangle *rects);
- 
- extern _X_EXPORT void
-+miTriangles (CARD8	    op,
-+	     PicturePtr	    pSrc,
-+	     PicturePtr	    pDst,
-+	     PictFormatPtr  maskFormat,
-+	     INT16	    xSrc,
-+	     INT16	    ySrc,
-+	     int	    ntri,
-+	     xTriangle	    *tris);
-+
-+extern _X_EXPORT void
- 
- miTriStrip(CARD8 op,
-            PicturePtr pSrc,
-@@ -137,10 +147,27 @@ miTriFan(CARD8 op,
-          PictFormatPtr maskFormat,
-          INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
- 
-+extern _X_EXPORT PicturePtr
-+miCreateAlphaPicture (ScreenPtr	    pScreen, 
-+		      PicturePtr    pDst,
-+		      PictFormatPtr pPictFormat,
-+		      CARD16	    width,
-+		      CARD16	    height);
-+
- extern _X_EXPORT void
-  miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box);
- 
- extern _X_EXPORT void
-+miTrapezoids (CARD8        op,
-+             PicturePtr    pSrc,
-+             PicturePtr    pDst,
-+             PictFormatPtr maskFormat,
-+             INT16         xSrc,
-+             INT16         ySrc,
-+             int           ntrap,
-+             xTrapezoid    *traps);
-+
-+extern _X_EXPORT void
-  miPointFixedBounds(int npoint, xPointFixed * points, BoxPtr bounds);
- 
- extern _X_EXPORT void
-diff --git a/render/mitrap.c b/render/mitrap.c
-index 17b6dcd..71c1857 100644
---- a/render/mitrap.c
-+++ b/render/mitrap.c
-@@ -34,6 +34,55 @@
- #include "picturestr.h"
- #include "mipict.h"
- 
-+PicturePtr
-+miCreateAlphaPicture (ScreenPtr	    pScreen, 
-+		      PicturePtr    pDst,
-+		      PictFormatPtr pPictFormat,
-+		      CARD16	    width,
-+		      CARD16	    height)
-+{
-+    PixmapPtr	    pPixmap;
-+    PicturePtr	    pPicture;
-+    GCPtr	    pGC;
-+    int		    error;
-+    xRectangle	    rect;
-+
-+    if (width > 32767 || height > 32767)
-+	return 0;
-+
-+    if (!pPictFormat)
-+    {
-+	if (pDst->polyEdge == PolyEdgeSharp)
-+	    pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
-+	else
-+	    pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
-+	if (!pPictFormat)
-+	    return 0;
-+    }
-+
-+    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 
-+					pPictFormat->depth, 0);
-+    if (!pPixmap)
-+	return 0;
-+    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
-+    if (!pGC)
-+    {
-+	(*pScreen->DestroyPixmap) (pPixmap);
-+	return 0;
-+    }
-+    ValidateGC (&pPixmap->drawable, pGC);
-+    rect.x = 0;
-+    rect.y = 0;
-+    rect.width = width;
-+    rect.height = height;
-+    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
-+    FreeScratchGC (pGC);
-+    pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
-+			      0, 0, serverClient, &error);
-+    (*pScreen->DestroyPixmap) (pPixmap);
-+    return pPicture;
-+}
-+
- static xFixed
- miLineFixedX(xLineFixed * l, xFixed y, Bool ceil)
- {
-@@ -79,3 +128,65 @@ miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box)
-             box->x2 = x2;
-     }
- }
-+
-+
-+void
-+miTrapezoids (CARD8        op,
-+             PicturePtr    pSrc,
-+             PicturePtr    pDst,
-+             PictFormatPtr maskFormat,
-+             INT16         xSrc,
-+             INT16         ySrc,
-+             int           ntrap,
-+             xTrapezoid    *traps)
-+{
-+    ScreenPtr          pScreen = pDst->pDrawable->pScreen;
-+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
-+
-+    /*
-+     * Check for solid alpha add
-+     */
-+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
-+    {
-+       for (; ntrap; ntrap--, traps++)
-+           (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
-+    } 
-+    else if (maskFormat)
-+    {
-+       PicturePtr      pPicture;
-+       BoxRec          bounds;
-+       INT16           xDst, yDst;
-+       INT16           xRel, yRel;
-+       
-+       xDst = traps[0].left.p1.x >> 16;
-+       yDst = traps[0].left.p1.y >> 16;
-+
-+       miTrapezoidBounds (ntrap, traps, &bounds);
-+       if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
-+           return;
-+       pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
-+                                        bounds.x2 - bounds.x1,
-+                                        bounds.y2 - bounds.y1);
-+       if (!pPicture)
-+           return;
-+       for (; ntrap; ntrap--, traps++)
-+           (*ps->RasterizeTrapezoid) (pPicture, traps, 
-+                                      -bounds.x1, -bounds.y1);
-+       xRel = bounds.x1 + xSrc - xDst;
-+       yRel = bounds.y1 + ySrc - yDst;
-+       CompositePicture (op, pSrc, pPicture, pDst,
-+                         xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-+                         bounds.x2 - bounds.x1,
-+                         bounds.y2 - bounds.y1);
-+       FreePicture (pPicture, 0);
-+    }
-+    else
-+    {
-+       if (pDst->polyEdge == PolyEdgeSharp)
-+           maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
-+       else
-+           maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
-+       for (; ntrap; ntrap--, traps++)
-+           miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
-+    }
-+}
-diff --git a/render/mitri.c b/render/mitri.c
-index 922f22a..bdca9ca 100644
---- a/render/mitri.c
-+++ b/render/mitri.c
-@@ -65,3 +65,64 @@ miTriangleBounds(int ntri, xTriangle * tris, BoxPtr bounds)
- {
-     miPointFixedBounds(ntri * 3, (xPointFixed *) tris, bounds);
- }
-+
-+
-+void
-+miTriangles (CARD8	    op,
-+	     PicturePtr	    pSrc,
-+	     PicturePtr	    pDst,
-+	     PictFormatPtr  maskFormat,
-+	     INT16	    xSrc,
-+	     INT16	    ySrc,
-+	     int	    ntri,
-+	     xTriangle	    *tris)
-+{
-+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
-+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
-+    
-+    /*
-+     * Check for solid alpha add
-+     */
-+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
-+    {
-+	(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
-+    }
-+    else if (maskFormat)
-+    {
-+	BoxRec		bounds;
-+	PicturePtr	pPicture;
-+	INT16		xDst, yDst;
-+	INT16		xRel, yRel;
-+	
-+	xDst = tris[0].p1.x >> 16;
-+	yDst = tris[0].p1.y >> 16;
-+
-+	miTriangleBounds (ntri, tris, &bounds);
-+	if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
-+	    return;
-+	pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
-+					 bounds.x2 - bounds.x1,
-+					 bounds.y2 - bounds.y1);
-+	if (!pPicture)
-+	    return;
-+	(*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
-+	
-+	xRel = bounds.x1 + xSrc - xDst;
-+	yRel = bounds.y1 + ySrc - yDst;
-+	CompositePicture (op, pSrc, pPicture, pDst,
-+			  xRel, yRel, 0, 0, bounds.x1, bounds.y1,
-+			  bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
-+	FreePicture (pPicture, 0);
-+    }
-+    else
-+    {
-+	if (pDst->polyEdge == PolyEdgeSharp)
-+	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
-+	else
-+	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
-+	
-+	for (; ntri; ntri--, tris++)
-+	    miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
-+    }
-+}
-+
--- 
-2.3.2 (Apple Git-55)
-
diff --git a/pkgs/servers/x11/xorg/darwin/0005-fb-Revert-fb-changes-that-broke-XQuartz.patch b/pkgs/servers/x11/xorg/darwin/0005-fb-Revert-fb-changes-that-broke-XQuartz.patch
deleted file mode 100644
index b9d4b18cf82a..000000000000
--- a/pkgs/servers/x11/xorg/darwin/0005-fb-Revert-fb-changes-that-broke-XQuartz.patch
+++ /dev/null
@@ -1,316 +0,0 @@
-From a635e397d5830f7f60e3690a1bb36f7a725b915a Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston <jeremyhu@apple.com>
-Date: Fri, 12 Feb 2010 19:48:52 -0800
-Subject: [PATCH 5/6] fb: Revert fb changes that broke XQuartz
-
-http://bugs.freedesktop.org/show_bug.cgi?id=26124
-
-Revert "Fix source pictures getting random transforms after 2d6a8f668342a5190cdf43b5."
-Revert "fb: Adjust transform or composite coordinates for pixman operations"
-
-http://bugs.freedesktop.org/26124
-
-This reverts commit a72c65e9176c51de95db2fdbf4c5d946a4911695.
-This reverts commit a6bd5d2e482a5aa84acb3d4932e2a166d8670ef1.
-
-Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
----
- fb/fb.h     |  3 +--
- fb/fbpict.c | 82 ++++++++++++++++++-------------------------------------------
- fb/fbtrap.c | 43 ++++++++++++++------------------
- 3 files changed, 43 insertions(+), 85 deletions(-)
-
-diff --git a/fb/fb.h b/fb/fb.h
-index ab110f3..59eaac3 100644
---- a/fb/fb.h
-+++ b/fb/fb.h
-@@ -1326,8 +1326,7 @@ fbFillRegionSolid(DrawablePtr pDrawable,
-                   RegionPtr pRegion, FbBits and, FbBits xor);
- 
- extern _X_EXPORT pixman_image_t *image_from_pict(PicturePtr pict,
--                                                 Bool has_clip,
--                                                 int *xoff, int *yoff);
-+                                                 Bool has_clip);
- 
- extern _X_EXPORT void free_pixman_pict(PicturePtr, pixman_image_t *);
- 
-diff --git a/fb/fbpict.c b/fb/fbpict.c
-index cafb027..6ee63e9 100644
---- a/fb/fbpict.c
-+++ b/fb/fbpict.c
-@@ -46,23 +46,18 @@ fbComposite(CARD8 op,
-             INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
-     pixman_image_t *src, *mask, *dest;
--    int src_xoff, src_yoff;
--    int msk_xoff, msk_yoff;
--    int dst_xoff, dst_yoff;
--
-     miCompositeSourceValidate(pSrc);
-     if (pMask)
-         miCompositeSourceValidate(pMask);
- 
--    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
--    mask = image_from_pict(pMask, FALSE, &msk_xoff, &msk_yoff);
--    dest = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
-+    src = image_from_pict(pSrc, TRUE);
-+    mask = image_from_pict(pMask, TRUE);
-+    dest = image_from_pict(pDst, TRUE);
- 
-     if (src && dest && !(pMask && !mask)) {
-         pixman_image_composite(op, src, mask, dest,
--                               xSrc + src_xoff, ySrc + src_yoff,
--                               xMask + msk_xoff, yMask + msk_yoff,
--                               xDst + dst_xoff, yDst + dst_yoff, width, height);
-+                               xSrc, ySrc, xMask, yMask, xDst, yDst,
-+                               width, height);
-     }
- 
-     free_pixman_pict(pSrc, src);
-@@ -289,20 +284,22 @@ create_conical_gradient_image(PictGradient * gradient)
- }
- 
- static pixman_image_t *
--create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
-+create_bits_picture(PicturePtr pict, Bool has_clip)
- {
--    PixmapPtr pixmap;
-     FbBits *bits;
-     FbStride stride;
--    int bpp;
-+    int bpp, xoff, yoff;
-     pixman_image_t *image;
- 
--    fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
--    fbGetPixmapBitsData(pixmap, bits, stride, bpp);
-+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-+
-+    bits = (FbBits*)((CARD8*)bits +
-+                     (pict->pDrawable->y + yoff) * stride * sizeof(FbBits) +
-+                     (pict->pDrawable->x + xoff) * (bpp / 8));
- 
-     image = pixman_image_create_bits((pixman_format_code_t) pict->format,
--                                     pixmap->drawable.width,
--                                     pixmap->drawable.height, (uint32_t *) bits,
-+                                     pict->pDrawable->width,
-+                                     pict->pDrawable->height, (uint32_t *) bits,
-                                      stride * sizeof(FbStride));
- 
-     if (!image)
-@@ -321,57 +318,31 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
-         if (pict->clientClip)
-             pixman_image_set_has_client_clip(image, TRUE);
- 
--        if (*xoff || *yoff)
--            pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
-+        pixman_region_translate (pict->pCompositeClip, - pict->pDrawable->x, - pict->pDrawable->y);
- 
-         pixman_image_set_clip_region(image, pict->pCompositeClip);
- 
--        if (*xoff || *yoff)
--            pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
-+        pixman_region_translate (pict->pCompositeClip, pict->pDrawable->x, pict->pDrawable->y);
-     }
- 
-     /* Indexed table */
-     if (pict->pFormat->index.devPrivate)
-         pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
- 
--    /* Add in drawable origin to position within the image */
--    *xoff += pict->pDrawable->x;
--    *yoff += pict->pDrawable->y;
--
-     return image;
- }
- 
- static pixman_image_t *image_from_pict_internal(PicturePtr pict, Bool has_clip,
--                                                int *xoff, int *yoff,
-                                                 Bool is_alpha_map);
- 
- static void
--set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
--                     int *xoff, int *yoff, Bool is_alpha_map)
-+set_image_properties(pixman_image_t * image, PicturePtr pict, Bool is_alpha_map)
- {
-     pixman_repeat_t repeat;
-     pixman_filter_t filter;
- 
-     if (pict->transform) {
--        /* For source images, adjust the transform to account
--         * for the drawable offset within the pixman image,
--         * then set the offset to 0 as it will be used
--         * to compute positions within the transformed image.
--         */
--        if (!has_clip) {
--            struct pixman_transform adjusted;
--
--            adjusted = *pict->transform;
--            pixman_transform_translate(&adjusted,
--                                       NULL,
--                                       pixman_int_to_fixed(*xoff),
--                                       pixman_int_to_fixed(*yoff));
--            pixman_image_set_transform(image, &adjusted);
--            *xoff = 0;
--            *yoff = 0;
--        }
--        else
--            pixman_image_set_transform(image, pict->transform);
-+        pixman_image_set_transform(image, pict->transform);
-     }
- 
-     switch (pict->repeatType) {
-@@ -399,10 +370,8 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
-      * as the alpha map for this operation
-      */
-     if (pict->alphaMap && !is_alpha_map) {
--        int alpha_xoff, alpha_yoff;
-         pixman_image_t *alpha_map =
--            image_from_pict_internal(pict->alphaMap, FALSE, &alpha_xoff,
--                                     &alpha_yoff, TRUE);
-+            image_from_pict_internal(pict->alphaMap, TRUE, TRUE);
- 
-         pixman_image_set_alpha_map(image, alpha_map, pict->alphaOrigin.x,
-                                    pict->alphaOrigin.y);
-@@ -436,8 +405,7 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
- }
- 
- static pixman_image_t *
--image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
--                         Bool is_alpha_map)
-+image_from_pict_internal(PicturePtr pict, Bool has_clip, Bool is_alpha_map)
- {
-     pixman_image_t *image = NULL;
- 
-@@ -445,7 +413,7 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
-         return NULL;
- 
-     if (pict->pDrawable) {
--        image = create_bits_picture(pict, has_clip, xoff, yoff);
-+        image = create_bits_picture(pict, has_clip);
-     }
-     else if (pict->pSourcePict) {
-         SourcePict *sp = pict->pSourcePict;
-@@ -463,19 +431,17 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
-             else if (sp->type == SourcePictTypeConical)
-                 image = create_conical_gradient_image(gradient);
-         }
--        *xoff = *yoff = 0;
-     }
- 
-     if (image)
--        set_image_properties(image, pict, has_clip, xoff, yoff, is_alpha_map);
--
-+        set_image_properties (image, pict, is_alpha_map);
-     return image;
- }
- 
- pixman_image_t *
--image_from_pict(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
-+image_from_pict (PicturePtr pict, Bool has_clip)
- {
--    return image_from_pict_internal(pict, has_clip, xoff, yoff, FALSE);
-+    return image_from_pict_internal (pict, has_clip, FALSE);
- }
- 
- void
-diff --git a/fb/fbtrap.c b/fb/fbtrap.c
-index bf82f8f..0145ce9 100644
---- a/fb/fbtrap.c
-+++ b/fb/fbtrap.c
-@@ -36,13 +36,12 @@ fbAddTraps(PicturePtr pPicture,
-            INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
- {
-     pixman_image_t *image;
--    int dst_xoff, dst_yoff;
- 
--    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
--        return;
--
--    pixman_add_traps(image, x_off + dst_xoff, y_off + dst_yoff,
--                     ntrap, (pixman_trap_t *) traps);
-+    if (!(image = image_from_pict (pPicture, FALSE)))
-+	return;
-+    
-+    pixman_add_traps(image, x_off, y_off,
-+                     ntrap, (pixman_trap_t *)traps);
- 
-     free_pixman_pict(pPicture, image);
- }
-@@ -52,13 +51,12 @@ fbRasterizeTrapezoid(PicturePtr pPicture,
-                      xTrapezoid * trap, int x_off, int y_off)
- {
-     pixman_image_t *image;
--    int dst_xoff, dst_yoff;
- 
--    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
-+    if (!(image = image_from_pict (pPicture, FALSE)))
-         return;
- 
--    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *) trap,
--                               x_off + dst_xoff, y_off + dst_yoff);
-+    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *)trap,
-+                               x_off, y_off);
- 
-     free_pixman_pict(pPicture, image);
- }
-@@ -68,14 +66,12 @@ fbAddTriangles(PicturePtr pPicture,
-                INT16 x_off, INT16 y_off, int ntri, xTriangle * tris)
- {
-     pixman_image_t *image;
--    int dst_xoff, dst_yoff;
- 
--    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
-+    if (!(image = image_from_pict (pPicture, FALSE)))
-         return;
--
--    pixman_add_triangles(image,
--                         dst_xoff + x_off, dst_yoff + y_off,
--                         ntri, (pixman_triangle_t *) tris);
-+    
-+    pixman_add_triangles(image, x_off, y_off, ntri,
-+                         (pixman_triangle_t *)tris);
- 
-     free_pixman_pict(pPicture, image);
- }
-@@ -98,13 +94,11 @@ fbShapes(CompositeShapesFunc composite,
-          int16_t ySrc, int nshapes, int shape_size, const uint8_t * shapes)
- {
-     pixman_image_t *src, *dst;
--    int src_xoff, src_yoff;
--    int dst_xoff, dst_yoff;
- 
-     miCompositeSourceValidate(pSrc);
- 
--    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
--    dst = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
-+    src = image_from_pict(pSrc, FALSE);
-+    dst = image_from_pict(pDst, TRUE);
- 
-     if (src && dst) {
-         pixman_format_code_t format;
-@@ -121,9 +115,8 @@ fbShapes(CompositeShapesFunc composite,
- 
-             for (i = 0; i < nshapes; ++i) {
-                 composite(op, src, dst, format,
--                          xSrc + src_xoff,
--                          ySrc + src_yoff,
--                          dst_xoff, dst_yoff, 1, shapes + i * shape_size);
-+                          xSrc, ySrc, 0, 0, 
-+                          1, shapes + i * shape_size);
-             }
-         }
-         else {
-@@ -143,8 +136,8 @@ fbShapes(CompositeShapesFunc composite,
-             }
- 
-             composite(op, src, dst, format,
--                      xSrc + src_xoff,
--                      ySrc + src_yoff, dst_xoff, dst_yoff, nshapes, shapes);
-+                      xSrc, ySrc, 0, 0,
-+                      nshapes, shapes);
-         }
- 
-         DamageRegionProcessPending(pDst->pDrawable);
--- 
-2.3.2 (Apple Git-55)
-
diff --git a/pkgs/servers/x11/xorg/darwin/0006-fb-Revert-fb-changes-that-broke-XQuartz.patch b/pkgs/servers/x11/xorg/darwin/0006-fb-Revert-fb-changes-that-broke-XQuartz.patch
deleted file mode 100644
index 03d4decdb1c9..000000000000
--- a/pkgs/servers/x11/xorg/darwin/0006-fb-Revert-fb-changes-that-broke-XQuartz.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-From 4c7572abafeac9b2dcd884c444c5a5bae5b302c3 Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Date: Sat, 31 May 2014 13:14:20 -0700
-Subject: [PATCH 6/6] fb: Revert fb changes that broke XQuartz
-
-    http://bugs.freedesktop.org/show_bug.cgi?id=26124
-
-Revert "Use new pixman_glyph_cache_t API that will be in pixman 0.28.0"
-Revert "fb: Fix origin of source picture in fbGlyphs"
-Revert "fb: Publish fbGlyphs and fbUnrealizeGlyph"
-
-This reverts commit 9cbcb5bd6a5360a128d15b77a02d8d3351f74366.
-This reverts commit 983e30361f49a67252d0b5d82630e70724d69dbf.
-This reverts commit 3c2c59eed3c68c0e5a93c38cf01eedad015e3157.
----
- fb/fb.h       |   3 --
- fb/fbpict.c   | 149 +---------------------------------------------------------
- fb/fbpict.h   |  11 +----
- fb/fbscreen.c |   1 -
- 4 files changed, 2 insertions(+), 162 deletions(-)
-
-diff --git a/fb/fb.h b/fb/fb.h
-index 59eaac3..046b948 100644
---- a/fb/fb.h
-+++ b/fb/fb.h
-@@ -1116,9 +1116,6 @@ extern _X_EXPORT void
- extern _X_EXPORT Bool
-  fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
- 
--extern _X_EXPORT void
--fbDestroyGlyphCache(void);
--
- /*
-  * fbpixmap.c
-  */
-diff --git a/fb/fbpict.c b/fb/fbpict.c
-index 6ee63e9..9c4cc42 100644
---- a/fb/fbpict.c
-+++ b/fb/fbpict.c
-@@ -65,152 +65,6 @@ fbComposite(CARD8 op,
-     free_pixman_pict(pDst, dest);
- }
- 
--static pixman_glyph_cache_t *glyphCache;
--
--void
--fbDestroyGlyphCache(void)
--{
--    if (glyphCache)
--    {
--	pixman_glyph_cache_destroy (glyphCache);
--	glyphCache = NULL;
--    }
--}
--
--static void
--fbUnrealizeGlyph(ScreenPtr pScreen,
--		 GlyphPtr pGlyph)
--{
--    if (glyphCache)
--	pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
--}
--
--void
--fbGlyphs(CARD8 op,
--	 PicturePtr pSrc,
--	 PicturePtr pDst,
--	 PictFormatPtr maskFormat,
--	 INT16 xSrc,
--	 INT16 ySrc, int nlist,
--	 GlyphListPtr list,
--	 GlyphPtr *glyphs)
--{
--#define N_STACK_GLYPHS 512
--    ScreenPtr pScreen = pDst->pDrawable->pScreen;
--    pixman_glyph_t stack_glyphs[N_STACK_GLYPHS];
--    pixman_glyph_t *pglyphs = stack_glyphs;
--    pixman_image_t *srcImage, *dstImage;
--    int srcXoff, srcYoff, dstXoff, dstYoff;
--    GlyphPtr glyph;
--    int n_glyphs;
--    int x, y;
--    int i, n;
--    int xDst = list->xOff, yDst = list->yOff;
--
--    miCompositeSourceValidate(pSrc);
--
--    n_glyphs = 0;
--    for (i = 0; i < nlist; ++i)
--	n_glyphs += list[i].len;
--
--    if (!glyphCache)
--	glyphCache = pixman_glyph_cache_create();
--
--    pixman_glyph_cache_freeze (glyphCache);
--
--    if (n_glyphs > N_STACK_GLYPHS) {
--	if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
--	    goto out;
--    }
--
--    i = 0;
--    x = y = 0;
--    while (nlist--) {
--        x += list->xOff;
--        y += list->yOff;
--        n = list->len;
--        while (n--) {
--	    const void *g;
--
--            glyph = *glyphs++;
--
--	    if (!(g = pixman_glyph_cache_lookup (glyphCache, glyph, NULL))) {
--		pixman_image_t *glyphImage;
--		PicturePtr pPicture;
--		int xoff, yoff;
--
--		pPicture = GetGlyphPicture(glyph, pScreen);
--		if (!pPicture) {
--		    n_glyphs--;
--		    goto next;
--		}
--
--		if (!(glyphImage = image_from_pict(pPicture, FALSE, &xoff, &yoff)))
--		    goto out;
--
--		g = pixman_glyph_cache_insert(glyphCache, glyph, NULL,
--					      glyph->info.x,
--					      glyph->info.y,
--					      glyphImage);
--
--		free_pixman_pict(pPicture, glyphImage);
--
--		if (!g)
--		    goto out;
--	    }
--
--	    pglyphs[i].x = x;
--	    pglyphs[i].y = y;
--	    pglyphs[i].glyph = g;
--	    i++;
--
--	next:
--            x += glyph->info.xOff;
--            y += glyph->info.yOff;
--	}
--	list++;
--    }
--
--    if (!(srcImage = image_from_pict(pSrc, FALSE, &srcXoff, &srcYoff)))
--	goto out;
--
--    if (!(dstImage = image_from_pict(pDst, TRUE, &dstXoff, &dstYoff)))
--	goto out_free_src;
--
--    if (maskFormat) {
--	pixman_format_code_t format;
--	pixman_box32_t extents;
--
--	format = maskFormat->format | (maskFormat->depth << 24);
--
--	pixman_glyph_get_extents(glyphCache, n_glyphs, pglyphs, &extents);
--
--	pixman_composite_glyphs(op, srcImage, dstImage, format,
--				xSrc + srcXoff + extents.x1 - xDst, ySrc + srcYoff + extents.y1 - yDst,
--				extents.x1, extents.y1,
--				extents.x1 + dstXoff, extents.y1 + dstYoff,
--				extents.x2 - extents.x1,
--				extents.y2 - extents.y1,
--				glyphCache, n_glyphs, pglyphs);
--    }
--    else {
--	pixman_composite_glyphs_no_mask(op, srcImage, dstImage,
--					xSrc + srcXoff - xDst, ySrc + srcYoff - yDst,
--					dstXoff, dstYoff,
--					glyphCache, n_glyphs, pglyphs);
--    }
--
--    free_pixman_pict(pDst, dstImage);
--
--out_free_src:
--    free_pixman_pict(pSrc, srcImage);
--
--out:
--    pixman_glyph_cache_thaw(glyphCache);
--    if (pglyphs != stack_glyphs)
--	free(pglyphs);
--}
--
- static pixman_image_t *
- create_solid_fill_image(PicturePtr pict)
- {
-@@ -461,8 +315,7 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
-         return FALSE;
-     ps = GetPictureScreen(pScreen);
-     ps->Composite = fbComposite;
--    ps->Glyphs = fbGlyphs;
--    ps->UnrealizeGlyph = fbUnrealizeGlyph;
-+    ps->Glyphs = miGlyphs;
-     ps->CompositeRects = miCompositeRects;
-     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
-     ps->AddTraps = fbAddTraps;
-diff --git a/fb/fbpict.h b/fb/fbpict.h
-index 5cb8663..110f32d 100644
---- a/fb/fbpict.h
-+++ b/fb/fbpict.h
-@@ -65,20 +65,11 @@ fbTrapezoids(CARD8 op,
-              INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
- 
- extern _X_EXPORT void
-+
- fbTriangles(CARD8 op,
-             PicturePtr pSrc,
-             PicturePtr pDst,
-             PictFormatPtr maskFormat,
-             INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
- 
--extern _X_EXPORT void
--fbGlyphs(CARD8 op,
--	 PicturePtr pSrc,
--	 PicturePtr pDst,
--	 PictFormatPtr maskFormat,
--	 INT16 xSrc,
--	 INT16 ySrc, int nlist,
--	 GlyphListPtr list,
--	 GlyphPtr *glyphs);
--
- #endif                          /* _FBPICT_H_ */
-diff --git a/fb/fbscreen.c b/fb/fbscreen.c
-index 71bcc5d..55330fc 100644
---- a/fb/fbscreen.c
-+++ b/fb/fbscreen.c
-@@ -32,7 +32,6 @@ fbCloseScreen(ScreenPtr pScreen)
-     int d;
-     DepthPtr depths = pScreen->allowedDepths;
- 
--    fbDestroyGlyphCache();
-     for (d = 0; d < pScreen->numDepths; d++)
-         free(depths[d].vids);
-     free(depths);
--- 
-2.3.2 (Apple Git-55)
-
diff --git a/pkgs/servers/x11/xorg/darwin/bundle_main.patch b/pkgs/servers/x11/xorg/darwin/bundle_main.patch
deleted file mode 100644
index e60ca5738d14..000000000000
--- a/pkgs/servers/x11/xorg/darwin/bundle_main.patch
+++ /dev/null
@@ -1,118 +0,0 @@
-cstrahan:
-
-This patch makes it possible (and necessary) to specify the default
-shell, xterm client, and startx script from environment variables. These
-defaults are used when launching the XQuartz.app, which in turn needs to know
-how to start the X server. I've patched `command_from_prefs' so that it ignores
-the preferences settings and immediately sets them to whatever the environment
-variables are.
-
-When developing an installable package for XQuartz/XQuartz.app, we'll need to
-set an `LSEnvironment' entry in the plist for the XQuartz.app, we'll also need
-to wrap the XQuartz.app/Contents/MacOS/X11 script (the Xquartz server will
-invoke this script during initialization. See stub.patch for more details.).
-
-diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
-index b403662..b1e2070 100644
---- a/hw/xquartz/mach-startup/bundle-main.c
-+++ b/hw/xquartz/mach-startup/bundle-main.c
-@@ -77,13 +77,7 @@ FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN;
- 
- extern int noPanoramiXExtension;
- 
--#define DEFAULT_CLIENT X11BINDIR "/xterm"
--#define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz"
--#define DEFAULT_SHELL  "/bin/sh"
--
--#ifndef BUILD_DATE
- #define BUILD_DATE ""
--#endif
- #ifndef XSERVER_VERSION
- #define XSERVER_VERSION "?"
- #endif
-@@ -718,14 +712,14 @@ main(int argc, char **argv, char **envp)
-         pid_t child1, child2;
-         int status;
- 
--        pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT);
-+        pref_app_to_run = command_from_prefs("app_to_run", getenv("XQUARTZ_DEFAULT_CLIENT"));
-         assert(pref_app_to_run);
- 
--        pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
-+        pref_login_shell = command_from_prefs("login_shell", getenv("XQUARTZ_DEFAULT_SHELL"));
-         assert(pref_login_shell);
- 
-         pref_startx_script = command_from_prefs("startx_script",
--                                                DEFAULT_STARTX);
-+                                                getenv("XQUARTZ_DEFAULT_STARTX"));
-         assert(pref_startx_script);
- 
-         /* Do the fork-twice trick to avoid having to reap zombies */
-@@ -804,10 +798,12 @@ execute(const char *command)
- static char *
- command_from_prefs(const char *key, const char *default_value)
- {
-+    if (default_value == NULL)
-+        return NULL;
-+
-     char *command = NULL;
- 
-     CFStringRef cfKey;
--    CFPropertyListRef PlistRef;
- 
-     if (!key)
-         return NULL;
-@@ -817,40 +813,24 @@ command_from_prefs(const char *key, const char *default_value)
-     if (!cfKey)
-         return NULL;
- 
--    PlistRef = CFPreferencesCopyAppValue(cfKey,
--                                         kCFPreferencesCurrentApplication);
-+    CFStringRef cfDefaultValue = CFStringCreateWithCString(
-+        NULL, default_value, kCFStringEncodingASCII);
-+    int len = strlen(default_value) + 1;
- 
--    if ((PlistRef == NULL) ||
--        (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
--        CFStringRef cfDefaultValue = CFStringCreateWithCString(
--            NULL, default_value, kCFStringEncodingASCII);
--        int len = strlen(default_value) + 1;
-+    if (!cfDefaultValue)
-+        goto command_from_prefs_out;
- 
--        if (!cfDefaultValue)
--            goto command_from_prefs_out;
-+    CFPreferencesSetAppValue(cfKey, cfDefaultValue,
-+                             kCFPreferencesCurrentApplication);
-+    CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-+    CFRelease(cfDefaultValue);
- 
--        CFPreferencesSetAppValue(cfKey, cfDefaultValue,
--                                 kCFPreferencesCurrentApplication);
--        CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
--        CFRelease(cfDefaultValue);
--
--        command = (char *)malloc(len * sizeof(char));
--        if (!command)
--            goto command_from_prefs_out;
--        strcpy(command, default_value);
--    }
--    else {
--        int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
--        command = (char *)malloc(len * sizeof(char));
--        if (!command)
--            goto command_from_prefs_out;
--        CFStringGetCString((CFStringRef)PlistRef, command, len,
--                           kCFStringEncodingASCII);
--    }
-+    command = (char *)malloc(len * sizeof(char));
-+    if (!command)
-+        goto command_from_prefs_out;
-+    strcpy(command, default_value);
- 
- command_from_prefs_out:
--    if (PlistRef)
--        CFRelease(PlistRef);
-     if (cfKey)
-         CFRelease(cfKey);
-     return command;
diff --git a/pkgs/servers/x11/xorg/darwin/function-pointer-test.patch b/pkgs/servers/x11/xorg/darwin/function-pointer-test.patch
deleted file mode 100644
index e521a12ba800..000000000000
--- a/pkgs/servers/x11/xorg/darwin/function-pointer-test.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-These are functions, not function pointers, so they always evaluate to true.
-
-diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
-index 5445c6f..8574bf1 100644
---- a/hw/xquartz/X11Controller.m
-+++ b/hw/xquartz/X11Controller.m
-@@ -364,7 +364,6 @@ extern char *bundle_id_prefix;
-     }
- 
- #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
--    if (asl_log_descriptor) {
-         char *asl_sender;
-         aslmsg amsg = asl_new(ASL_TYPE_MSG);
-         assert(amsg);
-@@ -394,7 +393,6 @@ extern char *bundle_id_prefix;
-         asl_log_descriptor(aslc, amsg, ASL_LEVEL_NOTICE, stderr_pipe[0], ASL_LOG_DESCRIPTOR_READ);
- 
-         asl_free(amsg);
--    }
- #endif
- 
-     /* Do the fork-twice trick to avoid having to reap zombies */
-@@ -414,11 +412,9 @@ extern char *bundle_id_prefix;
- 
-         case 0:                                     /* child2 */
- #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
--            if (asl_log_descriptor) {
-                 /* Replace our stdout/stderr */
-                 dup2(stdout_pipe[1], STDOUT_FILENO);
-                 dup2(stderr_pipe[1], STDERR_FILENO);
--            }
- #endif
- 
-             /* close all open files except for standard streams */
-@@ -443,11 +439,9 @@ extern char *bundle_id_prefix;
-     }
- 
- #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
--    if (asl_log_descriptor) {
-         /* Close the write ends of the pipe */
-         close(stdout_pipe[1]);
-         close(stderr_pipe[1]);
--    }
- #endif
- }
- 
diff --git a/pkgs/servers/x11/xorg/darwin/private-extern.patch b/pkgs/servers/x11/xorg/darwin/private-extern.patch
deleted file mode 100644
index 87af7865c376..000000000000
--- a/pkgs/servers/x11/xorg/darwin/private-extern.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/hw/xquartz/xpr/x-list.new.h b/hw/xquartz/xpr/x-list.h
-index 28385fd..71f9d26 100644
---- a/hw/xquartz/xpr/x-list.new.h
-+++ b/hw/xquartz/xpr/x-list.h
-@@ -45,6 +45,7 @@ struct x_list_struct {
- #endif
- 
- #ifndef X_EXTERN
-+#define __private_extern__ extern
- #define X_EXTERN __private_extern__
- #endif
- 
diff --git a/pkgs/servers/x11/xorg/darwin/stub.patch b/pkgs/servers/x11/xorg/darwin/stub.patch
deleted file mode 100644
index db3215b498aa..000000000000
--- a/pkgs/servers/x11/xorg/darwin/stub.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-cstrahan:
-
-When the X / Xquartz server initiallizes, it starts the XQuartz.app and
-hands-off the display FD. To start the XQuartz.app, Xquartz normally uses some
-system calls to get the path of the application by app bundle id, and then
-executes the Contents/MacOS/X11 script contained inside, which in turn executes
-Contents/MacOS/X11.bin (the actual app).
-
-This patch replaces that discovery technique with a simple call to
-`getenv'. In order to make Xquartz actually work, we'll need another wrapper
-that sets the `XQUARTZ_X11' environment variable to point to the `X11' script.
-
-diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
-index 756e4ef..3313a55 100644
---- a/hw/xquartz/mach-startup/stub.c
-+++ b/hw/xquartz/mach-startup/stub.c
-@@ -61,54 +61,16 @@ aslclient aslc;
- static void
- set_x11_path(void)
- {
--#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
--
--    CFURLRef appURL = NULL;
--    OSStatus osstatus =
--        LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(
--                                     kX11AppBundleId), nil, nil, &appURL);
--
--    switch (osstatus) {
--    case noErr:
--        if (appURL == NULL) {
--            asl_log(
--                aslc, NULL, ASL_LEVEL_ERR,
--                "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
--                kX11AppBundleId);
--            exit(1);
--        }
--
--        if (!CFURLGetFileSystemRepresentation(appURL, true,
--                                              (unsigned char *)x11_path,
--                                              sizeof(x11_path))) {
--            asl_log(aslc, NULL, ASL_LEVEL_ERR,
--                    "Xquartz: Error resolving URL for %s",
--                    kX11AppBundleId);
--            exit(3);
--        }
--
--        strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
--        asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
--        break;
--
--    case kLSApplicationNotFoundErr:
--        asl_log(aslc, NULL, ASL_LEVEL_ERR,
--                "Xquartz: Unable to find application for %s",
--                kX11AppBundleId);
--        exit(10);
--
--    default:
--        asl_log(aslc, NULL, ASL_LEVEL_ERR,
--                "Xquartz: Unable to find application for %s, error code = %d",
--                kX11AppBundleId,
--                (int)osstatus);
--        exit(11);
-+    char *xquartzX11 = getenv("XQUARTZ_X11");
-+    if (xquartzX11) {
-+        strlcpy(x11_path, xquartzX11,
-+                sizeof(x11_path));
-+    } else {
-+        asl_log(
-+            aslc, NULL, ASL_LEVEL_ERR,
-+            "Xquartz: XQUARTZ_X11 environment variable not set");
-+        exit(1);
-     }
--#else
--    /* TODO: Make Tiger smarter... but TBH, this should never get called on Tiger... */
--    strlcpy(x11_path, "/Applications/Utilities/X11.app/Contents/MacOS/X11",
--            sizeof(x11_path));
--#endif
- }
- 
- static int
diff --git a/pkgs/servers/x11/xorg/default.nix b/pkgs/servers/x11/xorg/default.nix
index 778fe03a0c28..e6f5e7ff5887 100644
--- a/pkgs/servers/x11/xorg/default.nix
+++ b/pkgs/servers/x11/xorg/default.nix
@@ -1,6 +1,6 @@
 # THIS IS A GENERATED FILE.  DO NOT EDIT!
 args @ { clangStdenv, fetchurl, fetchgit, fetchpatch, stdenv, pkgconfig, intltool, freetype, fontconfig
-, libxslt, expat, libpng, zlib, perl, mesa_drivers, spice_protocol
+, libxslt, expat, libpng, zlib, perl, mesa_noglu, mesa_drivers, spice-protocol
 , dbus, libuuid, openssl, gperf, m4, libevdev, tradcpp, libinput, mcpp, makeWrapper, autoreconfHook
 , autoconf, automake, libtool, xmlto, asciidoc, flex, bison, python, mtdev, pixman, ... }: with args;
 
@@ -9,7 +9,9 @@ let
   mkDerivation = name: attrs:
     let newAttrs = (overrides."${name}" or (x: x)) attrs;
         stdenv = newAttrs.stdenv or args.stdenv;
-    in stdenv.mkDerivation (removeAttrs newAttrs [ "stdenv" ]);
+      in stdenv.mkDerivation ((removeAttrs newAttrs [ "stdenv" ]) // {
+        hardeningDisable = [ "bindnow" "relro" ];
+      });
 
   overrides = import ./overrides.nix {inherit args xorg;};
 
@@ -24,18 +26,34 @@ let
       url = mirror://xorg/X11R7.7/src/everything/applewmproto-1.4.2.tar.bz2;
       sha256 = "1zi4p07mp6jmk030p4gmglwxcwp0lzs5mi31y1b4rp8lsqxdxizw";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
+  appres = (mkDerivation "appres" {
+    name = "appres-1.0.4";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/app/appres-1.0.4.tar.bz2;
+      sha256 = "139yp08qy1w6dccamdy0fh343yhaf1am1v81m2j435nd4ya4wqcz";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit libX11 xproto libXt ;};
+
   bdftopcf = (mkDerivation "bdftopcf" {
-    name = "bdftopcf-1.0.5";
+    name = "bdftopcf-1.1";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/bdftopcf-1.0.5.tar.bz2;
-      sha256 = "09i03sk878cmx2i40lkpsysn7zqcvlczb30j7x3lryb11jz4gx1q";
+      url = mirror://xorg/individual/app/bdftopcf-1.1.tar.bz2;
+      sha256 = "18hiscgljrz10zjcws25bis32nyrg3hzgmiq6scrh7izqmgz0kab";
     };
-    buildInputs = [pkgconfig libXfont ];
-  }) // {inherit libXfont ;};
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit ;};
 
   bigreqsproto = (mkDerivation "bigreqsproto" {
     name = "bigreqsproto-1.1.2";
@@ -44,9 +62,23 @@ let
       url = mirror://xorg/X11R7.7/src/everything/bigreqsproto-1.1.2.tar.bz2;
       sha256 = "07hvfm84scz8zjw14riiln2v4w03jlhp756ypwhq27g48jmic8a6";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
+  bitmap = (mkDerivation "bitmap" {
+    name = "bitmap-1.0.8";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/app/bitmap-1.0.8.tar.gz;
+      sha256 = "1z06a1sn3iq72rmh73f11xgb7n46bdav1fvpgczxjp6al88bsbqs";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXaw xbitmaps libXmu xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit libX11 libXaw xbitmaps libXmu xproto libXt ;};
+
   compositeproto = (mkDerivation "compositeproto" {
     name = "compositeproto-0.4.2";
     builder = ./builder.sh;
@@ -54,7 +86,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/compositeproto-0.4.2.tar.bz2;
       sha256 = "1z0crmf669hirw4s7972mmp8xig80kfndja9h559haqbpvq5k4q4";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   damageproto = (mkDerivation "damageproto" {
@@ -64,7 +98,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/damageproto-1.2.1.tar.bz2;
       sha256 = "0nzwr5pv9hg7c21n995pdiv0zqhs91yz3r8rn3aska4ykcp12z2w";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   dmxproto = (mkDerivation "dmxproto" {
@@ -74,7 +110,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/dmxproto-2.3.1.tar.bz2;
       sha256 = "02b5x9dkgajizm8dqyx2w6hmqx3v25l67mgf35nj6sz0lgk52877";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   dri2proto = (mkDerivation "dri2proto" {
@@ -84,7 +122,9 @@ let
       url = mirror://xorg/individual/proto/dri2proto-2.8.tar.bz2;
       sha256 = "015az1vfdqmil1yay5nlsmpf6cf7vcbpslxjb72cfkzlvrv59dgr";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   dri3proto = (mkDerivation "dri3proto" {
@@ -94,7 +134,9 @@ let
       url = mirror://xorg/individual/proto/dri3proto-1.0.tar.bz2;
       sha256 = "0x609xvnl8jky5m8jdklw4nymx3irkv32w99dfd8nl800bblkgh1";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   encodings = (mkDerivation "encodings" {
@@ -104,7 +146,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/encodings-1.0.4.tar.bz2;
       sha256 = "0ffmaw80vmfwdgvdkp6495xgsqszb6s0iira5j0j6pd4i0lk3mnf";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   fixesproto = (mkDerivation "fixesproto" {
@@ -114,7 +158,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/fixesproto-5.0.tar.bz2;
       sha256 = "1ki4wiq2iivx5g4w5ckzbjbap759kfqd72yg18m3zpbb4hqkybxs";
     };
-    buildInputs = [pkgconfig xextproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xextproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xextproto ;};
 
   fontadobe100dpi = (mkDerivation "fontadobe100dpi" {
@@ -124,7 +170,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-adobe-100dpi-1.0.3.tar.bz2;
       sha256 = "0m60f5bd0caambrk8ksknb5dks7wzsg7g7xaf0j21jxmx8rq9h5j";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontadobe75dpi = (mkDerivation "fontadobe75dpi" {
@@ -134,7 +182,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-adobe-75dpi-1.0.3.tar.bz2;
       sha256 = "02advcv9lyxpvrjv8bjh1b797lzg6jvhipclz49z8r8y98g4l0n6";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontadobeutopia100dpi = (mkDerivation "fontadobeutopia100dpi" {
@@ -144,7 +194,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-adobe-utopia-100dpi-1.0.4.tar.bz2;
       sha256 = "19dd9znam1ah72jmdh7i6ny2ss2r6m21z9v0l43xvikw48zmwvyi";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontadobeutopia75dpi = (mkDerivation "fontadobeutopia75dpi" {
@@ -154,7 +206,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-adobe-utopia-75dpi-1.0.4.tar.bz2;
       sha256 = "152wigpph5wvl4k9m3l4mchxxisgsnzlx033mn5iqrpkc6f72cl7";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontadobeutopiatype1 = (mkDerivation "fontadobeutopiatype1" {
@@ -164,7 +218,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-adobe-utopia-type1-1.0.4.tar.bz2;
       sha256 = "0xw0pdnzj5jljsbbhakc6q9ha2qnca1jr81zk7w70yl9bw83b54p";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontalias = (mkDerivation "fontalias" {
@@ -174,7 +230,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-alias-1.0.3.tar.bz2;
       sha256 = "16ic8wfwwr3jicaml7b5a0sk6plcgc1kg84w02881yhwmqm3nicb";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   fontarabicmisc = (mkDerivation "fontarabicmisc" {
@@ -184,7 +242,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-arabic-misc-1.0.3.tar.bz2;
       sha256 = "1x246dfnxnmflzf0qzy62k8jdpkb6jkgspcjgbk8jcq9lw99npah";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontbh100dpi = (mkDerivation "fontbh100dpi" {
@@ -194,7 +254,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bh-100dpi-1.0.3.tar.bz2;
       sha256 = "10cl4gm38dw68jzln99ijix730y7cbx8np096gmpjjwff1i73h13";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontbh75dpi = (mkDerivation "fontbh75dpi" {
@@ -204,7 +266,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bh-75dpi-1.0.3.tar.bz2;
       sha256 = "073jmhf0sr2j1l8da97pzsqj805f7mf9r2gy92j4diljmi8sm1il";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontbhlucidatypewriter100dpi = (mkDerivation "fontbhlucidatypewriter100dpi" {
@@ -214,7 +278,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bh-lucidatypewriter-100dpi-1.0.3.tar.bz2;
       sha256 = "1fqzckxdzjv4802iad2fdrkpaxl4w0hhs9lxlkyraq2kq9ik7a32";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontbhlucidatypewriter75dpi = (mkDerivation "fontbhlucidatypewriter75dpi" {
@@ -224,7 +290,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bh-lucidatypewriter-75dpi-1.0.3.tar.bz2;
       sha256 = "0cfbxdp5m12cm7jsh3my0lym9328cgm7fa9faz2hqj05wbxnmhaa";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontbhttf = (mkDerivation "fontbhttf" {
@@ -234,7 +302,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bh-ttf-1.0.3.tar.bz2;
       sha256 = "0pyjmc0ha288d4i4j0si4dh3ncf3jiwwjljvddrb0k8v4xiyljqv";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontbhtype1 = (mkDerivation "fontbhtype1" {
@@ -244,7 +314,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bh-type1-1.0.3.tar.bz2;
       sha256 = "1hb3iav089albp4sdgnlh50k47cdjif9p4axm0kkjvs8jyi5a53n";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontbitstream100dpi = (mkDerivation "fontbitstream100dpi" {
@@ -254,7 +326,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bitstream-100dpi-1.0.3.tar.bz2;
       sha256 = "1kmn9jbck3vghz6rj3bhc3h0w6gh0qiaqm90cjkqsz1x9r2dgq7b";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontbitstream75dpi = (mkDerivation "fontbitstream75dpi" {
@@ -264,7 +338,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bitstream-75dpi-1.0.3.tar.bz2;
       sha256 = "13plbifkvfvdfym6gjbgy9wx2xbdxi9hfrl1k22xayy02135wgxs";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontbitstreamtype1 = (mkDerivation "fontbitstreamtype1" {
@@ -274,7 +350,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-bitstream-type1-1.0.3.tar.bz2;
       sha256 = "1256z0jhcf5gbh1d03593qdwnag708rxqa032izmfb5dmmlhbsn6";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontcronyxcyrillic = (mkDerivation "fontcronyxcyrillic" {
@@ -284,7 +362,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-cronyx-cyrillic-1.0.3.tar.bz2;
       sha256 = "0ai1v4n61k8j9x2a1knvfbl2xjxk3xxmqaq3p9vpqrspc69k31kf";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontcursormisc = (mkDerivation "fontcursormisc" {
@@ -294,7 +374,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-cursor-misc-1.0.3.tar.bz2;
       sha256 = "0dd6vfiagjc4zmvlskrbjz85jfqhf060cpys8j0y1qpcbsrkwdhp";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontdaewoomisc = (mkDerivation "fontdaewoomisc" {
@@ -304,7 +386,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-daewoo-misc-1.0.3.tar.bz2;
       sha256 = "1s2bbhizzgbbbn5wqs3vw53n619cclxksljvm759h9p1prqdwrdw";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontdecmisc = (mkDerivation "fontdecmisc" {
@@ -314,7 +398,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-dec-misc-1.0.3.tar.bz2;
       sha256 = "0yzza0l4zwyy7accr1s8ab7fjqkpwggqydbm2vc19scdby5xz7g1";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontibmtype1 = (mkDerivation "fontibmtype1" {
@@ -324,7 +410,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-ibm-type1-1.0.3.tar.bz2;
       sha256 = "1pyjll4adch3z5cg663s6vhi02k8m6488f0mrasg81ssvg9jinzx";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontisasmisc = (mkDerivation "fontisasmisc" {
@@ -334,7 +422,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-isas-misc-1.0.3.tar.bz2;
       sha256 = "0rx8q02rkx673a7skkpnvfkg28i8gmqzgf25s9yi0lar915sn92q";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontjismisc = (mkDerivation "fontjismisc" {
@@ -344,7 +434,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-jis-misc-1.0.3.tar.bz2;
       sha256 = "0rdc3xdz12pnv951538q6wilx8mrdndpkphpbblszsv7nc8cw61b";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontmicromisc = (mkDerivation "fontmicromisc" {
@@ -354,7 +446,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-micro-misc-1.0.3.tar.bz2;
       sha256 = "1dldxlh54zq1yzfnrh83j5vm0k4ijprrs5yl18gm3n9j1z0q2cws";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontmisccyrillic = (mkDerivation "fontmisccyrillic" {
@@ -364,7 +458,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-misc-cyrillic-1.0.3.tar.bz2;
       sha256 = "0q2ybxs8wvylvw95j6x9i800rismsmx4b587alwbfqiw6biy63z4";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontmiscethiopic = (mkDerivation "fontmiscethiopic" {
@@ -374,7 +470,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-misc-ethiopic-1.0.3.tar.bz2;
       sha256 = "19cq7iq0pfad0nc2v28n681fdq3fcw1l1hzaq0wpkgpx7bc1zjsk";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontmiscmeltho = (mkDerivation "fontmiscmeltho" {
@@ -384,7 +482,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-misc-meltho-1.0.3.tar.bz2;
       sha256 = "148793fqwzrc3bmh2vlw5fdiwjc2n7vs25cic35gfp452czk489p";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   fontmiscmisc = (mkDerivation "fontmiscmisc" {
@@ -394,7 +494,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-misc-misc-1.1.2.tar.bz2;
       sha256 = "150pq6n8n984fah34n3k133kggn9v0c5k07igv29sxp1wi07krxq";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontmuttmisc = (mkDerivation "fontmuttmisc" {
@@ -404,7 +506,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-mutt-misc-1.0.3.tar.bz2;
       sha256 = "13qghgr1zzpv64m0p42195k1kc77pksiv059fdvijz1n6kdplpxx";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontschumachermisc = (mkDerivation "fontschumachermisc" {
@@ -414,7 +518,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-schumacher-misc-1.1.2.tar.bz2;
       sha256 = "0nkym3n48b4v36y4s927bbkjnsmicajarnf6vlp7wxp0as304i74";
     };
-    buildInputs = [pkgconfig bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf fontutil mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf fontutil mkfontdir mkfontscale ;};
 
   fontscreencyrillic = (mkDerivation "fontscreencyrillic" {
@@ -424,7 +530,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-screen-cyrillic-1.0.4.tar.bz2;
       sha256 = "0yayf1qlv7irf58nngddz2f1q04qkpr5jwp4aja2j5gyvzl32hl2";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontsonymisc = (mkDerivation "fontsonymisc" {
@@ -434,7 +542,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-sony-misc-1.0.3.tar.bz2;
       sha256 = "1xfgcx4gsgik5mkgkca31fj3w72jw9iw76qyrajrsz1lp8ka6hr0";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontsproto = (mkDerivation "fontsproto" {
@@ -444,7 +554,9 @@ let
       url = mirror://xorg/individual/proto/fontsproto-2.1.3.tar.bz2;
       sha256 = "1f2sdsd74y34nnaf4m1zlcbhyv8xb6irnisc99f84c4ivnq4d415";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   fontsunmisc = (mkDerivation "fontsunmisc" {
@@ -454,7 +566,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-sun-misc-1.0.3.tar.bz2;
       sha256 = "1q6jcqrffg9q5f5raivzwx9ffvf7r11g6g0b125na1bhpz5ly7s8";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontutil = (mkDerivation "fontutil" {
@@ -464,7 +578,9 @@ let
       url = mirror://xorg/individual/font/font-util-1.3.1.tar.bz2;
       sha256 = "08drjb6cf84pf5ysghjpb4i7xkd2p86k3wl2a0jxs1jif6qbszma";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   fontwinitzkicyrillic = (mkDerivation "fontwinitzkicyrillic" {
@@ -474,7 +590,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-winitzki-cyrillic-1.0.3.tar.bz2;
       sha256 = "181n1bgq8vxfxqicmy1jpm1hnr6gwn1kdhl6hr4frjigs1ikpldb";
     };
-    buildInputs = [pkgconfig bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ bdftopcf mkfontdir ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit bdftopcf mkfontdir ;};
 
   fontxfree86type1 = (mkDerivation "fontxfree86type1" {
@@ -484,7 +602,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/font-xfree86-type1-1.0.4.tar.bz2;
       sha256 = "0jp3zc0qfdaqfkgzrb44vi9vi0a8ygb35wp082yz7rvvxhmg9sya";
     };
-    buildInputs = [pkgconfig mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ mkfontdir mkfontscale ]; configureFlags = "--with-fontrootdir=$(out)/lib/X11/fonts"; 
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit mkfontdir mkfontscale ;};
 
   gccmakedep = (mkDerivation "gccmakedep" {
@@ -494,19 +614,11 @@ let
       url = mirror://xorg/individual/util/gccmakedep-1.0.3.tar.bz2;
       sha256 = "1r1fpy5ni8chbgx7j5sz0008fpb6vbazpy1nifgdhgijyzqxqxdj";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
-  glamoregl = (mkDerivation "glamoregl" {
-    name = "glamor-egl-0.6.0";
-    builder = ./builder.sh;
-    src = fetchurl {
-      url = mirror://xorg/individual/driver/glamor-egl-0.6.0.tar.bz2;
-      sha256 = "1jg5clihklb9drh1jd7nhhdsszla6nv7xmbvm8yvakh5wrb1nlv6";
-    };
-    buildInputs = [pkgconfig dri2proto xorgserver ];
-  }) // {inherit dri2proto xorgserver ;};
-
   glproto = (mkDerivation "glproto" {
     name = "glproto-1.4.17";
     builder = ./builder.sh;
@@ -514,7 +626,9 @@ let
       url = mirror://xorg/individual/proto/glproto-1.4.17.tar.bz2;
       sha256 = "0h5ykmcddwid5qj6sbrszgkcypwn3mslvswxpgy2n2iixnyr9amd";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   iceauth = (mkDerivation "iceauth" {
@@ -524,7 +638,9 @@ let
       url = mirror://xorg/individual/app/iceauth-1.0.7.tar.bz2;
       sha256 = "02izdyzhwpgiyjd8brzilwvwnfr72ncjb6mzz3y1icwrxqnsy5hj";
     };
-    buildInputs = [pkgconfig libICE xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libICE xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libICE xproto ;};
 
   imake = (mkDerivation "imake" {
@@ -534,17 +650,21 @@ let
       url = mirror://xorg/individual/util/imake-1.0.7.tar.bz2;
       sha256 = "0zpk8p044jh14bis838shbf4100bjg7mccd7bq54glpsq552q339";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   inputproto = (mkDerivation "inputproto" {
-    name = "inputproto-2.3.1";
+    name = "inputproto-2.3.2";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/proto/inputproto-2.3.1.tar.bz2;
-      sha256 = "1lf1jlxp0fc8h6fjdffhd084dqab94966l1zm3rwwsis0mifwiss";
+      url = mirror://xorg/individual/proto/inputproto-2.3.2.tar.bz2;
+      sha256 = "07gk7v006zqn3dcfh16l06gnccy7xnqywf3vl9c209ikazsnlfl9";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   kbproto = (mkDerivation "kbproto" {
@@ -554,7 +674,9 @@ let
       url = mirror://xorg/individual/proto/kbproto-1.0.7.tar.bz2;
       sha256 = "0mxqj1pzhjpz9495vrjnpi10kv2n1s4vs7di0sh3yvipfq5j30pq";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   libAppleWM = (mkDerivation "libAppleWM" {
@@ -564,7 +686,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/libAppleWM-1.4.1.tar.bz2;
       sha256 = "0r8x28n45q89x91mz8mv0zkkcxi8wazkac886fyvflhiv2y8ap2y";
     };
-    buildInputs = [pkgconfig applewmproto libX11 libXext xextproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ applewmproto libX11 libXext xextproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit applewmproto libX11 libXext xextproto ;};
 
   libFS = (mkDerivation "libFS" {
@@ -574,7 +698,9 @@ let
       url = mirror://xorg/individual/lib/libFS-1.0.7.tar.bz2;
       sha256 = "1wy4km3qwwajbyl8y9pka0zwizn7d9pfiyjgzba02x3a083lr79f";
     };
-    buildInputs = [pkgconfig fontsproto xproto xtrans ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto xproto xtrans ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto xproto xtrans ;};
 
   libICE = (mkDerivation "libICE" {
@@ -584,7 +710,9 @@ let
       url = mirror://xorg/individual/lib/libICE-1.0.9.tar.bz2;
       sha256 = "00p2b6bsg6kcdbb39bv46339qcywxfl4hsrz8asm4hy6q7r34w4g";
     };
-    buildInputs = [pkgconfig xproto xtrans ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto xtrans ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto xtrans ;};
 
   libSM = (mkDerivation "libSM" {
@@ -594,7 +722,9 @@ let
       url = mirror://xorg/individual/lib/libSM-1.2.2.tar.bz2;
       sha256 = "1gc7wavgs435g9qkp9jw4lhmaiq6ip9llv49f054ad6ryp4sib0b";
     };
-    buildInputs = [pkgconfig libICE libuuid xproto xtrans ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libICE libuuid xproto xtrans ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libICE libuuid xproto xtrans ;};
 
   libWindowsWM = (mkDerivation "libWindowsWM" {
@@ -604,17 +734,21 @@ let
       url = mirror://xorg/X11R7.7/src/everything/libWindowsWM-1.0.1.tar.bz2;
       sha256 = "1p0flwb67xawyv6yhri9w17m1i4lji5qnd0gq8v1vsfb8zw7rw15";
     };
-    buildInputs = [pkgconfig windowswmproto libX11 libXext xextproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ windowswmproto libX11 libXext xextproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit windowswmproto libX11 libXext xextproto ;};
 
   libX11 = (mkDerivation "libX11" {
-    name = "libX11-1.6.3";
+    name = "libX11-1.6.5";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libX11-1.6.3.tar.bz2;
-      sha256 = "04c1vj53xq2xgyxx5vhln3wm2d76hh1n95fvs3myhligkz1sfcfg";
+      url = mirror://xorg/individual/lib/libX11-1.6.5.tar.bz2;
+      sha256 = "0pa3cfp6h9rl2vxmkph65250gfqyki0ccqyaan6bl9d25gdr0f2d";
     };
-    buildInputs = [pkgconfig inputproto kbproto libxcb xextproto xf86bigfontproto xproto xtrans ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto kbproto libxcb xextproto xf86bigfontproto xproto xtrans ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto kbproto libxcb xextproto xf86bigfontproto xproto xtrans ;};
 
   libXScrnSaver = (mkDerivation "libXScrnSaver" {
@@ -624,7 +758,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/libXScrnSaver-1.2.2.tar.bz2;
       sha256 = "07ff4r20nkkrj7h08f9fwamds9b3imj8jz5iz6y38zqw6jkyzwcg";
     };
-    buildInputs = [pkgconfig scrnsaverproto libX11 libXext xextproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ scrnsaverproto libX11 libXext xextproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit scrnsaverproto libX11 libXext xextproto ;};
 
   libXau = (mkDerivation "libXau" {
@@ -634,7 +770,9 @@ let
       url = mirror://xorg/individual/lib/libXau-1.0.8.tar.bz2;
       sha256 = "1wm4pv12f36cwzhldpp7vy3lhm3xdcnp4f184xkxsp7b18r7gm7x";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   libXaw = (mkDerivation "libXaw" {
@@ -644,7 +782,9 @@ let
       url = mirror://xorg/individual/lib/libXaw-1.0.13.tar.bz2;
       sha256 = "1kdhxplwrn43d9jp3v54llp05kwx210lrsdvqb6944jp29rhdy4f";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto libXmu libXpm xproto libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto libXmu libXpm xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto libXmu libXpm xproto libXt ;};
 
   libXcomposite = (mkDerivation "libXcomposite" {
@@ -654,17 +794,21 @@ let
       url = mirror://xorg/individual/lib/libXcomposite-0.4.4.tar.bz2;
       sha256 = "0y21nfpa5s8qmx0srdlilyndas3sgl0c6rc26d5fx2vx436m1qpd";
     };
-    buildInputs = [pkgconfig compositeproto libX11 libXfixes xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ compositeproto libX11 libXfixes xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit compositeproto libX11 libXfixes xproto ;};
 
   libXcursor = (mkDerivation "libXcursor" {
-    name = "libXcursor-1.1.14";
+    name = "libXcursor-1.1.15";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXcursor-1.1.14.tar.bz2;
-      sha256 = "1prkdicl5y5yx32h1azh6gjfbijvjp415javv8dsakd13jrarilv";
+      url = mirror://xorg/individual/lib/libXcursor-1.1.15.tar.bz2;
+      sha256 = "0syzlfvh29037p0vnlc8f3jxz8nl55k65blswsakklkwsc6nfki9";
     };
-    buildInputs = [pkgconfig fixesproto libX11 libXfixes xproto libXrender ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fixesproto libX11 libXfixes xproto libXrender ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fixesproto libX11 libXfixes xproto libXrender ;};
 
   libXdamage = (mkDerivation "libXdamage" {
@@ -674,7 +818,9 @@ let
       url = mirror://xorg/individual/lib/libXdamage-1.1.4.tar.bz2;
       sha256 = "1bamagq7g6s0d23l8rb3nppj8ifqj05f7z9bhbs4fdg8az3ffgvw";
     };
-    buildInputs = [pkgconfig damageproto fixesproto libX11 xextproto libXfixes xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ damageproto fixesproto libX11 xextproto libXfixes xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit damageproto fixesproto libX11 xextproto libXfixes xproto ;};
 
   libXdmcp = (mkDerivation "libXdmcp" {
@@ -684,7 +830,9 @@ let
       url = mirror://xorg/individual/lib/libXdmcp-1.1.2.tar.bz2;
       sha256 = "1qp4yhxbfnpj34swa0fj635kkihdkwaiw7kf55cg5zqqg630kzl1";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   libXext = (mkDerivation "libXext" {
@@ -694,27 +842,45 @@ let
       url = mirror://xorg/individual/lib/libXext-1.3.3.tar.bz2;
       sha256 = "0dbfn5bznnrhqzvkrcmw4c44yvvpwdcsrvzxf4rk27r36b9x865m";
     };
-    buildInputs = [pkgconfig libX11 xextproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xextproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xextproto xproto ;};
 
   libXfixes = (mkDerivation "libXfixes" {
-    name = "libXfixes-5.0.1";
+    name = "libXfixes-5.0.3";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXfixes-5.0.1.tar.bz2;
-      sha256 = "0rs7qgzr6dpr62db7sd91c1b47hzhzfr010qwnpcm8sg122w1gk3";
+      url = mirror://xorg/individual/lib/libXfixes-5.0.3.tar.bz2;
+      sha256 = "1miana3y4hwdqdparsccmygqr3ic3hs5jrqfzp70hvi2zwxd676y";
     };
-    buildInputs = [pkgconfig fixesproto libX11 xextproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fixesproto libX11 xextproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fixesproto libX11 xextproto xproto ;};
 
   libXfont = (mkDerivation "libXfont" {
-    name = "libXfont-1.5.1";
+    name = "libXfont-1.5.4";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXfont-1.5.1.tar.bz2;
-      sha256 = "1630v3sfvwwlimb2ja10c84ql6v1mw9bdfhvan7pbybkgi99h25p";
+      url = mirror://xorg/individual/lib/libXfont-1.5.4.tar.bz2;
+      sha256 = "0hiji1bvpl78aj3a3141hkk353aich71wv8l5l2z51scfy878zqs";
     };
-    buildInputs = [pkgconfig libfontenc fontsproto freetype xproto xtrans zlib ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libfontenc fontsproto freetype xproto xtrans zlib ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit libfontenc fontsproto freetype xproto xtrans zlib ;};
+
+  libXfont2 = (mkDerivation "libXfont2" {
+    name = "libXfont2-2.0.3";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/lib/libXfont2-2.0.3.tar.bz2;
+      sha256 = "0klwmimmhm3axpj8pwn5l41lbggh47r5aazhw63zxkbwfgyvg2hf";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libfontenc fontsproto freetype xproto xtrans zlib ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libfontenc fontsproto freetype xproto xtrans zlib ;};
 
   libXft = (mkDerivation "libXft" {
@@ -724,17 +890,21 @@ let
       url = mirror://xorg/individual/lib/libXft-2.3.2.tar.bz2;
       sha256 = "0k6wzi5rzs0d0n338ms8n8lfyhq914hw4yl2j7553wqxfqjci8zm";
     };
-    buildInputs = [pkgconfig fontconfig freetype libX11 xproto libXrender ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontconfig freetype libX11 xproto libXrender ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontconfig freetype libX11 xproto libXrender ;};
 
   libXi = (mkDerivation "libXi" {
-    name = "libXi-1.7.5";
+    name = "libXi-1.7.9";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXi-1.7.5.tar.bz2;
-      sha256 = "0ad21jy40d8b2f9ldadx7lkspmvka1i9r5jqqfwxdxyqnpgdfr6r";
+      url = mirror://xorg/individual/lib/libXi-1.7.9.tar.bz2;
+      sha256 = "0idg1wc01hndvaa820fvfs7phvd1ymf0lldmq6386i7rhkzvirn2";
     };
-    buildInputs = [pkgconfig inputproto libX11 libXext xextproto libXfixes xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto libX11 libXext xextproto libXfixes xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto libX11 libXext xextproto libXfixes xproto ;};
 
   libXinerama = (mkDerivation "libXinerama" {
@@ -744,7 +914,9 @@ let
       url = mirror://xorg/individual/lib/libXinerama-1.1.3.tar.bz2;
       sha256 = "1qlqfvzw45gdzk9xirgwlp2qgj0hbsyiqj8yh8zml2bk2ygnjibs";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto xineramaproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto xineramaproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto xineramaproto ;};
 
   libXmu = (mkDerivation "libXmu" {
@@ -754,7 +926,9 @@ let
       url = mirror://xorg/individual/lib/libXmu-1.1.2.tar.bz2;
       sha256 = "02wx6jw7i0q5qwx87yf94fsn3h0xpz1k7dz1nkwfwm1j71ydqvkm";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto xproto libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto xproto libXt ;};
 
   libXp = (mkDerivation "libXp" {
@@ -764,17 +938,21 @@ let
       url = mirror://xorg/individual/lib/libXp-1.0.3.tar.bz2;
       sha256 = "0mwc2jwmq03b1m9ihax5c6gw2ln8rc70zz4fsj3kb7440nchqdkz";
     };
-    buildInputs = [pkgconfig printproto libX11 libXau libXext xextproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ printproto libX11 libXau libXext xextproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit printproto libX11 libXau libXext xextproto ;};
 
   libXpm = (mkDerivation "libXpm" {
-    name = "libXpm-3.5.11";
+    name = "libXpm-3.5.12";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXpm-3.5.11.tar.bz2;
-      sha256 = "07041q4k8m4nirzl7lrqn8by2zylx0xvh6n0za301qqs3njszgf5";
+      url = mirror://xorg/individual/lib/libXpm-3.5.12.tar.bz2;
+      sha256 = "1v5xaiw4zlhxspvx76y3hq4wpxv7mpj6parqnwdqvpj8vbinsspx";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto xproto libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto xproto libXt ;};
 
   libXpresent = (mkDerivation "libXpresent" {
@@ -784,37 +962,45 @@ let
       url = mirror://xorg/individual/lib/libXpresent-1.0.0.tar.bz2;
       sha256 = "12kvvar3ihf6sw49h6ywfdiwmb8i1gh8wasg1zhzp6hs2hay06n1";
     };
-    buildInputs = [pkgconfig presentproto libX11 xextproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ presentproto libX11 xextproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit presentproto libX11 xextproto xproto ;};
 
   libXrandr = (mkDerivation "libXrandr" {
-    name = "libXrandr-1.5.0";
+    name = "libXrandr-1.5.1";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXrandr-1.5.0.tar.bz2;
-      sha256 = "0n6ycs1arf4wb1cal9il6v7vbxbf21qhs9sbfl8xndgwnxclk1kg";
+      url = mirror://xorg/individual/lib/libXrandr-1.5.1.tar.bz2;
+      sha256 = "06pmphx8lp3iywqnh88fvbfb0d8xgkx0qpvan49akpja1vxfgy8z";
     };
-    buildInputs = [pkgconfig randrproto renderproto libX11 libXext xextproto xproto libXrender ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ randrproto renderproto libX11 libXext xextproto xproto libXrender ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit randrproto renderproto libX11 libXext xextproto xproto libXrender ;};
 
   libXrender = (mkDerivation "libXrender" {
-    name = "libXrender-0.9.9";
+    name = "libXrender-0.9.10";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXrender-0.9.9.tar.bz2;
-      sha256 = "06myx7044qqdswxndsmd82fpp670klnizkgzdm194h51h1wyabzw";
+      url = mirror://xorg/individual/lib/libXrender-0.9.10.tar.bz2;
+      sha256 = "0j89cnb06g8x79wmmnwzykgkkfdhin9j7hjpvsxwlr3fz1wmjvf0";
     };
-    buildInputs = [pkgconfig renderproto libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ renderproto libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit renderproto libX11 xproto ;};
 
   libXres = (mkDerivation "libXres" {
-    name = "libXres-1.0.7";
+    name = "libXres-1.2.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXres-1.0.7.tar.bz2;
-      sha256 = "1rd0bzn67cpb2qkc946gch2183r4bdjfhs6cpqbipy47m9a91296";
+      url = mirror://xorg/individual/lib/libXres-1.2.0.tar.bz2;
+      sha256 = "1m0jr0lbz9ixpp9ihk68349q0i7ry2379lnfzdy4mrl86ijc2xgz";
     };
-    buildInputs = [pkgconfig resourceproto libX11 libXext xextproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ resourceproto libX11 libXext xextproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit resourceproto libX11 libXext xextproto xproto ;};
 
   libXt = (mkDerivation "libXt" {
@@ -824,37 +1010,45 @@ let
       url = mirror://xorg/individual/lib/libXt-1.1.5.tar.bz2;
       sha256 = "06lz6i7rbrp19kgikpaz4c97fw7n31k2h2aiikczs482g2zbdvj6";
     };
-    buildInputs = [pkgconfig libICE kbproto libSM libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libICE kbproto libSM libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libICE kbproto libSM libX11 xproto ;};
 
   libXtst = (mkDerivation "libXtst" {
-    name = "libXtst-1.2.2";
+    name = "libXtst-1.2.3";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXtst-1.2.2.tar.bz2;
-      sha256 = "1ngn161nq679ffmbwl81i2hn75jjg5b3ffv6n4jilpvyazypy2pg";
+      url = mirror://xorg/individual/lib/libXtst-1.2.3.tar.bz2;
+      sha256 = "012jpyj7xfm653a9jcfqbzxyywdmwb2b5wr1dwylx14f3f54jma6";
     };
-    buildInputs = [pkgconfig inputproto recordproto libX11 libXext xextproto libXi ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto recordproto libX11 libXext xextproto libXi ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto recordproto libX11 libXext xextproto libXi ;};
 
   libXv = (mkDerivation "libXv" {
-    name = "libXv-1.0.10";
+    name = "libXv-1.0.11";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXv-1.0.10.tar.bz2;
-      sha256 = "09a5j6bisysiipd0nw6s352565bp0n6gbyhv5hp63s3cd3w95zjm";
+      url = mirror://xorg/individual/lib/libXv-1.0.11.tar.bz2;
+      sha256 = "125hn06bd3d8y97hm2pbf5j55gg4r2hpd3ifad651i4sr7m16v6j";
     };
-    buildInputs = [pkgconfig videoproto libX11 libXext xextproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ videoproto libX11 libXext xextproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit videoproto libX11 libXext xextproto xproto ;};
 
   libXvMC = (mkDerivation "libXvMC" {
-    name = "libXvMC-1.0.9";
+    name = "libXvMC-1.0.10";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libXvMC-1.0.9.tar.bz2;
-      sha256 = "0mjp1b21dvkaz7r0iq085r92nh5vkpmx99awfgqq9hgzyvgxf0q7";
+      url = mirror://xorg/individual/lib/libXvMC-1.0.10.tar.bz2;
+      sha256 = "0bpffxr5dal90a8miv2w0rif61byqxq2f5angj4z1bnznmws00g5";
     };
-    buildInputs = [pkgconfig videoproto libX11 libXext xextproto xproto libXv ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ videoproto libX11 libXext xextproto xproto libXv ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit videoproto libX11 libXext xextproto xproto libXv ;};
 
   libXxf86dga = (mkDerivation "libXxf86dga" {
@@ -864,7 +1058,9 @@ let
       url = mirror://xorg/individual/lib/libXxf86dga-1.1.4.tar.bz2;
       sha256 = "0zn7aqj8x0951d8zb2h2andldvwkzbsc4cs7q023g6nzq6vd9v4f";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto xf86dgaproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto xf86dgaproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto xf86dgaproto xproto ;};
 
   libXxf86misc = (mkDerivation "libXxf86misc" {
@@ -874,7 +1070,9 @@ let
       url = mirror://xorg/individual/lib/libXxf86misc-1.0.3.tar.bz2;
       sha256 = "0nvbq9y6k6m9hxdvg3crycqsnnxf1859wrisqcs37z9fhq044gsn";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto xf86miscproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto xf86miscproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto xf86miscproto xproto ;};
 
   libXxf86vm = (mkDerivation "libXxf86vm" {
@@ -884,7 +1082,9 @@ let
       url = mirror://xorg/individual/lib/libXxf86vm-1.1.4.tar.bz2;
       sha256 = "0mydhlyn72i7brjwypsqrpkls3nm6vxw0li8b2nw0caz7kwjgvmg";
     };
-    buildInputs = [pkgconfig libX11 libXext xextproto xf86vidmodeproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext xextproto xf86vidmodeproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext xextproto xf86vidmodeproto xproto ;};
 
   libdmx = (mkDerivation "libdmx" {
@@ -894,7 +1094,9 @@ let
       url = mirror://xorg/individual/lib/libdmx-1.1.3.tar.bz2;
       sha256 = "00djlxas38kbsrglcmwmxfbmxjdchlbj95pqwjvdg8jn5rns6zf9";
     };
-    buildInputs = [pkgconfig dmxproto libX11 libXext xextproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ dmxproto libX11 libXext xextproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit dmxproto libX11 libXext xextproto ;};
 
   libfontenc = (mkDerivation "libfontenc" {
@@ -904,37 +1106,45 @@ let
       url = mirror://xorg/individual/lib/libfontenc-1.1.3.tar.bz2;
       sha256 = "08gxmrhgw97mv0pvkfmd46zzxrn6zdw4g27073zl55gwwqq8jn3h";
     };
-    buildInputs = [pkgconfig xproto zlib ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto zlib ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto zlib ;};
 
   libpciaccess = (mkDerivation "libpciaccess" {
-    name = "libpciaccess-0.13.4";
+    name = "libpciaccess-0.14";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/lib/libpciaccess-0.13.4.tar.bz2;
-      sha256 = "1krgryi9ngjr66242v0v5mczihgv0y7rrvx0563arr318mjn9y07";
+      url = mirror://xorg/individual/lib/libpciaccess-0.14.tar.bz2;
+      sha256 = "197jbcpvp4z4x6j705mq2y4fsnnypy6f85y8xalgwhgx5bhl7x9x";
     };
-    buildInputs = [pkgconfig zlib ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ zlib ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit zlib ;};
 
   libpthreadstubs = (mkDerivation "libpthreadstubs" {
-    name = "libpthread-stubs-0.3";
+    name = "libpthread-stubs-0.4";
     builder = ./builder.sh;
     src = fetchurl {
-      url = http://xcb.freedesktop.org/dist/libpthread-stubs-0.3.tar.bz2;
-      sha256 = "16bjv3in19l84hbri41iayvvg4ls9gv1ma0x0qlbmwy67i7dbdim";
+      url = http://xcb.freedesktop.org/dist/libpthread-stubs-0.4.tar.bz2;
+      sha256 = "0cz7s9w8lqgzinicd4g36rjg08zhsbyngh0w68c3np8nlc8mkl74";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   libxcb = (mkDerivation "libxcb" {
-    name = "libxcb-1.11.1";
+    name = "libxcb-1.12";
     builder = ./builder.sh;
     src = fetchurl {
-      url = http://xcb.freedesktop.org/dist/libxcb-1.11.1.tar.bz2;
-      sha256 = "0c4xyvdyx5adh8dzyhnrmvwwz24gri4z1czxmxqm63i0gmngs85p";
+      url = http://xcb.freedesktop.org/dist/libxcb-1.12.tar.bz2;
+      sha256 = "0nvv0la91cf8p5qqlb3r5xnmg1jn2wphn4fb5jfbr6byqsvv3psa";
     };
-    buildInputs = [pkgconfig libxslt libpthreadstubs python libXau xcbproto libXdmcp ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libxslt libpthreadstubs python libXau xcbproto libXdmcp ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libxslt libpthreadstubs python libXau xcbproto libXdmcp ;};
 
   libxkbfile = (mkDerivation "libxkbfile" {
@@ -944,7 +1154,9 @@ let
       url = mirror://xorg/individual/lib/libxkbfile-1.0.9.tar.bz2;
       sha256 = "0smimr14zvail7ar68n7spvpblpdnih3jxrva7cpa6cn602px0ai";
     };
-    buildInputs = [pkgconfig kbproto libX11 ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ kbproto libX11 ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit kbproto libX11 ;};
 
   libxshmfence = (mkDerivation "libxshmfence" {
@@ -954,7 +1166,9 @@ let
       url = mirror://xorg/individual/lib/libxshmfence-1.2.tar.bz2;
       sha256 = "032b0nlkdrpbimdld4gqvhqx53rzn8fawvf1ybhzn7lcswgjs6yj";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   lndir = (mkDerivation "lndir" {
@@ -964,7 +1178,9 @@ let
       url = mirror://xorg/individual/util/lndir-1.0.3.tar.bz2;
       sha256 = "0pdngiy8zdhsiqx2am75yfcl36l7kd7d7nl0rss8shcdvsqgmx29";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   luit = (mkDerivation "luit" {
@@ -974,7 +1190,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/luit-1.1.1.tar.bz2;
       sha256 = "0dn694mk56x6hdk6y9ylx4f128h5jcin278gnw2gb807rf3ygc1h";
     };
-    buildInputs = [pkgconfig libfontenc ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libfontenc ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libfontenc ;};
 
   makedepend = (mkDerivation "makedepend" {
@@ -984,7 +1202,9 @@ let
       url = mirror://xorg/individual/util/makedepend-1.0.5.tar.bz2;
       sha256 = "09alw99r6y2bbd1dc786n3jfgv4j520apblyn7cw6jkjydshba7p";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   mkfontdir = (mkDerivation "mkfontdir" {
@@ -994,7 +1214,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/mkfontdir-1.0.7.tar.bz2;
       sha256 = "0c3563kw9fg15dpgx4dwvl12qz6sdqdns1pxa574hc7i5m42mman";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   mkfontscale = (mkDerivation "mkfontscale" {
@@ -1004,17 +1226,21 @@ let
       url = mirror://xorg/individual/app/mkfontscale-1.1.2.tar.bz2;
       sha256 = "081z8lwh9c1gyrx3ad12whnpv3jpfbqsc366mswpfm48mwl54vcc";
     };
-    buildInputs = [pkgconfig libfontenc freetype xproto zlib ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libfontenc freetype xproto zlib ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libfontenc freetype xproto zlib ;};
 
   presentproto = (mkDerivation "presentproto" {
-    name = "presentproto-1.0";
+    name = "presentproto-1.1";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/proto/presentproto-1.0.tar.bz2;
-      sha256 = "1kir51aqg9cwazs14ivcldcn3mzadqgykc9cg87rm40zf947sb41";
+      url = mirror://xorg/individual/proto/presentproto-1.1.tar.bz2;
+      sha256 = "1f96dlgfwhsd0834z8ydjzjnb0cwha5r6lxgia4say4zhsl276zn";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   printproto = (mkDerivation "printproto" {
@@ -1024,7 +1250,9 @@ let
       url = mirror://xorg/individual/proto/printproto-1.0.5.tar.bz2;
       sha256 = "06liap8n4s25sgp27d371cc7yg9a08dxcr3pmdjp761vyin3360j";
     };
-    buildInputs = [pkgconfig libXau ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libXau ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libXau ;};
 
   randrproto = (mkDerivation "randrproto" {
@@ -1034,7 +1262,9 @@ let
       url = mirror://xorg/individual/proto/randrproto-1.5.0.tar.bz2;
       sha256 = "0s4496z61y5q45q20gldwpf788b9nsa8hb13gnck1mwwwwrmarsc";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   recordproto = (mkDerivation "recordproto" {
@@ -1044,7 +1274,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/recordproto-1.14.2.tar.bz2;
       sha256 = "0w3kgr1zabwf79bpc28dcnj0fpni6r53rpi82ngjbalj5s6m8xx7";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   renderproto = (mkDerivation "renderproto" {
@@ -1054,7 +1286,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/renderproto-0.11.1.tar.bz2;
       sha256 = "0dr5xw6s0qmqg0q5pdkb4jkdhaja0vbfqla79qh5j1xjj9dmlwq6";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   resourceproto = (mkDerivation "resourceproto" {
@@ -1064,7 +1298,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/resourceproto-1.2.0.tar.bz2;
       sha256 = "0638iyfiiyjw1hg3139pai0j6m65gkskrvd9684zgc6ydcx00riw";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   scrnsaverproto = (mkDerivation "scrnsaverproto" {
@@ -1074,17 +1310,21 @@ let
       url = mirror://xorg/X11R7.7/src/everything/scrnsaverproto-1.2.2.tar.bz2;
       sha256 = "0rfdbfwd35d761xkfifcscx56q0n56043ixlmv70r4v4l66hmdwb";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   sessreg = (mkDerivation "sessreg" {
-    name = "sessreg-1.1.0";
+    name = "sessreg-1.1.1";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/sessreg-1.1.0.tar.bz2;
-      sha256 = "0z013rskwmdadd8cdlxvh4asmgim61qijyzfbqmr1q1mg1jpf4am";
+      url = mirror://xorg/individual/app/sessreg-1.1.1.tar.bz2;
+      sha256 = "1qd66mg2bnppqz4xgdjzif2488zl82vx2c26ld3nb8pnyginm9vq";
     };
-    buildInputs = [pkgconfig xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xproto ;};
 
   setxkbmap = (mkDerivation "setxkbmap" {
@@ -1094,7 +1334,9 @@ let
       url = mirror://xorg/individual/app/setxkbmap-1.3.1.tar.bz2;
       sha256 = "1qfk097vjysqb72pq89h0la3462kbb2dh1d11qzs2fr67ybb7pd9";
     };
-    buildInputs = [pkgconfig libX11 libxkbfile ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libxkbfile ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libxkbfile ;};
 
   smproxy = (mkDerivation "smproxy" {
@@ -1104,7 +1346,9 @@ let
       url = mirror://xorg/individual/app/smproxy-1.0.6.tar.bz2;
       sha256 = "0rkjyzmsdqmlrkx8gy2j4q6iksk58hcc92xzdprkf8kml9ar3wbc";
     };
-    buildInputs = [pkgconfig libICE libSM libXmu libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libICE libSM libXmu libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libICE libSM libXmu libXt ;};
 
   twm = (mkDerivation "twm" {
@@ -1114,27 +1358,33 @@ let
       url = mirror://xorg/individual/app/twm-1.0.9.tar.bz2;
       sha256 = "02iicvhkp3i7q5rliyymiq9bppjr0pzfs6rgb78kppryqdx1cxf5";
     };
-    buildInputs = [pkgconfig libICE libSM libX11 libXext libXmu xproto libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libICE libSM libX11 libXext libXmu xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libICE libSM libX11 libXext libXmu xproto libXt ;};
 
   utilmacros = (mkDerivation "utilmacros" {
-    name = "util-macros-1.19.0";
+    name = "util-macros-1.19.2";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/util/util-macros-1.19.0.tar.bz2;
-      sha256 = "1fnhpryf55l0yqajxn0cxan3kvsjzi67nlanz8clwqzf54cb2d98";
+      url = mirror://xorg/individual/util/util-macros-1.19.2.tar.bz2;
+      sha256 = "04p7ydqxgq37jklnfj18b70zsifiz4h50wvrk94i2112mmv37r6p";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   videoproto = (mkDerivation "videoproto" {
-    name = "videoproto-2.3.2";
+    name = "videoproto-2.3.3";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/proto/videoproto-2.3.2.tar.bz2;
-      sha256 = "1dnlkd9nb0m135lgd6hd61vc29sdyarsyya8aqpx7z10p261dbld";
+      url = mirror://xorg/individual/proto/videoproto-2.3.3.tar.bz2;
+      sha256 = "00m7rh3pwmsld4d5fpii3xfk5ciqn17kkk38gfpzrrh8zn4ki067";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   windowswmproto = (mkDerivation "windowswmproto" {
@@ -1144,7 +1394,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/windowswmproto-1.0.4.tar.bz2;
       sha256 = "0syjxgy4m8l94qrm03nvn5k6bkxc8knnlld1gbllym97nvnv0ny0";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   x11perf = (mkDerivation "x11perf" {
@@ -1154,17 +1406,21 @@ let
       url = mirror://xorg/individual/app/x11perf-1.6.0.tar.bz2;
       sha256 = "0lb716yfdb8f11h4cz93d1bapqdxf1xplsb21kbp4xclq7g9hw78";
     };
-    buildInputs = [pkgconfig libX11 libXext libXft libXmu xproto libXrender ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext libXft libXmu xproto libXrender ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext libXft libXmu xproto libXrender ;};
 
   xauth = (mkDerivation "xauth" {
-    name = "xauth-1.0.9";
+    name = "xauth-1.0.10";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/xauth-1.0.9.tar.bz2;
-      sha256 = "13y2invb0894b1in03jbglximbz6v31y2kr4yjjgica8xciibkjn";
+      url = mirror://xorg/individual/app/xauth-1.0.10.tar.bz2;
+      sha256 = "0kgwz9rmxjfdvi2syf8g0ms5rr5cgyqx4n0n1m960kyz7k745zjs";
     };
-    buildInputs = [pkgconfig libX11 libXau libXext libXmu xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXau libXext libXmu xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXau libXext libXmu xproto ;};
 
   xbacklight = (mkDerivation "xbacklight" {
@@ -1174,7 +1430,9 @@ let
       url = mirror://xorg/individual/app/xbacklight-1.2.1.tar.bz2;
       sha256 = "0arnd1j8vzhzmw72mqhjjcb2qwcbs9qphsy3ps593ajyld8wzxhp";
     };
-    buildInputs = [pkgconfig libxcb xcbutil ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libxcb xcbutil ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libxcb xcbutil ;};
 
   xbitmaps = (mkDerivation "xbitmaps" {
@@ -1184,17 +1442,21 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xbitmaps-1.1.1.tar.bz2;
       sha256 = "178ym90kwidia6nas4qr5n5yqh698vv8r02js0r4vg3b6lsb0w9n";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xcbproto = (mkDerivation "xcbproto" {
-    name = "xcb-proto-1.11";
+    name = "xcb-proto-1.12";
     builder = ./builder.sh;
     src = fetchurl {
-      url = http://xcb.freedesktop.org/dist/xcb-proto-1.11.tar.bz2;
-      sha256 = "0bp3f53l9fy5x3mn1rkj1g81aiyzl90wacwvqdgy831aa3kfxb5l";
+      url = http://xcb.freedesktop.org/dist/xcb-proto-1.12.tar.bz2;
+      sha256 = "01j91946q8f34l1mbvmmgvyc393sm28ym4lxlacpiav4qsjan8jr";
     };
-    buildInputs = [pkgconfig python ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ python ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit python ;};
 
   xcbutil = (mkDerivation "xcbutil" {
@@ -1204,17 +1466,21 @@ let
       url = http://xcb.freedesktop.org/dist/xcb-util-0.4.0.tar.bz2;
       sha256 = "1sahmrgbpyki4bb72hxym0zvxwnycmswsxiisgqlln9vrdlr9r26";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xproto ;};
 
   xcbutilcursor = (mkDerivation "xcbutilcursor" {
-    name = "xcb-util-cursor-0.1.2";
+    name = "xcb-util-cursor-0.1.3";
     builder = ./builder.sh;
     src = fetchurl {
-      url = http://xcb.freedesktop.org/dist/xcb-util-cursor-0.1.2.tar.bz2;
-      sha256 = "0fpv46zb7kz04qxwvpax4cpd2kd8yhsm2n0if1isniqdh5xkcrgd";
+      url = http://xcb.freedesktop.org/dist/xcb-util-cursor-0.1.3.tar.bz2;
+      sha256 = "0krr4rcw6r42cncinzvzzdqnmxk3nrgpnadyg2h8k9x10q3hm885";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xcbutilimage xcbutilrenderutil xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xcbutilimage xcbutilrenderutil xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xcbutilimage xcbutilrenderutil xproto ;};
 
   xcbutilerrors = (mkDerivation "xcbutilerrors" {
@@ -1224,7 +1490,9 @@ let
       url = http://xcb.freedesktop.org/dist/xcb-util-errors-1.0.tar.bz2;
       sha256 = "158rm913dg3hxrrhyvvxr8bcm0pjy5jws70dhy2s12w1krv829k8";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xcbproto xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xcbproto xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xcbproto xproto ;};
 
   xcbutilimage = (mkDerivation "xcbutilimage" {
@@ -1234,7 +1502,9 @@ let
       url = http://xcb.freedesktop.org/dist/xcb-util-image-0.4.0.tar.bz2;
       sha256 = "1z1gxacg7q4cw6jrd26gvi5y04npsyavblcdad1xccc8swvnmf9d";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xcbutil xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xcbutil xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xcbutil xproto ;};
 
   xcbutilkeysyms = (mkDerivation "xcbutilkeysyms" {
@@ -1244,7 +1514,9 @@ let
       url = http://xcb.freedesktop.org/dist/xcb-util-keysyms-0.4.0.tar.bz2;
       sha256 = "1nbd45pzc1wm6v5drr5338j4nicbgxa5hcakvsvm5pnyy47lky0f";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xproto ;};
 
   xcbutilrenderutil = (mkDerivation "xcbutilrenderutil" {
@@ -1254,7 +1526,9 @@ let
       url = http://xcb.freedesktop.org/dist/xcb-util-renderutil-0.3.9.tar.bz2;
       sha256 = "0nza1csdvvxbmk8vgv8vpmq7q8h05xrw3cfx9lwxd1hjzd47xsf6";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xproto ;};
 
   xcbutilwm = (mkDerivation "xcbutilwm" {
@@ -1264,7 +1538,9 @@ let
       url = http://xcb.freedesktop.org/dist/xcb-util-wm-0.4.1.tar.bz2;
       sha256 = "0gra7hfyxajic4mjd63cpqvd20si53j1q3rbdlkqkahfciwq3gr8";
     };
-    buildInputs = [pkgconfig gperf m4 libxcb xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ gperf m4 libxcb xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit gperf m4 libxcb xproto ;};
 
   xclock = (mkDerivation "xclock" {
@@ -1274,7 +1550,9 @@ let
       url = mirror://xorg/individual/app/xclock-1.0.7.tar.bz2;
       sha256 = "1l3xv4bsca6bwxx73jyjz0blav86i7vwffkhdb1ac81y9slyrki3";
     };
-    buildInputs = [pkgconfig libX11 libXaw libXft libxkbfile libXmu xproto libXrender libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXaw libXft libxkbfile libXmu xproto libXrender libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXaw libXft libxkbfile libXmu xproto libXrender libXt ;};
 
   xcmiscproto = (mkDerivation "xcmiscproto" {
@@ -1284,7 +1562,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xcmiscproto-1.2.2.tar.bz2;
       sha256 = "1pyjv45wivnwap2wvsbrzdvjc5ql8bakkbkrvcv6q9bjjf33ccmi";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xcmsdb = (mkDerivation "xcmsdb" {
@@ -1294,7 +1574,9 @@ let
       url = mirror://xorg/individual/app/xcmsdb-1.0.5.tar.bz2;
       sha256 = "1ik7gzlp2igz183x70883000ygp99r20x3aah6xhaslbpdhm6n75";
     };
-    buildInputs = [pkgconfig libX11 ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 ;};
 
   xcompmgr = (mkDerivation "xcompmgr" {
@@ -1304,7 +1586,9 @@ let
       url = mirror://xorg/individual/app/xcompmgr-1.1.7.tar.bz2;
       sha256 = "14k89mz13jxgp4h2pz0yq0fbkw1lsfcb3acv8vkknc9i4ld9n168";
     };
-    buildInputs = [pkgconfig libXcomposite libXdamage libXext libXfixes libXrender ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libXcomposite libXdamage libXext libXfixes libXrender ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libXcomposite libXdamage libXext libXfixes libXrender ;};
 
   xcursorgen = (mkDerivation "xcursorgen" {
@@ -1314,7 +1598,9 @@ let
       url = mirror://xorg/individual/app/xcursorgen-1.0.6.tar.bz2;
       sha256 = "0v7nncj3kaa8c0524j7ricdf4rvld5i7c3m6fj55l5zbah7r3j1i";
     };
-    buildInputs = [pkgconfig libpng libX11 libXcursor ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libpng libX11 libXcursor ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libpng libX11 libXcursor ;};
 
   xcursorthemes = (mkDerivation "xcursorthemes" {
@@ -1324,7 +1610,9 @@ let
       url = mirror://xorg/individual/data/xcursor-themes-1.0.4.tar.bz2;
       sha256 = "11mv661nj1p22sqkv87ryj2lcx4m68a04b0rs6iqh3fzp42jrzg3";
     };
-    buildInputs = [pkgconfig libXcursor ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libXcursor ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libXcursor ;};
 
   xdm = (mkDerivation "xdm" {
@@ -1334,7 +1622,9 @@ let
       url = mirror://xorg/individual/app/xdm-1.1.11.tar.bz2;
       sha256 = "0iqw11977lpr9nk1is4fca84d531vck0mq7jldwl44m0vrnl5nnl";
     };
-    buildInputs = [pkgconfig libX11 libXau libXaw libXdmcp libXext libXft libXinerama libXmu libXpm libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXau libXaw libXdmcp libXext libXft libXinerama libXmu libXpm libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXau libXaw libXdmcp libXext libXft libXinerama libXmu libXpm libXt ;};
 
   xdpyinfo = (mkDerivation "xdpyinfo" {
@@ -1344,7 +1634,9 @@ let
       url = mirror://xorg/individual/app/xdpyinfo-1.3.2.tar.bz2;
       sha256 = "0ldgrj4w2fa8jng4b3f3biaj0wyn8zvya88pnk70d7k12pcqw8rh";
     };
-    buildInputs = [pkgconfig libdmx libX11 libxcb libXcomposite libXext libXi libXinerama xproto libXrender libXtst libXxf86dga libXxf86misc libXxf86vm ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libdmx libX11 libxcb libXcomposite libXext libXi libXinerama xproto libXrender libXtst libXxf86dga libXxf86misc libXxf86vm ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libdmx libX11 libxcb libXcomposite libXext libXi libXinerama xproto libXrender libXtst libXxf86dga libXxf86misc libXxf86vm ;};
 
   xdriinfo = (mkDerivation "xdriinfo" {
@@ -1354,7 +1646,9 @@ let
       url = mirror://xorg/individual/app/xdriinfo-1.0.5.tar.bz2;
       sha256 = "0681d0y8liqakkpz7mmsf689jcxrvs5291r20qi78mc9xxk3gfjc";
     };
-    buildInputs = [pkgconfig glproto libX11 ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ glproto libX11 ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit glproto libX11 ;};
 
   xev = (mkDerivation "xev" {
@@ -1364,7 +1658,9 @@ let
       url = mirror://xorg/individual/app/xev-1.2.2.tar.bz2;
       sha256 = "0krivhrxpq6719103r541xpi3i3a0y15f7ypc4lnrx8sdhmfcjnr";
     };
-    buildInputs = [pkgconfig libX11 xproto libXrandr ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto libXrandr ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto libXrandr ;};
 
   xextproto = (mkDerivation "xextproto" {
@@ -1374,7 +1670,9 @@ let
       url = mirror://xorg/individual/proto/xextproto-7.3.0.tar.bz2;
       sha256 = "1c2vma9gqgc2v06rfxdiqgwhxmzk2cbmknwf1ng3m76vr0xb5x7k";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xeyes = (mkDerivation "xeyes" {
@@ -1384,7 +1682,9 @@ let
       url = mirror://xorg/individual/app/xeyes-1.1.1.tar.bz2;
       sha256 = "08d5x2kar5kg4yammw6hhk10iva6jmh8cqq176a1z7nm1il9hplp";
     };
-    buildInputs = [pkgconfig libX11 libXext libXmu libXrender libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext libXmu libXrender libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext libXmu libXrender libXt ;};
 
   xf86bigfontproto = (mkDerivation "xf86bigfontproto" {
@@ -1394,7 +1694,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86bigfontproto-1.2.0.tar.bz2;
       sha256 = "0j0n7sj5xfjpmmgx6n5x556rw21hdd18fwmavp95wps7qki214ms";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xf86dgaproto = (mkDerivation "xf86dgaproto" {
@@ -1404,7 +1706,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86dgaproto-2.1.tar.bz2;
       sha256 = "0l4hx48207mx0hp09026r6gy9nl3asbq0c75hri19wp1118zcpmc";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xf86driproto = (mkDerivation "xf86driproto" {
@@ -1414,67 +1718,81 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86driproto-2.1.1.tar.bz2;
       sha256 = "07v69m0g2dfzb653jni4x656jlr7l84c1k39j8qc8vfb45r8sjww";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xf86inputevdev = (mkDerivation "xf86inputevdev" {
-    name = "xf86-input-evdev-2.9.2";
+    name = "xf86-input-evdev-2.10.5";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-input-evdev-2.9.2.tar.bz2;
-      sha256 = "1v7gmjc1ilyhln80i87rivgls3ajlm8lnkm9rn695img66sjj8vr";
+      url = mirror://xorg/individual/driver/xf86-input-evdev-2.10.5.tar.bz2;
+      sha256 = "03dphgwjaxxyys8axc1kyysp6xvy9bjxicsdrhi2jvdgbchadnly";
     };
-    buildInputs = [pkgconfig inputproto udev xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto udev xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto udev xorgserver xproto ;};
 
   xf86inputjoystick = (mkDerivation "xf86inputjoystick" {
-    name = "xf86-input-joystick-1.6.2";
+    name = "xf86-input-joystick-1.6.3";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-input-joystick-1.6.2.tar.bz2;
-      sha256 = "038mfqairyyqvz02rk7v3i070sab1wr0k6fkxvyvxdgkfbnqcfzf";
+      url = mirror://xorg/individual/driver/xf86-input-joystick-1.6.3.tar.bz2;
+      sha256 = "1awfq496d082brgjbr60lhm6jvr9537rflwxqdfqwfzjy3n6jxly";
     };
-    buildInputs = [pkgconfig inputproto kbproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto kbproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto kbproto xorgserver xproto ;};
 
   xf86inputkeyboard = (mkDerivation "xf86inputkeyboard" {
-    name = "xf86-input-keyboard-1.8.1";
+    name = "xf86-input-keyboard-1.9.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-input-keyboard-1.8.1.tar.bz2;
-      sha256 = "04d27kwqq03fc26an6051hs3i0bff8albhnngzyd59wxpwwzzj0s";
+      url = mirror://xorg/individual/driver/xf86-input-keyboard-1.9.0.tar.bz2;
+      sha256 = "12032yg412kyvnmc5fha1in7mpi651d8sa1bk4138s2j2zr01jgp";
     };
-    buildInputs = [pkgconfig inputproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto xorgserver xproto ;};
 
   xf86inputlibinput = (mkDerivation "xf86inputlibinput" {
-    name = "xf86-input-libinput-0.12.0";
+    name = "xf86-input-libinput-0.26.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-input-libinput-0.12.0.tar.bz2;
-      sha256 = "1mi6m1a32xc43na46amfqz0025952whiy3w4wz0wx0d34jf933yv";
+      url = mirror://xorg/individual/driver/xf86-input-libinput-0.26.0.tar.bz2;
+      sha256 = "0yrqs88b7yn9nljwlxzn76jfmvf0sh939kzij5b2jvr2qa7mbjmb";
     };
-    buildInputs = [pkgconfig inputproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto xorgserver xproto ;};
 
   xf86inputmouse = (mkDerivation "xf86inputmouse" {
-    name = "xf86-input-mouse-1.9.1";
+    name = "xf86-input-mouse-1.9.2";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-input-mouse-1.9.1.tar.bz2;
-      sha256 = "1kn5kx3qyn9qqvd6s24a2l1wfgck2pgfvzl90xpl024wfxsx719l";
+      url = mirror://xorg/individual/driver/xf86-input-mouse-1.9.2.tar.bz2;
+      sha256 = "0bsbgww9421792zan43j60mndqprhfxhc48agsi15d3abjqda9gl";
     };
-    buildInputs = [pkgconfig inputproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto xorgserver xproto ;};
 
   xf86inputsynaptics = (mkDerivation "xf86inputsynaptics" {
-    name = "xf86-input-synaptics-1.8.2";
+    name = "xf86-input-synaptics-1.9.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-input-synaptics-1.8.2.tar.bz2;
-      sha256 = "104cd67dqalp1a73jmi61kdpxwsr61w5x5cmqvh819h2pm71c3kv";
+      url = mirror://xorg/individual/driver/xf86-input-synaptics-1.9.0.tar.bz2;
+      sha256 = "0niv0w1czbxh4y3qkqbpdp5gjwhp3379inwhknhif0m4sy4k5fmg";
     };
-    buildInputs = [pkgconfig inputproto randrproto recordproto libX11 libXi xorgserver xproto libXtst ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto randrproto recordproto libX11 libXi xorgserver xproto libXtst ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto randrproto recordproto libX11 libXi xorgserver xproto libXtst ;};
 
   xf86inputvmmouse = (mkDerivation "xf86inputvmmouse" {
@@ -1484,7 +1802,9 @@ let
       url = mirror://xorg/individual/driver/xf86-input-vmmouse-13.1.0.tar.bz2;
       sha256 = "06ckn4hlkpig5vnivl0zj8a7ykcgvrsj8b3iccl1pgn1gaamix8a";
     };
-    buildInputs = [pkgconfig inputproto udev randrproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto udev randrproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto udev randrproto xorgserver xproto ;};
 
   xf86inputvoid = (mkDerivation "xf86inputvoid" {
@@ -1494,7 +1814,9 @@ let
       url = mirror://xorg/individual/driver/xf86-input-void-1.4.1.tar.bz2;
       sha256 = "171k8b8s42s3w73l7ln9jqwk88w4l7r1km2blx1vy898c854yvpr";
     };
-    buildInputs = [pkgconfig xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xorgserver xproto ;};
 
   xf86miscproto = (mkDerivation "xf86miscproto" {
@@ -1504,9 +1826,23 @@ let
       url = mirror://xorg/individual/proto/xf86miscproto-0.9.3.tar.bz2;
       sha256 = "15dhcdpv61fyj6rhzrhnwri9hlw8rjfy05z1vik118lc99mfrf25";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
+  xf86videoamdgpu = (mkDerivation "xf86videoamdgpu" {
+    name = "xf86-video-amdgpu-1.4.0";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-amdgpu-1.4.0.tar.bz2;
+      sha256 = "0z56ifw3xiq9dychv8chg1cny0hq4v3c1r9pqcybk5fp7nzw9jpq";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto mesa_noglu libGL libdrm udev randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto mesa_noglu libGL libdrm udev randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
+
   xf86videoark = (mkDerivation "xf86videoark" {
     name = "xf86-video-ark-0.7.5";
     builder = ./builder.sh;
@@ -1514,28 +1850,46 @@ let
       url = mirror://xorg/individual/driver/xf86-video-ark-0.7.5.tar.bz2;
       sha256 = "07p5vdsj2ckxb6wh02s61akcv4qfg6s1d5ld3jn3lfaayd3f1466";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess xextproto xorgserver xproto ;};
 
   xf86videoast = (mkDerivation "xf86videoast" {
-    name = "xf86-video-ast-0.98.0";
+    name = "xf86-video-ast-1.1.5";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-ast-0.98.0.tar.bz2;
-      sha256 = "188nv73w0p5xhfxz2dffli44yzyn1qhhq3qkwc8wva9dhg25n8lh";
+      url = mirror://xorg/individual/driver/xf86-video-ast-1.1.5.tar.bz2;
+      sha256 = "1pm2cy81ma7ldsw0yfk28b33h9z2hcj5rccrxhfxfgvxsiavrnqy";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videoati = (mkDerivation "xf86videoati" {
-    name = "xf86-video-ati-7.5.0";
+    name = "xf86-video-ati-18.0.1";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-ati-18.0.1.tar.bz2;
+      sha256 = "180l2yw8c63cbcs3zk729vx439aig1d7yicpyxj0nmfl4y0kpskj";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
+
+  xf86videochips = (mkDerivation "xf86videochips" {
+    name = "xf86-video-chips-1.2.7";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-ati-7.5.0.tar.bz2;
-      sha256 = "0dkrw036ikym8aacl43lnf04q0wbms5498xg5b3l16ngnq36ygpc";
+      url = mirror://xorg/individual/driver/xf86-video-chips-1.2.7.tar.bz2;
+      sha256 = "0n4zypmbkjzkw36cjy2braaivhvj60np6w80lcs9mfpabs66ia3f";
     };
-    buildInputs = [pkgconfig fontsproto glamoregl libdrm udev libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
-  }) // {inherit fontsproto glamoregl libdrm udev libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videocirrus = (mkDerivation "xf86videocirrus" {
     name = "xf86-video-cirrus-1.5.3";
@@ -1544,17 +1898,21 @@ let
       url = mirror://xorg/individual/driver/xf86-video-cirrus-1.5.3.tar.bz2;
       sha256 = "1asifc6ld2g9kap15vfhvsvyl69lj7pw3d9ra9mi4najllh7pj7d";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videodummy = (mkDerivation "xf86videodummy" {
-    name = "xf86-video-dummy-0.3.7";
+    name = "xf86-video-dummy-0.3.8";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-dummy-0.3.7.tar.bz2;
-      sha256 = "1046p64xap69vlsmsz5rjv0djc970yhvq44fmllmas0mqp5lzy2n";
+      url = mirror://xorg/individual/driver/xf86-video-dummy-0.3.8.tar.bz2;
+      sha256 = "1fcm9vwgv8wnffbvkzddk4yxrh3kc0np6w65wj8k88q7jf3bn4ip";
     };
-    buildInputs = [pkgconfig fontsproto randrproto renderproto videoproto xf86dgaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto randrproto renderproto videoproto xf86dgaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto randrproto renderproto videoproto xf86dgaproto xorgserver xproto ;};
 
   xf86videofbdev = (mkDerivation "xf86videofbdev" {
@@ -1564,7 +1922,9 @@ let
       url = mirror://xorg/individual/driver/xf86-video-fbdev-0.4.4.tar.bz2;
       sha256 = "06ym7yy017lanj730hfkpfk4znx3dsj8jq3qvyzsn8w294kb7m4x";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xorgserver xproto ;};
 
   xf86videogeode = (mkDerivation "xf86videogeode" {
@@ -1574,7 +1934,9 @@ let
       url = mirror://xorg/individual/driver/xf86-video-geode-2.11.17.tar.bz2;
       sha256 = "0h9w6cfj7s86rg72c6qci8f733hg4g7paan5fwmmj7p74ckd9d07";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videoglide = (mkDerivation "xf86videoglide" {
@@ -1584,17 +1946,21 @@ let
       url = mirror://xorg/individual/driver/xf86-video-glide-1.2.2.tar.bz2;
       sha256 = "1vaav6kx4n00q4fawgqnjmbdkppl0dir2dkrj4ad372mxrvl9c4y";
     };
-    buildInputs = [pkgconfig xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xextproto xorgserver xproto ;};
 
   xf86videoglint = (mkDerivation "xf86videoglint" {
-    name = "xf86-video-glint-1.2.8";
+    name = "xf86-video-glint-1.2.9";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-glint-1.2.8.tar.bz2;
-      sha256 = "08a2aark2yn9irws9c78d9q44dichr03i9zbk61jgr54ncxqhzv5";
+      url = mirror://xorg/individual/driver/xf86-video-glint-1.2.9.tar.bz2;
+      sha256 = "1lkpspvrvrp9s539bhfdjfh4andaqyk63l6zjn8m3km95smk6a45";
     };
-    buildInputs = [pkgconfig libpciaccess videoproto xextproto xf86dgaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libpciaccess videoproto xextproto xf86dgaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libpciaccess videoproto xextproto xf86dgaproto xorgserver xproto ;};
 
   xf86videoi128 = (mkDerivation "xf86videoi128" {
@@ -1604,27 +1970,33 @@ let
       url = mirror://xorg/individual/driver/xf86-video-i128-1.3.6.tar.bz2;
       sha256 = "171b8lbxr56w3isph947dnw7x87hc46v6m3mcxdcz44gk167x0pq";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videoi740 = (mkDerivation "xf86videoi740" {
-    name = "xf86-video-i740-1.3.5";
+    name = "xf86-video-i740-1.3.6";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-i740-1.3.5.tar.bz2;
-      sha256 = "0973zzmdsvlmplcax1c91is7v78lcwy6d9mwp11npgqzl782vq0w";
+      url = mirror://xorg/individual/driver/xf86-video-i740-1.3.6.tar.bz2;
+      sha256 = "0c8nl0yyyw08n4zd6sgw9p3a858wpgf6raczjd70gf47lncms389";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videointel = (mkDerivation "xf86videointel" {
-    name = "xf86-video-intel-2015-07-22";
+    name = "xf86-video-intel-2.99.917";
     builder = ./builder.sh;
     src = fetchurl {
-      url = http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/snapshot/a29e765ec0c1d73ee7ef2dad3aa148214ec04335.tar.gz;
-      sha256 = "094qa8x0f7vgyirjbj9qdyak71nwxnmmsxml4zk49z59blq4l874";
+      url = mirror://xorg/individual/driver/xf86-video-intel-2.99.917.tar.bz2;
+      sha256 = "1jb7jspmzidfixbc0gghyjmnmpqv85i7pi13l4h2hn2ml3p83dq0";
     };
-    buildInputs = [pkgconfig dri2proto dri3proto fontsproto libdrm libpng udev libpciaccess presentproto randrproto renderproto libX11 xcbutil libxcb libXcursor libXdamage libXext xextproto xf86driproto libXfixes xorgserver xproto libXrandr libXrender libxshmfence libXtst libXvMC ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ dri2proto dri3proto fontsproto libdrm libpng udev libpciaccess presentproto randrproto renderproto libX11 xcbutil libxcb libXcursor libXdamage libXext xextproto xf86driproto libXfixes xorgserver xproto libXrandr libXrender libxshmfence libXtst libXvMC ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit dri2proto dri3proto fontsproto libdrm libpng udev libpciaccess presentproto randrproto renderproto libX11 xcbutil libxcb libXcursor libXdamage libXext xextproto xf86driproto libXfixes xorgserver xproto libXrandr libXrender libxshmfence libXtst libXvMC ;};
 
   xf86videomach64 = (mkDerivation "xf86videomach64" {
@@ -1634,29 +2006,23 @@ let
       url = mirror://xorg/individual/driver/xf86-video-mach64-6.9.5.tar.bz2;
       sha256 = "07xlf5nsjm0x18ij5gyy4lf8hwpl10i8chi3skpqjh84drdri61y";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
 
   xf86videomga = (mkDerivation "xf86videomga" {
-    name = "xf86-video-mga-1.6.4";
+    name = "xf86-video-mga-1.6.5";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-mga-1.6.4.tar.bz2;
-      sha256 = "0kyl8w99arviv27pc349zsy2vinnm7mdpy34vr9nzisicw5nkij8";
+      url = mirror://xorg/individual/driver/xf86-video-mga-1.6.5.tar.bz2;
+      sha256 = "08ll52hlar9z446v0wwca5qkj3hxhswwm7vvcgic9xv4cf7csqxn";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
 
-  xf86videomodesetting = (mkDerivation "xf86videomodesetting" {
-    name = "xf86-video-modesetting-0.9.0";
-    builder = ./builder.sh;
-    src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-modesetting-0.9.0.tar.bz2;
-      sha256 = "0p6pjn5bnd2wr3lmas4b12zcq12d9ilvssga93fzlg90fdahikwh";
-    };
-    buildInputs = [pkgconfig fontsproto libdrm udev libpciaccess randrproto libX11 xextproto xorgserver xproto ];
-  }) // {inherit fontsproto libdrm udev libpciaccess randrproto libX11 xextproto xorgserver xproto ;};
-
   xf86videoneomagic = (mkDerivation "xf86videoneomagic" {
     name = "xf86-video-neomagic-1.2.9";
     builder = ./builder.sh;
@@ -1664,7 +2030,9 @@ let
       url = mirror://xorg/individual/driver/xf86-video-neomagic-1.2.9.tar.bz2;
       sha256 = "1whb2kgyqaxdjim27ya404acz50izgmafwnb6y9m89q5n6b97y3j";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess xorgserver xproto ;};
 
   xf86videonewport = (mkDerivation "xf86videonewport" {
@@ -1674,89 +2042,143 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86-video-newport-0.2.4.tar.bz2;
       sha256 = "1yafmp23jrfdmc094i6a4dsizapsc9v0pl65cpc8w1kvn7343k4i";
     };
-    buildInputs = [pkgconfig fontsproto randrproto renderproto videoproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto randrproto renderproto videoproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto randrproto renderproto videoproto xorgserver xproto ;};
 
   xf86videonouveau = (mkDerivation "xf86videonouveau" {
-    name = "xf86-video-nouveau-1.0.11";
+    name = "xf86-video-nouveau-1.0.15";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-nouveau-1.0.11.tar.bz2;
-      sha256 = "0j3847rnffy81iaxxi6vnd8saadrc9jahfmckr0sjgkzg2rf4kzq";
+      url = mirror://xorg/individual/driver/xf86-video-nouveau-1.0.15.tar.bz2;
+      sha256 = "0k0xah72ryjwak4dc4crszxrlkmi9x1s7p3sd4la642n77yi1pmf";
     };
-    buildInputs = [pkgconfig dri2proto fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ dri2proto fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit dri2proto fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videonv = (mkDerivation "xf86videonv" {
-    name = "xf86-video-nv-2.1.20";
+    name = "xf86-video-nv-2.1.21";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-nv-2.1.20.tar.bz2;
-      sha256 = "1gqh1khc4zalip5hh2nksgs7i3piqq18nncgmsx9qvzi05azd5c3";
+      url = mirror://xorg/individual/driver/xf86-video-nv-2.1.21.tar.bz2;
+      sha256 = "0bdk3pc5y0n7p53q4gc2ff7bw16hy5hwdjjxkm5j3s7hdyg6960z";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
 
   xf86videoopenchrome = (mkDerivation "xf86videoopenchrome" {
-    name = "xf86-video-openchrome-0.3.3";
+    name = "xf86-video-openchrome-0.6.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-openchrome-0.3.3.tar.bz2;
-      sha256 = "1v8j4i1r268n4fc5gq54zg1x50j0rhw71f3lba7411mcblg2z7p4";
+      url = mirror://xorg/individual/driver/xf86-video-openchrome-0.6.0.tar.bz2;
+      sha256 = "0x9gq3hw6k661k82ikd1y2kkk4dmgv310xr5q59dwn4k6z37aafs";
     };
-    buildInputs = [pkgconfig fontsproto glproto libdrm udev libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xf86driproto xorgserver xproto libXvMC ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto glproto libdrm udev libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xf86driproto xorgserver xproto libXvMC ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto glproto libdrm udev libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xf86driproto xorgserver xproto libXvMC ;};
 
   xf86videoqxl = (mkDerivation "xf86videoqxl" {
-    name = "xf86-video-qxl-0.1.3";
+    name = "xf86-video-qxl-0.1.5";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-qxl-0.1.3.tar.bz2;
-      sha256 = "1368dd5mihn3s098n7wa3fpjkp8pnamabfjjipkqs9zyrcvncy3m";
+      url = mirror://xorg/individual/driver/xf86-video-qxl-0.1.5.tar.bz2;
+      sha256 = "14jc24znnahhmz4kqalafmllsg8awlz0y6gpgdpk5ih38ph851mi";
     };
-    buildInputs = [pkgconfig fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xf86dgaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xf86dgaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm udev libpciaccess randrproto renderproto videoproto xf86dgaproto xorgserver xproto ;};
 
   xf86videor128 = (mkDerivation "xf86videor128" {
-    name = "xf86-video-r128-6.10.0";
+    name = "xf86-video-r128-6.10.2";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-r128-6.10.0.tar.bz2;
-      sha256 = "0g9m1n5184h05mq14vb6k288zm6g81a9m048id00l8v8f6h33mc0";
+      url = mirror://xorg/individual/driver/xf86-video-r128-6.10.2.tar.bz2;
+      sha256 = "1pkpka5m4cd6iy0f8iqnmg6xci14nb6887ilvxzn3xrsgx8j3nl4";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xorgserver xproto ;};
 
+  xf86videorendition = (mkDerivation "xf86videorendition" {
+    name = "xf86-video-rendition-4.2.6";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-rendition-4.2.6.tar.bz2;
+      sha256 = "1a7rqafxzc2hd0s5pnq8s8j9d3jg64ndc0xnq4160kasyqhwy3k6";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto libpciaccess randrproto renderproto xextproto xorgserver xproto ;};
+
+  xf86videos3virge = (mkDerivation "xf86videos3virge" {
+    name = "xf86-video-s3virge-1.10.7";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-s3virge-1.10.7.tar.bz2;
+      sha256 = "1nm4cngjbw226q63rdacw6nx5lgxv7l7rsa8vhpr0gs80pg6igjx";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xorgserver xproto ;};
+
   xf86videosavage = (mkDerivation "xf86videosavage" {
-    name = "xf86-video-savage-2.3.8";
+    name = "xf86-video-savage-2.3.9";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-savage-2.3.8.tar.bz2;
-      sha256 = "0qzshncynjdmyhavhqw4x5ha3gwbygi0zbsy158fpg1jcnla9kpx";
+      url = mirror://xorg/individual/driver/xf86-video-savage-2.3.9.tar.bz2;
+      sha256 = "11pcrsdpdrwk0mrgv83s5nsx8a9i4lhmivnal3fjbrvi3zdw94rc";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
 
   xf86videosiliconmotion = (mkDerivation "xf86videosiliconmotion" {
-    name = "xf86-video-siliconmotion-1.7.8";
+    name = "xf86-video-siliconmotion-1.7.9";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-siliconmotion-1.7.8.tar.bz2;
-      sha256 = "1sqv0y31mi4zmh9yaxqpzg7p8y2z01j6qys433hb8n4yznllkm79";
+      url = mirror://xorg/individual/driver/xf86-video-siliconmotion-1.7.9.tar.bz2;
+      sha256 = "1g2r6gxqrmjdff95d42msxdw6vmkg2zn5sqv0rxd420iwy8wdwyh";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess videoproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess videoproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess videoproto xextproto xorgserver xproto ;};
 
   xf86videosis = (mkDerivation "xf86videosis" {
-    name = "xf86-video-sis-0.10.7";
+    name = "xf86-video-sis-0.10.9";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-sis-0.10.7.tar.bz2;
-      sha256 = "1l0w84x39gq4y9j81dny9r6rma1xkqvxpsavpkd8h7h8panbcbmy";
+      url = mirror://xorg/individual/driver/xf86-video-sis-0.10.9.tar.bz2;
+      sha256 = "03f1abjjf68y8y1iz768rn95va9d33wmbwfbsqrgl6k0gi0bf9jj";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xf86driproto xineramaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xf86driproto xineramaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xf86driproto xineramaproto xorgserver xproto ;};
 
+  xf86videosisusb = (mkDerivation "xf86videosisusb" {
+    name = "xf86-video-sisusb-0.9.7";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-sisusb-0.9.7.tar.bz2;
+      sha256 = "090lfs3hjz3cjd016v5dybmcsigj6ffvjdhdsqv13k90p4b08h7l";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xineramaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xineramaproto xorgserver xproto ;};
+
   xf86videosuncg6 = (mkDerivation "xf86videosuncg6" {
     name = "xf86-video-suncg6-1.1.2";
     builder = ./builder.sh;
@@ -1764,7 +2186,9 @@ let
       url = mirror://xorg/individual/driver/xf86-video-suncg6-1.1.2.tar.bz2;
       sha256 = "04fgwgk02m4nimlv67rrg1wnyahgymrn6rb2cjj1l8bmzkii4glr";
     };
-    buildInputs = [pkgconfig fontsproto randrproto renderproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto randrproto renderproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto randrproto renderproto xorgserver xproto ;};
 
   xf86videosunffb = (mkDerivation "xf86videosunffb" {
@@ -1774,17 +2198,33 @@ let
       url = mirror://xorg/individual/driver/xf86-video-sunffb-1.2.2.tar.bz2;
       sha256 = "07z3ngifwg2d4jgq8pms47n5lr2yn0ai72g86xxjnb3k20n5ym7s";
     };
-    buildInputs = [pkgconfig fontsproto randrproto renderproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto randrproto renderproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto randrproto renderproto xextproto xorgserver xproto ;};
 
+  xf86videosunleo = (mkDerivation "xf86videosunleo" {
+    name = "xf86-video-sunleo-1.2.2";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-sunleo-1.2.2.tar.bz2;
+      sha256 = "1gacm0s6rii4x5sx9py5bhvs50jd4vs3nnbwjdjymyf31kpdirl3";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto randrproto renderproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto randrproto renderproto xorgserver xproto ;};
+
   xf86videotdfx = (mkDerivation "xf86videotdfx" {
-    name = "xf86-video-tdfx-1.4.6";
+    name = "xf86-video-tdfx-1.4.7";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-tdfx-1.4.6.tar.bz2;
-      sha256 = "0dvdrhyn1iv6rr85v1c52s1gl0j1qrxgv7x0r7qn3ba0gj38i2is";
+      url = mirror://xorg/individual/driver/xf86-video-tdfx-1.4.7.tar.bz2;
+      sha256 = "0hia45z4jc472fxp00803nznizcn4h1ybp63jcsb4lmd9vhqxx2c";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xorgserver xproto ;};
 
   xf86videotga = (mkDerivation "xf86videotga" {
@@ -1794,17 +2234,21 @@ let
       url = mirror://xorg/individual/driver/xf86-video-tga-1.2.2.tar.bz2;
       sha256 = "0cb161lvdgi6qnf1sfz722qn38q7kgakcvj7b45ba3i0020828r0";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xorgserver xproto ;};
 
   xf86videotrident = (mkDerivation "xf86videotrident" {
-    name = "xf86-video-trident-1.3.7";
+    name = "xf86-video-trident-1.3.8";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-trident-1.3.7.tar.bz2;
-      sha256 = "1bhkwic2acq9za4yz4bwj338cwv5mdrgr2qmgkhlj3bscbg1imgc";
+      url = mirror://xorg/individual/driver/xf86-video-trident-1.3.8.tar.bz2;
+      sha256 = "0gxcar434kx813fxdpb93126lhmkl3ikabaljhcj5qn3fkcijlcy";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto videoproto xextproto xf86dgaproto xorgserver xproto ;};
 
   xf86videov4l = (mkDerivation "xf86videov4l" {
@@ -1814,28 +2258,34 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86-video-v4l-0.2.0.tar.bz2;
       sha256 = "0pcjc75hgbih3qvhpsx8d4fljysfk025slxcqyyhr45dzch93zyb";
     };
-    buildInputs = [pkgconfig randrproto videoproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ randrproto videoproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit randrproto videoproto xorgserver xproto ;};
 
   xf86videovesa = (mkDerivation "xf86videovesa" {
-    name = "xf86-video-vesa-2.3.4";
+    name = "xf86-video-vesa-2.4.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-vesa-2.3.4.tar.bz2;
-      sha256 = "1haiw8r1z8ihk68d0jqph2wsld13w4qkl86biq46fvyxg7cg9pbv";
+      url = mirror://xorg/individual/driver/xf86-video-vesa-2.4.0.tar.bz2;
+      sha256 = "1373vsxn6qh00na0s9c09kf09gj78rzi98zq93id8v5zsya3qi5z";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto xextproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto xextproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto xextproto xorgserver xproto ;};
 
   xf86videovmware = (mkDerivation "xf86videovmware" {
-    name = "xf86-video-vmware-13.1.0";
+    name = "xf86-video-vmware-13.2.1";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/driver/xf86-video-vmware-13.1.0.tar.bz2;
-      sha256 = "1k50whwnkzxam2ihc1sw456dx0pvr76naycm4qhyjxqv9d72879w";
+      url = mirror://xorg/individual/driver/xf86-video-vmware-13.2.1.tar.bz2;
+      sha256 = "0azn3g0vcki47n5jddagk2rmbwdvp845k8p7d2r56zxs3w8ggxz2";
     };
-    buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xineramaproto xorgserver xproto ];
-  }) // {inherit fontsproto libdrm libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xineramaproto xorgserver xproto ;};
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libdrm udev libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xineramaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto libdrm udev libpciaccess randrproto renderproto videoproto libX11 libXext xextproto xineramaproto xorgserver xproto ;};
 
   xf86videovoodoo = (mkDerivation "xf86videovoodoo" {
     name = "xf86-video-voodoo-1.2.5";
@@ -1844,7 +2294,9 @@ let
       url = mirror://xorg/individual/driver/xf86-video-voodoo-1.2.5.tar.bz2;
       sha256 = "1s6p7yxmi12q4y05va53rljwyzd6ry492r1pgi7wwq6cznivhgly";
     };
-    buildInputs = [pkgconfig fontsproto libpciaccess randrproto renderproto xextproto xf86dgaproto xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto libpciaccess randrproto renderproto xextproto xf86dgaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit fontsproto libpciaccess randrproto renderproto xextproto xf86dgaproto xorgserver xproto ;};
 
   xf86videowsfb = (mkDerivation "xf86videowsfb" {
@@ -1854,9 +2306,23 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86-video-wsfb-0.4.0.tar.bz2;
       sha256 = "0hr8397wpd0by1hc47fqqrnaw3qdqd8aqgwgzv38w5k3l3jy6p4p";
     };
-    buildInputs = [pkgconfig xorgserver xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit xorgserver xproto ;};
 
+  xf86videoxgi = (mkDerivation "xf86videoxgi" {
+    name = "xf86-video-xgi-1.6.1";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = mirror://xorg/individual/driver/xf86-video-xgi-1.6.1.tar.bz2;
+      sha256 = "10xd2vah0pnpw5spn40n4p95mpmgvdkly4i1cz51imnlfsw7g8si";
+    };
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ fontsproto glproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xineramaproto xorgserver xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit fontsproto glproto libdrm libpciaccess randrproto renderproto videoproto xextproto xf86driproto xineramaproto xorgserver xproto ;};
+
   xf86vidmodeproto = (mkDerivation "xf86vidmodeproto" {
     name = "xf86vidmodeproto-2.3.1";
     builder = ./builder.sh;
@@ -1864,7 +2330,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xf86vidmodeproto-2.3.1.tar.bz2;
       sha256 = "0w47d7gfa8zizh2bshdr2rffvbr4jqjv019mdgyh6cmplyd4kna5";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xfs = (mkDerivation "xfs" {
@@ -1874,7 +2342,9 @@ let
       url = mirror://xorg/individual/app/xfs-1.1.4.tar.bz2;
       sha256 = "1ylz4r7adf567rnlbb52yi9x3qi4pyv954kkhm7ld4f0fkk7a2x4";
     };
-    buildInputs = [pkgconfig libXfont xproto xtrans ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libXfont xproto xtrans ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libXfont xproto xtrans ;};
 
   xgamma = (mkDerivation "xgamma" {
@@ -1884,7 +2354,9 @@ let
       url = mirror://xorg/individual/app/xgamma-1.0.6.tar.bz2;
       sha256 = "1lr2nb1fhg5fk2fchqxdxyl739602ggwhmgl2wiv5c8qbidw7w8f";
     };
-    buildInputs = [pkgconfig libX11 xproto libXxf86vm ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto libXxf86vm ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto libXxf86vm ;};
 
   xgc = (mkDerivation "xgc" {
@@ -1894,7 +2366,9 @@ let
       url = mirror://xorg/individual/app/xgc-1.0.5.tar.bz2;
       sha256 = "0pigvjd3i9fchmj1inqy151aafz3dr0vq1h2zizdb2imvadqv0hl";
     };
-    buildInputs = [pkgconfig libXaw libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libXaw libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libXaw libXt ;};
 
   xhost = (mkDerivation "xhost" {
@@ -1904,7 +2378,9 @@ let
       url = mirror://xorg/individual/app/xhost-1.0.7.tar.bz2;
       sha256 = "16n26xw6l01zq31d4qvsaz50misvizhn7iihzdn5f7s72pp1krlk";
     };
-    buildInputs = [pkgconfig libX11 libXau libXmu xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXau libXmu xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXau libXmu xproto ;};
 
   xineramaproto = (mkDerivation "xineramaproto" {
@@ -1914,37 +2390,45 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xineramaproto-1.2.1.tar.bz2;
       sha256 = "0ns8abd27x7gbp4r44z3wc5k9zqxxj8zjnazqpcyr4n17nxp8xcp";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xinit = (mkDerivation "xinit" {
-    name = "xinit-1.3.4";
+    name = "xinit-1.4.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/xinit-1.3.4.tar.bz2;
-      sha256 = "1cq2g469mb2cfgr8k57960yrn90bl33vfqri4pdh2zm0jxrqvn3m";
+      url = mirror://xorg/individual/app/xinit-1.4.0.tar.bz2;
+      sha256 = "1vw2wlg74ig52naw0cha3pgzcwwk25l834j42cg8m5zmybp3a213";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xinput = (mkDerivation "xinput" {
-    name = "xinput-1.6.1";
+    name = "xinput-1.6.2";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/xinput-1.6.1.tar.bz2;
-      sha256 = "07w7zlpdhpwzzshg8q0y152cy3wl2fj7x1897glnp2la487jsqxp";
+      url = mirror://xorg/individual/app/xinput-1.6.2.tar.bz2;
+      sha256 = "1i75mviz9dyqyf7qigzmxq8vn31i86aybm662fzjz5c086dx551n";
     };
-    buildInputs = [pkgconfig inputproto libX11 libXext libXi libXinerama libXrandr ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto libX11 libXext libXi libXinerama libXrandr ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto libX11 libXext libXi libXinerama libXrandr ;};
 
   xkbcomp = (mkDerivation "xkbcomp" {
-    name = "xkbcomp-1.3.0";
+    name = "xkbcomp-1.4.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/xkbcomp-1.3.0.tar.bz2;
-      sha256 = "0aibcbhhjlwcrxh943xg2dswwx5bz1x0pmhs28b55gzsg0vrgb6g";
+      url = mirror://xorg/individual/app/xkbcomp-1.4.0.tar.bz2;
+      sha256 = "0syfc6zscvai824mzihlnrqxhkcr27dzkpy8zndavi83iischsdw";
     };
-    buildInputs = [pkgconfig libX11 libxkbfile xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libxkbfile xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libxkbfile xproto ;};
 
   xkbevd = (mkDerivation "xkbevd" {
@@ -1954,7 +2438,9 @@ let
       url = mirror://xorg/individual/app/xkbevd-1.1.4.tar.bz2;
       sha256 = "0sprjx8i86ljk0l7ldzbz2xlk8916z5zh78cafjv8k1a63js4c14";
     };
-    buildInputs = [pkgconfig libX11 libxkbfile ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libxkbfile ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libxkbfile ;};
 
   xkbprint = (mkDerivation "xkbprint" {
@@ -1964,7 +2450,9 @@ let
       url = mirror://xorg/individual/app/xkbprint-1.0.4.tar.bz2;
       sha256 = "04iyv5z8aqhabv7wcpvbvq0ji0jrz1666vw6gvxkvl7szswalgqb";
     };
-    buildInputs = [pkgconfig libX11 libxkbfile xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libxkbfile xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libxkbfile xproto ;};
 
   xkbutils = (mkDerivation "xkbutils" {
@@ -1974,17 +2462,21 @@ let
       url = mirror://xorg/individual/app/xkbutils-1.0.4.tar.bz2;
       sha256 = "0c412isxl65wplhl7nsk12vxlri29lk48g3p52hbrs3m0awqm8fj";
     };
-    buildInputs = [pkgconfig inputproto libX11 libXaw xproto libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ inputproto libX11 libXaw xproto libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit inputproto libX11 libXaw xproto libXt ;};
 
   xkeyboardconfig = (mkDerivation "xkeyboardconfig" {
-    name = "xkeyboard-config-2.15";
+    name = "xkeyboard-config-2.23.1";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/data/xkeyboard-config/xkeyboard-config-2.15.tar.bz2;
-      sha256 = "1grqdy5a9f2dii3y24fn0p3kz4q5g9j2kh3jcj2402rgrbvkqi0f";
+      url = mirror://xorg/individual/data/xkeyboard-config/xkeyboard-config-2.23.1.tar.bz2;
+      sha256 = "1wq27cs1c9y7d1d7zp5yhq29paj9smajdb68lyvm28d2zq2vqjra";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xkill = (mkDerivation "xkill" {
@@ -1994,7 +2486,9 @@ let
       url = mirror://xorg/individual/app/xkill-1.0.4.tar.bz2;
       sha256 = "0bl1ky8ps9jg842j4mnmf4zbx8nkvk0h77w7bqjlpwij9wq2mvw8";
     };
-    buildInputs = [pkgconfig libX11 libXmu xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXmu xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXmu xproto ;};
 
   xlsatoms = (mkDerivation "xlsatoms" {
@@ -2004,7 +2498,9 @@ let
       url = mirror://xorg/individual/app/xlsatoms-1.1.2.tar.bz2;
       sha256 = "196yjik910xsr7dwy8daa0amr0r22ynfs360z0ndp9mx7mydrra7";
     };
-    buildInputs = [pkgconfig libxcb ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libxcb ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libxcb ;};
 
   xlsclients = (mkDerivation "xlsclients" {
@@ -2014,7 +2510,9 @@ let
       url = mirror://xorg/individual/app/xlsclients-1.1.3.tar.bz2;
       sha256 = "0g9x7rrggs741x9xwvv1k9qayma980d88nhdqw7j3pn3qvy6d5jx";
     };
-    buildInputs = [pkgconfig libxcb ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libxcb ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libxcb ;};
 
   xlsfonts = (mkDerivation "xlsfonts" {
@@ -2024,7 +2522,9 @@ let
       url = mirror://xorg/individual/app/xlsfonts-1.0.5.tar.bz2;
       sha256 = "1yi774g6r1kafsbnxbkrwyndd3i60362ck1fps9ywz076pn5naa0";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xmag = (mkDerivation "xmag" {
@@ -2034,7 +2534,9 @@ let
       url = mirror://xorg/individual/app/xmag-1.0.6.tar.bz2;
       sha256 = "0qg12ifbbk9n8fh4jmyb625cknn8ssj86chd6zwdiqjin8ivr8l7";
     };
-    buildInputs = [pkgconfig libX11 libXaw libXmu libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXaw libXmu libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXaw libXmu libXt ;};
 
   xmessage = (mkDerivation "xmessage" {
@@ -2044,7 +2546,9 @@ let
       url = mirror://xorg/individual/app/xmessage-1.0.4.tar.bz2;
       sha256 = "0s5bjlpxnmh8sxx6nfg9m0nr32r1sr3irr71wsnv76s33i34ppxw";
     };
-    buildInputs = [pkgconfig libXaw libXt ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libXaw libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libXaw libXt ;};
 
   xmodmap = (mkDerivation "xmodmap" {
@@ -2054,17 +2558,21 @@ let
       url = mirror://xorg/individual/app/xmodmap-1.0.9.tar.bz2;
       sha256 = "0y649an3jqfq9klkp9y5gj20xb78fw6g193f5mnzpl0hbz6fbc5p";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xorgcffiles = (mkDerivation "xorgcffiles" {
-    name = "xorg-cf-files-1.0.5";
+    name = "xorg-cf-files-1.0.6";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/util/xorg-cf-files-1.0.5.tar.bz2;
-      sha256 = "1m3ypq0xcy46ghxc0svl1rbhpy3zvgmy0aa2mn7w7v7d8d8bh8zd";
+      url = mirror://xorg/individual/util/xorg-cf-files-1.0.6.tar.bz2;
+      sha256 = "0kckng0zs1viz0nr84rdl6dswgip7ndn4pnh5nfwnviwpsfmmksd";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xorgdocs = (mkDerivation "xorgdocs" {
@@ -2074,18 +2582,22 @@ let
       url = mirror://xorg/individual/doc/xorg-docs-1.7.1.tar.bz2;
       sha256 = "0jrc4jmb4raqawx0j9jmhgasr0k6sxv0bm2hrxjh9hb26iy6gf14";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xorgserver = (mkDerivation "xorgserver" {
-    name = "xorg-server-1.17.2";
+    name = "xorg-server-1.19.6";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/xserver/xorg-server-1.17.2.tar.bz2;
-      sha256 = "14vr4mm0x94a9bd3sfx9mdh8qhvk48zcml3i8q1wbwi84xhj04gn";
+      url = mirror://xorg/individual/xserver/xorg-server-1.19.6.tar.bz2;
+      sha256 = "15y13ihgkggmly5s07vzvpn35gzx1w0hrkbnlcvcy05h3lpm0cm7";
     };
-    buildInputs = [pkgconfig dri2proto dri3proto renderproto libdrm openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libxshmfence libXt xcbutilrenderutil];
-  }) // {inherit dri2proto dri3proto renderproto libdrm openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libxshmfence libXt xcbutilrenderutil;};
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ dri2proto dri3proto renderproto openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms xcbutilrenderutil libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt ];
+    meta.platforms = stdenv.lib.platforms.unix;
+  }) // {inherit dri2proto dri3proto renderproto openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms xcbutilrenderutil libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt ;};
 
   xorgsgmldoctools = (mkDerivation "xorgsgmldoctools" {
     name = "xorg-sgml-doctools-1.11";
@@ -2094,7 +2606,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xorg-sgml-doctools-1.11.tar.bz2;
       sha256 = "0k5pffyi5bx8dmfn033cyhgd3gf6viqj3x769fqixifwhbgy2777";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xpr = (mkDerivation "xpr" {
@@ -2104,7 +2618,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xpr-1.0.4.tar.bz2;
       sha256 = "1dbcv26w2yand2qy7b3h5rbvw1mdmdd57jw88v53sgdr3vrqvngy";
     };
-    buildInputs = [pkgconfig libX11 libXmu xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXmu xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXmu xproto ;};
 
   xprop = (mkDerivation "xprop" {
@@ -2114,27 +2630,33 @@ let
       url = mirror://xorg/individual/app/xprop-1.2.2.tar.bz2;
       sha256 = "1ilvhqfjcg6f1hqahjkp8qaay9rhvmv2blvj3w9asraq0aqqivlv";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xproto = (mkDerivation "xproto" {
-    name = "xproto-7.0.28";
+    name = "xproto-7.0.31";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/proto/xproto-7.0.28.tar.bz2;
-      sha256 = "1jpnvm33vi2dar5y5zgz7jjh0m8fpkcxm0f0lbwfx37ns5l5bs19";
+      url = mirror://xorg/individual/proto/xproto-7.0.31.tar.bz2;
+      sha256 = "0ivpxz0rx2a7nahkpkhfgymz7j0pwzaqvyqpdgw9afmxl1yp9yf6";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xrandr = (mkDerivation "xrandr" {
-    name = "xrandr-1.4.3";
+    name = "xrandr-1.5.0";
     builder = ./builder.sh;
     src = fetchurl {
-      url = mirror://xorg/individual/app/xrandr-1.4.3.tar.bz2;
-      sha256 = "06xy0kr6ih7ilrwl6b5g6ay75vm2j4lxnv1d5xlj6sdqhqsaqm3i";
+      url = mirror://xorg/individual/app/xrandr-1.5.0.tar.bz2;
+      sha256 = "1kaih7rmzxr1vp5a5zzjhm5x7dn9mckya088sqqw026pskhx9ky1";
     };
-    buildInputs = [pkgconfig libX11 xproto libXrandr libXrender ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto libXrandr libXrender ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto libXrandr libXrender ;};
 
   xrdb = (mkDerivation "xrdb" {
@@ -2144,7 +2666,9 @@ let
       url = mirror://xorg/individual/app/xrdb-1.1.0.tar.bz2;
       sha256 = "0nsnr90wazcdd50nc5dqswy0bmq6qcj14nnrhyi7rln9pxmpp0kk";
     };
-    buildInputs = [pkgconfig libX11 libXmu xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXmu xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXmu xproto ;};
 
   xrefresh = (mkDerivation "xrefresh" {
@@ -2154,7 +2678,9 @@ let
       url = mirror://xorg/individual/app/xrefresh-1.0.5.tar.bz2;
       sha256 = "1mlinwgvql6s1rbf46yckbfr9j22d3c3z7jx3n6ix7ca18dnf4rj";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xset = (mkDerivation "xset" {
@@ -2164,7 +2690,9 @@ let
       url = mirror://xorg/individual/app/xset-1.2.3.tar.bz2;
       sha256 = "0qw0iic27bz3yz2wynf1gxs70hhkcf9c4jrv7zhlg1mq57xz90j3";
     };
-    buildInputs = [pkgconfig libX11 libXext libXmu xproto libXxf86misc ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libXext libXmu xproto libXxf86misc ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libXext libXmu xproto libXxf86misc ;};
 
   xsetroot = (mkDerivation "xsetroot" {
@@ -2174,7 +2702,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xsetroot-1.1.0.tar.bz2;
       sha256 = "1bazzsf9sy0q2bj4lxvh1kvyrhmpggzb7jg575i15sksksa3xwc8";
     };
-    buildInputs = [pkgconfig libX11 xbitmaps libXcursor libXmu ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xbitmaps libXcursor libXmu ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xbitmaps libXcursor libXmu ;};
 
   xtrans = (mkDerivation "xtrans" {
@@ -2184,7 +2714,9 @@ let
       url = mirror://xorg/individual/lib/xtrans-1.3.5.tar.bz2;
       sha256 = "00c3ph17acnsch3gbdmx33b9ifjnl5w7vx8hrmic1r1cjcv3pgdd";
     };
-    buildInputs = [pkgconfig ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit ;};
 
   xvinfo = (mkDerivation "xvinfo" {
@@ -2194,7 +2726,9 @@ let
       url = mirror://xorg/individual/app/xvinfo-1.1.3.tar.bz2;
       sha256 = "1sz5wqhxd1fqsfi1w5advdlwzkizf2fgl12hdpk66f7mv9l8pflz";
     };
-    buildInputs = [pkgconfig libX11 xproto libXv ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto libXv ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto libXv ;};
 
   xwd = (mkDerivation "xwd" {
@@ -2204,7 +2738,9 @@ let
       url = mirror://xorg/individual/app/xwd-1.0.6.tar.bz2;
       sha256 = "0ybx48agdvjp9lgwvcw79r1x6jbqbyl3fliy3i5xwy4d4si9dcrv";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
   xwininfo = (mkDerivation "xwininfo" {
@@ -2214,7 +2750,9 @@ let
       url = mirror://xorg/individual/app/xwininfo-1.1.3.tar.bz2;
       sha256 = "1y1zn8ijqslb5lfpbq4bb78kllhch8in98ps7n8fg3dxjpmb13i1";
     };
-    buildInputs = [pkgconfig libX11 libxcb xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 libxcb xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 libxcb xproto ;};
 
   xwud = (mkDerivation "xwud" {
@@ -2224,7 +2762,9 @@ let
       url = mirror://xorg/X11R7.7/src/everything/xwud-1.0.4.tar.bz2;
       sha256 = "1ggql6maivah58kwsh3z9x1hvzxm1a8888xx4s78cl77ryfa1cyn";
     };
-    buildInputs = [pkgconfig libX11 xproto ];
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ libX11 xproto ];
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit libX11 xproto ;};
 
 }; in xorg
diff --git a/pkgs/servers/x11/xorg/extra.list b/pkgs/servers/x11/xorg/extra.list
index 80b5e14d8c3b..28b698bdc816 100644
--- a/pkgs/servers/x11/xorg/extra.list
+++ b/pkgs/servers/x11/xorg/extra.list
@@ -1,10 +1,11 @@
-http://xcb.freedesktop.org/dist/libpthread-stubs-0.3.tar.bz2
-http://xcb.freedesktop.org/dist/libxcb-1.11.1.tar.bz2
-http://xcb.freedesktop.org/dist/xcb-proto-1.11.tar.bz2
+http://xcb.freedesktop.org/dist/libpthread-stubs-0.4.tar.bz2
+http://xcb.freedesktop.org/dist/libxcb-1.12.tar.bz2
+http://xcb.freedesktop.org/dist/xcb-proto-1.12.tar.bz2
 http://xcb.freedesktop.org/dist/xcb-util-0.4.0.tar.bz2
-http://xcb.freedesktop.org/dist/xcb-util-cursor-0.1.2.tar.bz2
+http://xcb.freedesktop.org/dist/xcb-util-cursor-0.1.3.tar.bz2
 http://xcb.freedesktop.org/dist/xcb-util-image-0.4.0.tar.bz2
 http://xcb.freedesktop.org/dist/xcb-util-keysyms-0.4.0.tar.bz2
 http://xcb.freedesktop.org/dist/xcb-util-renderutil-0.3.9.tar.bz2
 http://xcb.freedesktop.org/dist/xcb-util-wm-0.4.1.tar.bz2
 http://xcb.freedesktop.org/dist/xcb-util-errors-1.0.tar.bz2
+mirror://xorg/individual/app/appres-1.0.4.tar.bz2
diff --git a/pkgs/servers/x11/xorg/fix_segfault.patch b/pkgs/servers/x11/xorg/fix_segfault.patch
deleted file mode 100644
index b3a7d2ed5e00..000000000000
--- a/pkgs/servers/x11/xorg/fix_segfault.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-From 7cc7ffd25d5e50b54cb942d07d4cb160f20ff9c5 Mon Sep 17 00:00:00 2001
-From: Martin Peres <martin.peres@linux.intel.com>
-Date: Fri, 17 Jul 2015 17:21:26 +0300
-Subject: [PATCH] os: make sure the clientsWritable fd_set is initialized
- before use
-
-In WaitForSomething(), the fd_set clientsWritable may be used unitialized when
-the boolean AnyClientsWriteBlocked is set in the WakeupHandler(). This leads to
-a crash in FlushAllOutput() after x11proto's commit
-2c94cdb453bc641246cc8b9a876da9799bee1ce7.
-
-The problem did not manifest before because both the XFD_SIZE and the maximum
-number of clients were set to 256. As the connectionTranslation table was
-initalized for the 256 clients to 0, the test on the index not being 0 was
-aborting before dereferencing the client #0.
-
-As of commit 2c94cdb453bc641246cc8b9a876da9799bee1ce7 in x11proto, the XFD_SIZE
-got bumped to 512. This lead the OutputPending fd_set to have any fd above 256
-to be uninitialized which in turns lead to reading an index after the end of
-the ConnectionTranslation table. This index would then be used to find the
-client corresponding to the fd marked as pending writes and would also result
-to an out-of-bound access which would usually be the fatal one.
-
-Fix this by zeroing the clientsWritable fd_set at the beginning of
-WaitForSomething(). In this case, the bottom part of the loop, which would
-indirectly call FlushAllOutput, will not do any work but the next call to
-select will result in the execution of the right codepath. This is exactly what
-we want because we need to know the writable clients before handling them. In
-the end, it also makes sure that the fds above MaxClient are initialized,
-preventing the crash in FlushAllOutput().
-
-Thanks to everyone involved in tracking this one down!
-
-Reported-by: Karol Herbst <freedesktop@karolherbst.de>
-Reported-by: Tobias Klausmann <tobias.klausmann@mni.thm.de>
-Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
-Tested-by: Martin Peres <martin.peres@linux.intel.com>
-Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91316
-Cc: Ilia Mirkin  <imirkin@alum.mit.edu>
-Cc: Martin Peres <martin.peres@linux.intel.com>
-Cc: Olivier Fourdan <ofourdan@redhat.com
-Cc: Adam Jackson <ajax@redhat.com>
-Cc: Alan Coopersmith <alan.coopersmith@oracle.com
-Cc: Chris Wilson <chris@chris-wilson.co.uk>
----
- os/WaitFor.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/os/WaitFor.c b/os/WaitFor.c
-index 431f1a6..993c14e 100644
---- a/os/WaitFor.c
-+++ b/os/WaitFor.c
-@@ -158,6 +158,7 @@ WaitForSomething(int *pClientsReady)
-     Bool someReady = FALSE;
- 
-     FD_ZERO(&clientsReadable);
-+    FD_ZERO(&clientsWritable);
- 
-     if (nready)
-         SmartScheduleStopTimer();
--- 
-2.4.5
-
diff --git a/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl b/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl
index 1e0ce6d6167e..dfde730fbea8 100755
--- a/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl
+++ b/pkgs/servers/x11/xorg/generate-expr-from-tarballs.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/env perl
 
 # Typical command to generate the list of tarballs:
 
@@ -11,6 +11,7 @@
 
 
 use strict;
+use warnings;
 
 my $tmpDir = "/tmp/xorg-unpack";
 
@@ -25,7 +26,7 @@ my %pcMap;
 my %extraAttrs;
 
 
-my @missingPCs = ("fontconfig", "libdrm", "libXaw", "zlib", "perl", "python", "mesa", "mkfontscale", "mkfontdir", "bdftopcf", "libxslt", "openssl", "gperf", "m4");
+my @missingPCs = ("fontconfig", "libdrm", "libXaw", "zlib", "perl", "python", "mkfontscale", "mkfontdir", "bdftopcf", "libxslt", "openssl", "gperf", "m4");
 $pcMap{$_} = $_ foreach @missingPCs;
 $pcMap{"freetype2"} = "freetype";
 $pcMap{"libpng12"} = "libpng";
@@ -33,7 +34,8 @@ $pcMap{"libpng"} = "libpng";
 $pcMap{"dbus-1"} = "dbus";
 $pcMap{"uuid"} = "libuuid";
 $pcMap{"libudev"} = "udev";
-$pcMap{"gl"} = "mesa";
+$pcMap{"gl"} = "libGL";
+$pcMap{"gbm"} = "mesa_noglu";
 $pcMap{"\$PIXMAN"} = "pixman";
 $pcMap{"\$RENDERPROTO"} = "renderproto";
 $pcMap{"\$DRI3PROTO"} = "dri3proto";
@@ -61,7 +63,7 @@ while (<>) {
       #next unless $pkg eq "xcbutil";
     }
 
-    $tarball =~ /\/([^\/]*)\.tar\.bz2$/;
+    $tarball =~ /\/([^\/]*)\.tar\.(bz2|gz|xz)$/;
     my $pkgName = $1;
 
     print "  $pkg $pkgName\n";
@@ -82,7 +84,7 @@ while (<>) {
     print "\nunpacking $path\n";
     system "rm -rf '$tmpDir'";
     mkdir $tmpDir, 0700;
-    system "cd '$tmpDir' && tar xfj '$path'";
+    system "cd '$tmpDir' && tar xf '$path'";
     die "cannot unpack `$path'" if $? != 0;
     print "\n";
 
@@ -230,7 +232,7 @@ print OUT "";
 print OUT <<EOF;
 # THIS IS A GENERATED FILE.  DO NOT EDIT!
 args @ { clangStdenv, fetchurl, fetchgit, fetchpatch, stdenv, pkgconfig, intltool, freetype, fontconfig
-, libxslt, expat, libpng, zlib, perl, mesa_drivers, spice_protocol
+, libxslt, expat, libpng, zlib, perl, mesa_noglu, mesa_drivers, spice-protocol
 , dbus, libuuid, openssl, gperf, m4, libevdev, tradcpp, libinput, mcpp, makeWrapper, autoreconfHook
 , autoconf, automake, libtool, xmlto, asciidoc, flex, bison, python, mtdev, pixman, ... }: with args;
 
@@ -239,7 +241,9 @@ let
   mkDerivation = name: attrs:
     let newAttrs = (overrides."\${name}" or (x: x)) attrs;
         stdenv = newAttrs.stdenv or args.stdenv;
-    in stdenv.mkDerivation (removeAttrs newAttrs [ "stdenv" ]);
+      in stdenv.mkDerivation ((removeAttrs newAttrs [ "stdenv" ]) // {
+        hardeningDisable = [ "bindnow" "relro" ];
+      });
 
   overrides = import ./overrides.nix {inherit args xorg;};
 
@@ -279,7 +283,9 @@ foreach my $pkg (sort (keys %pkgURLs)) {
       url = $pkgURLs{$pkg};
       sha256 = "$pkgHashes{$pkg}";
     };
-    buildInputs = [pkgconfig $inputs];$extraAttrs
+    nativeBuildInputs = [ pkgconfig ];
+    buildInputs = [ $inputs];$extraAttrs
+    meta.platforms = stdenv.lib.platforms.unix;
   }) // {inherit $inputs;};
 
 EOF
diff --git a/pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch b/pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch
new file mode 100644
index 000000000000..fe079eeb42a7
--- /dev/null
+++ b/pkgs/servers/x11/xorg/imake-cc-wrapper-uberhack.patch
@@ -0,0 +1,13 @@
+diff --git a/imake.c b/imake.c
+index c20cd4a..ec2589b 100644
+--- a/imake.c
++++ b/imake.c
+@@ -959,7 +959,7 @@ get_libc_version(FILE *inFile)
+ {
+   char aout[4096], *tmpdir;
+   FILE *fp;
+-  const char *format = "%s -o %s -x c -";
++  const char *format = "f=$(mktemp imakeXXXXXX.c); cat > $f; %s $f -o %s";
+   char *cc;
+   int len;
+   char *command;
diff --git a/pkgs/servers/x11/xorg/old.list b/pkgs/servers/x11/xorg/old.list
index 92fed797d70f..fd6eae916392 100644
--- a/pkgs/servers/x11/xorg/old.list
+++ b/pkgs/servers/x11/xorg/old.list
@@ -3,7 +3,7 @@ mirror://xorg/individual/app/xclock-1.0.7.tar.bz2
 mirror://xorg/individual/app/xdm-1.1.11.tar.bz2
 mirror://xorg/individual/app/xeyes-1.1.1.tar.bz2
 mirror://xorg/individual/app/xfs-1.1.4.tar.bz2
-mirror://xorg/individual/app/xinit-1.3.4.tar.bz2
+mirror://xorg/individual/app/xinit-1.4.0.tar.bz2
 mirror://xorg/individual/app/xmessage-1.0.4.tar.bz2
 mirror://xorg/individual/lib/libXp-1.0.3.tar.bz2
 mirror://xorg/individual/lib/libXxf86misc-1.0.3.tar.bz2
@@ -12,4 +12,4 @@ mirror://xorg/individual/proto/xf86miscproto-0.9.3.tar.bz2
 mirror://xorg/individual/util/gccmakedep-1.0.3.tar.bz2
 mirror://xorg/individual/util/imake-1.0.7.tar.bz2
 mirror://xorg/individual/util/lndir-1.0.3.tar.bz2
-mirror://xorg/individual/util/xorg-cf-files-1.0.5.tar.bz2
+mirror://xorg/individual/util/xorg-cf-files-1.0.6.tar.bz2
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index a7e5b43689a0..f45ee7500ed0 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -5,11 +5,9 @@ let
   inherit (stdenv) lib isDarwin;
   inherit (lib) overrideDerivation;
 
-  setMalloc0ReturnsNullCrossCompiling = ''
-    if test -n "$crossConfig"; then
-      configureFlags="$configureFlags --enable-malloc0returnsnull";
-    fi
-  '';
+  malloc0ReturnsNullCrossFlag = stdenv.lib.optional
+    (stdenv.hostPlatform != stdenv.buildPlatform)
+    "--enable-malloc0returnsnull";
 
   gitRelease = { libName, version, rev, sha256 } : attrs : attrs // {
     name = libName + "-" + version;
@@ -24,10 +22,33 @@ let
   compose = f: g: x: f (g x);
 in
 {
+  bdftopcf = attrs: attrs // {
+    buildInputs = attrs.buildInputs ++ [ xorg.xproto xorg.fontsproto ];
+  };
+
+  bitmap = attrs: attrs // {
+    nativeBuildInputs = attrs.nativeBuildInputs ++ [ makeWrapper ];
+    postInstall = ''
+      paths=(
+        "$out/share/X11/%T/%N"
+        "$out/include/X11/%T/%N"
+        "${xorg.xbitmaps}/include/X11/%T/%N"
+      )
+      wrapProgram "$out/bin/bitmap" \
+        --suffix XFILESEARCHPATH : $(IFS=:; echo "''${paths[*]}")
+      makeWrapper "$out/bin/bitmap" "$out/bin/bitmap-color" \
+        --suffix XFILESEARCHPATH : "$out/share/X11/%T/%N-color"
+    '';
+  };
+
   encodings = attrs: attrs // {
     buildInputs = attrs.buildInputs ++ [ xorg.mkfontscale ];
   };
 
+  fontbhttf = attrs: attrs // {
+    meta = attrs.meta // { license = lib.licenses.unfreeRedistributable; };
+  };
+
   fontcursormisc = attrs: attrs // {
     buildInputs = attrs.buildInputs ++ [ xorg.mkfontscale ];
   };
@@ -37,18 +58,14 @@ in
       ''
         ALIASFILE=${xorg.fontalias}/share/fonts/X11/misc/fonts.alias
         test -f $ALIASFILE
-        ln -s $ALIASFILE $out/lib/X11/fonts/misc/fonts.alias
+        cp $ALIASFILE $out/lib/X11/fonts/misc/fonts.alias
       '';
   };
 
-  glamoregl = attrs: attrs // {
-    installFlags = "sdkdir=\${out}/include/xorg configdir=\${out}/share/X11/xorg.conf.d";
-  };
-
   imake = attrs: attrs // {
     inherit (xorg) xorgcffiles;
     x11BuildHook = ./imake.sh;
-    patches = [./imake.patch];
+    patches = [./imake.patch ./imake-cc-wrapper-uberhack.patch];
     setupHook = if stdenv.isDarwin then ./darwin-imake-setup-hook.sh else null;
     CFLAGS = [ "-DIMAKE_COMPILETIME_CPP=\\\"${if stdenv.isDarwin
       then "${args.tradcpp}/bin/cpp"
@@ -71,17 +88,20 @@ in
   };
 
   libxcb = attrs : attrs // {
-    nativeBuildInputs = [ args.python ];
+    nativeBuildInputs = attrs.nativeBuildInputs ++ [ args.python ];
     configureFlags = "--enable-xkb --enable-xinput";
-    outputs = [ "out" "doc" "man" ];
+    outputs = [ "out" "dev" "man" "doc" ];
   };
 
   xcbproto = attrs : attrs // {
-    nativeBuildInputs = [ args.python ];
+    nativeBuildInputs = attrs.nativeBuildInputs ++ [ args.python ];
   };
 
   libX11 = attrs: attrs // {
-    preConfigure = setMalloc0ReturnsNullCrossCompiling + ''
+    outputs = [ "out" "dev" "man" ];
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
+    preConfigure = ''
       sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure
     '';
     postInstall =
@@ -90,14 +110,25 @@ in
         rm -rf $out/share/doc
       '';
     CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -";
-    outputs = [ "out" "man" ];
   };
 
   libAppleWM = attrs: attrs // {
-    propagatedBuildInputs = [ args.apple_sdk.frameworks.ApplicationServices ];
+    buildInputs = attrs.buildInputs ++ [ args.apple_sdk.frameworks.ApplicationServices ];
+    preConfigure = ''
+      substituteInPlace src/Makefile.in --replace -F/System -F${args.apple_sdk.frameworks.ApplicationServices}
+    '';
+  };
+
+  libXau = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
+
+  libXdmcp = attrs: attrs // {
+    outputs = [ "out" "dev" "doc" ];
   };
 
   libXfont = attrs: attrs // {
+    outputs = [ "out" "dev" ];
     propagatedBuildInputs = [ args.freetype ]; # propagate link reqs. like bzip2
     # prevents "misaligned_stack_error_entering_dyld_stub_binder"
     configureFlags = lib.optionals isDarwin [
@@ -106,24 +137,23 @@ in
   };
 
   libXxf86vm = attrs: attrs // {
-    preConfigure = setMalloc0ReturnsNullCrossCompiling;
-  };
-
-  libXrandr = attrs: attrs // {
-    preConfigure = setMalloc0ReturnsNullCrossCompiling;
-    propagatedBuildInputs = [xorg.libXrender];
+    outputs = [ "out" "dev" ];
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
   };
 
   # Propagate some build inputs because of header file dependencies.
   # Note: most of these are in Requires.private, so maybe builder.sh
   # should propagate them automatically.
   libXt = attrs: attrs // {
-    preConfigure = setMalloc0ReturnsNullCrossCompiling + ''
+    preConfigure = ''
       sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure
     '';
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
     propagatedBuildInputs = [ xorg.libSM ];
     CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -";
-    outputs = [ "out" "doc" "man" ];
+    outputs = [ "out" "dev" "devdoc" ];
   };
 
   # See https://bugs.freedesktop.org/show_bug.cgi?id=47792
@@ -136,44 +166,130 @@ in
     propagatedBuildInputs = [ xorg.fixesproto ];
   };
 
+  libICE = attrs: attrs // {
+    outputs = [ "out" "dev" "doc" ];
+  };
+
   libXcomposite = attrs: attrs // {
+    outputs = [ "out" "dev" ];
     propagatedBuildInputs = [ xorg.libXfixes ];
   };
 
   libXaw = attrs: attrs // {
+    outputs = [ "out" "dev" "devdoc" ];
     propagatedBuildInputs = [ xorg.libXmu ];
   };
 
+  libXcursor = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
+
+  libXdamage = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
+
   libXft = attrs: attrs // {
+    outputs = [ "out" "dev" ];
     propagatedBuildInputs = [ xorg.libXrender args.freetype args.fontconfig ];
-    preConfigure = setMalloc0ReturnsNullCrossCompiling;
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
     # the include files need ft2build.h, and Requires.private isn't enough for us
     postInstall = ''
-      sed "/^Requires:/s/$/, freetype2/" -i "$out/lib/pkgconfig/xft.pc"
+      sed "/^Requires:/s/$/, freetype2/" -i "$dev/lib/pkgconfig/xft.pc"
     '';
   };
 
   libXext = attrs: attrs // {
+    outputs = [ "out" "dev" "man" "doc" ];
     propagatedBuildInputs = [ xorg.xproto xorg.libXau ];
-    preConfigure = setMalloc0ReturnsNullCrossCompiling;
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
+  };
+
+  libXfixes = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
+
+  libXi = attrs: attrs // {
+    outputs = [ "out" "dev" "man" "doc" ];
+    propagatedBuildInputs = [ xorg.libXfixes ];
+  };
+
+  libXinerama = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
+
+  libXmu = attrs: attrs // {
+    outputs = [ "out" "dev" "doc" ];
+    buildFlags = ''BITMAP_DEFINES=-DBITMAPDIR=\"/no-such-path\"'';
+  };
+
+  libXrandr = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
+    propagatedBuildInputs = [xorg.libXrender];
   };
 
-  libSM = attrs: attrs
-    // { propagatedBuildInputs = [ xorg.libICE ]; };
+  libSM = attrs: attrs // {
+    outputs = [ "out" "dev" "doc" ];
+    propagatedBuildInputs = [ xorg.libICE ];
+  };
 
-  libXrender = attrs: attrs
-    // { preConfigure = setMalloc0ReturnsNullCrossCompiling; };
+  libXrender = attrs: attrs // {
+    outputs = [ "out" "dev" "doc" ];
+    configureFlags = attrs.configureFlags or []
+      ++ malloc0ReturnsNullCrossFlag;
+    propagatedBuildInputs = [ xorg.renderproto ];
+  };
 
-  libXvMC = attrs: attrs
-    // { buildInputs = attrs.buildInputs ++ [xorg.renderproto]; };
+  libXres = attrs: attrs // {
+    outputs = [ "out" "dev" "devdoc" ];
+  };
+
+  libXv = attrs: attrs // {
+    outputs = [ "out" "dev" "devdoc" ];
+  };
+
+  libXvMC = attrs: attrs // {
+    outputs = [ "out" "dev" "doc" ];
+    buildInputs = attrs.buildInputs ++ [xorg.renderproto];
+  };
+
+  libXp = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
 
   libXpm = attrs: attrs // {
+    name = "libXpm-3.5.12";
+    src = args.fetchurl {
+      url = mirror://xorg/individual/lib/libXpm-3.5.12.tar.bz2;
+      sha256 = "1v5xaiw4zlhxspvx76y3hq4wpxv7mpj6parqnwdqvpj8vbinsspx";
+    };
+    outputs = [ "bin" "dev" "out" ]; # tiny man in $bin
     patchPhase = "sed -i '/USE_GETTEXT_TRUE/d' sxpm/Makefile.in cxpm/Makefile.in";
   };
 
   libXpresent = attrs: attrs
     // { buildInputs = with xorg; attrs.buildInputs ++ [ libXext libXfixes libXrandr ]; };
 
+  libxkbfile = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # mainly to avoid propagation
+  };
+
+  libxshmfence = attrs: attrs // {
+    name = "libxshmfence-1.3";
+    src = args.fetchurl {
+      url = mirror://xorg/individual/lib/libxshmfence-1.3.tar.bz2;
+      sha256 = "1ir0j92mnd1nk37mrv9bz5swnccqldicgszvfsh62jd14q6k115q";
+    };
+    outputs = [ "out" "dev" ]; # mainly to avoid propagation
+  };
+
+  libpciaccess = attrs: attrs // {
+    meta = attrs.meta // { platforms = stdenv.lib.platforms.linux; };
+  };
+
   setxkbmap = attrs: attrs // {
     postInstall =
       ''
@@ -190,11 +306,33 @@ in
     buildInputs = attrs.buildInputs ++ [ args.freetype args.fontconfig ];
   };
 
+  xcbutil = attrs: attrs // {
+    outputs = [ "out" "dev" ];
+  };
+
   xcbutilcursor = attrs: attrs // {
-    meta.maintainers = [ stdenv.lib.maintainers.lovek323 ];
+    outputs = [ "out" "dev" ];
+    meta = attrs.meta // { maintainers = [ stdenv.lib.maintainers.lovek323 ]; };
+  };
+
+  xcbutilimage = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # mainly to get rid of propagating others
+  };
+
+  xcbutilkeysyms = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # mainly to get rid of propagating others
+  };
+
+  xcbutilrenderutil = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # mainly to get rid of propagating others
+  };
+
+  xcbutilwm = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # mainly to get rid of propagating others
   };
 
   xf86inputevdev = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # to get rid of xorgserver.dev; man is tiny
     preBuild = "sed -e '/motion_history_proc/d; /history_size/d;' -i src/*.c";
     installFlags = "sdkdir=\${out}/include/xorg";
     buildInputs = attrs.buildInputs ++ [ args.mtdev args.libevdev ];
@@ -208,12 +346,19 @@ in
     installFlags = "sdkdir=\${out}/include/xorg";
   };
 
-  xf86inputlibinput = attrs: attrs // {
+  xf86inputlibinput = attrs: attrs // rec {
+    name = "xf86-input-libinput-0.26.0";
+    src = args.fetchurl {
+      url = "mirror://xorg/individual/driver/${name}.tar.bz2";
+      sha256 = "0yrqs88b7yn9nljwlxzn76jfmvf0sh939kzij5b2jvr2qa7mbjmb";
+    };
+    outputs = [ "out" "dev" ];
     buildInputs = attrs.buildInputs ++ [ args.libinput ];
-    installFlags = "sdkdir=\${out}/include/xorg";
+    installFlags = "sdkdir=\${dev}/include/xorg";
   };
 
   xf86inputsynaptics = attrs: attrs // {
+    outputs = [ "out" "dev" ]; # *.pc pulls xorgserver.dev
     buildInputs = attrs.buildInputs ++ [args.mtdev args.libevdev];
     installFlags = "sdkdir=\${out}/include/xorg configdir=\${out}/share/X11/xorg.conf.d";
   };
@@ -224,29 +369,50 @@ in
       "--with-xorg-conf-dir=$(out)/share/X11/xorg.conf.d"
       "--with-udev-rules-dir=$(out)/lib/udev/rules.d"
     ];
+
+    meta = attrs.meta // {
+      platforms = ["i686-linux" "x86_64-linux"];
+    };
   };
 
-  xf86videoati = attrs: attrs // {
-    NIX_CFLAGS_COMPILE = "-I${xorg.glamoregl}/include/xorg";
+  # Obsolete drivers that don't compile anymore.
+  xf86videoark        = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videogeode      = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videoglide      = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videoi128       = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videonewport    = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videotga        = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videov4l        = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videovoodoo     = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+  xf86videowsfb       = attrs: attrs // { meta = attrs.meta // { broken = true; }; };
+
+  xf86videoamdgpu = attrs: attrs // {
+    configureFlags = [ "--with-xorg-conf-dir=$(out)/share/X11/xorg.conf.d" ];
   };
 
-  xf86videonv = attrs: attrs // {
-    patches = [( args.fetchpatch {
-      url = http://cgit.freedesktop.org/xorg/driver/xf86-video-nv/patch/?id=fc78fe98222b0204b8a2872a529763d6fe5048da;
-      sha256 = "0i2ddgqwj6cfnk8f4r73kkq3cna7hfnz7k3xj3ifx5v8mfiva6gw";
-    })];
+  xf86videoati = attrs: attrs // {
+    NIX_CFLAGS_COMPILE = "-I${xorg.xorgserver.dev or xorg.xorgserver}/include/xorg";
   };
 
   xf86videovmware = attrs: attrs // {
     buildInputs =  attrs.buildInputs ++ [ args.mesa_drivers ]; # for libxatracker
+    meta = attrs.meta // {
+      platforms = ["i686-linux" "x86_64-linux"];
+    };
   };
 
   xf86videoqxl = attrs: attrs // {
-    buildInputs =  attrs.buildInputs ++ [ args.spice_protocol ];
+    buildInputs =  attrs.buildInputs ++ [ args.spice-protocol ];
+  };
+
+  xf86videosiliconmotion = attrs: attrs // {
+    meta = attrs.meta // {
+      platforms = ["i686-linux" "x86_64-linux"];
+    };
   };
 
   xdriinfo = attrs: attrs // {
-    buildInputs = attrs.buildInputs ++ [args.mesa];
+    buildInputs = attrs.buildInputs ++ [args.libGL];
   };
 
   xvinfo = attrs: attrs // {
@@ -261,7 +427,8 @@ in
 
     buildInputs = attrs.buildInputs ++ [args.intltool];
 
-    #TODO: resurrect patches for US_intl or Esperanto?
+    #TODO: resurrect patches for US_intl?
+    patches = [ ./xkeyboard-config-eo.patch ];
 
     # 1: compatibility for X11/xkb location
     # 2: I think pkgconfig/ is supposed to be in /lib/
@@ -271,23 +438,51 @@ in
     '';
   };
 
-  xorgserver = with xorg; attrs: attrs //
+  xorgserver = with xorg; attrs_passed:
+    # exchange attrs if abiCompat is set
+    let
+      version = (builtins.parseDrvName attrs_passed.name).version;
+      attrs = with args;
+        if (args.abiCompat == null || lib.hasPrefix args.abiCompat version) then attrs_passed
+        else if (args.abiCompat == "1.17") then {
+          name = "xorg-server-1.17.4";
+          builder = ./builder.sh;
+          src = fetchurl {
+            url = mirror://xorg/individual/xserver/xorg-server-1.17.4.tar.bz2;
+            sha256 = "0mv4ilpqi5hpg182mzqn766frhi6rw48aba3xfbaj4m82v0lajqc";
+          };
+          nativeBuildInputs = [ pkgconfig ];
+          buildInputs = [ dri2proto dri3proto renderproto libdrm openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms xcbutilrenderutil libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt ];
+          meta.platforms = stdenv.lib.platforms.unix;
+        } else if (args.abiCompat == "1.18") then {
+            name = "xorg-server-1.18.4";
+            builder = ./builder.sh;
+            src = fetchurl {
+              url = mirror://xorg/individual/xserver/xorg-server-1.18.4.tar.bz2;
+              sha256 = "1j1i3n5xy1wawhk95kxqdc54h34kg7xp4nnramba2q8xqfr5k117";
+            };
+            nativeBuildInputs = [ pkgconfig ];
+            buildInputs = [ dri2proto dri3proto renderproto libdrm openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms xcbutilrenderutil libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt ];
+            postPatch = stdenv.lib.optionalString stdenv.isLinux "sed '1i#include <malloc.h>' -i include/os.h";
+            meta.platforms = stdenv.lib.platforms.unix;
+        } else throw "unsupported xorg abiCompat ${args.abiCompat} for ${attrs_passed.name}";
+
+    in attrs //
     (let
       version = (builtins.parseDrvName attrs.name).version;
       commonBuildInputs = attrs.buildInputs ++ [ xtrans ];
       commonPropagatedBuildInputs = [
-        args.zlib args.mesa args.dbus.libs
+        args.zlib args.libGL args.libGLU args.dbus
         xf86bigfontproto glproto xf86driproto
         compositeproto scrnsaverproto resourceproto
         xf86dgaproto
         dmxproto /*libdmx not used*/ xf86vidmodeproto
-        recordproto libXext pixman libXfont
+        recordproto libXext pixman libXfont libxshmfence args.libunwind
         damageproto xcmiscproto  bigreqsproto
         inputproto xextproto randrproto renderproto presentproto
         dri2proto dri3proto kbproto xineramaproto resourceproto scrnsaverproto videoproto
+        libXfont2
       ];
-      # fix_segfault: https://bugs.freedesktop.org/show_bug.cgi?id=91316
-      commonPatches = [ ./xorgserver-xkbcomp-path.patch ./fix_segfault.patch ];
       # XQuartz requires two compilations: the first to get X / XQuartz,
       # and the second to get Xvfb, Xnest, etc.
       darwinOtherX = overrideDerivation xorgserver (oldAttrs: {
@@ -303,45 +498,74 @@ in
     in
       if (!isDarwin)
       then {
-        buildInputs = [ makeWrapper ] ++ commonBuildInputs;
-        propagatedBuildInputs = [ libpciaccess ] ++ commonPropagatedBuildInputs ++ lib.optionals stdenv.isLinux [
+        outputs = [ "out" "dev" ];
+        buildInputs = commonBuildInputs ++ [ args.libdrm args.mesa_noglu ];
+        propagatedBuildInputs = [ libpciaccess args.epoxy ] ++ commonPropagatedBuildInputs ++ lib.optionals stdenv.isLinux [
           args.udev
         ];
-        patches = commonPatches;
+        prePatch = stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+          export CFLAGS+=" -D__uid_t=uid_t -D__gid_t=gid_t"
+        '';
         configureFlags = [
           "--enable-kdrive"             # not built by default
           "--enable-xephyr"
           "--enable-xcsecurity"         # enable SECURITY extension
           "--with-default-font-path="   # there were only paths containing "${prefix}",
                                         # and there are no fonts in this package anyway
+          "--with-xkb-bin-directory=${xorg.xkbcomp}/bin"
+          "--with-xkb-path=${xorg.xkeyboardconfig}/share/X11/xkb"
+          "--with-xkb-output=$out/share/X11/xkb/compiled"
+          "--enable-glamor"
+        ] ++ lib.optionals stdenv.hostPlatform.isMusl [
+          "--disable-tls"
         ];
+
         postInstall = ''
-          rm -fr $out/share/X11/xkb/compiled
-          ln -s /var/tmp $out/share/X11/xkb/compiled
-          wrapProgram $out/bin/Xephyr \
-            --set XKB_BINDIR "${xorg.xkbcomp}/bin" \
-            --add-flags "-xkbdir ${xorg.xkeyboardconfig}/share/X11/xkb"
+          rm -fr $out/share/X11/xkb/compiled # otherwise X will try to write in it
+          ( # assert() keeps runtime reference xorgserver-dev in xf86-video-intel and others
+            cd "$dev"
+            for f in include/xorg/*.h; do
+              sed "1i#line 1 \"${attrs.name}/$f\"" -i "$f"
+            done
+          )
         '';
         passthru.version = version; # needed by virtualbox guest additions
       } else {
-        buildInputs = commonBuildInputs ++ [ args.bootstrap_cmds args.automake args.autoconf ];
+        nativeBuildInputs = attrs.nativeBuildInputs ++ [ args.autoreconfHook xorg.utilmacros xorg.fontutil ];
+        buildInputs = commonBuildInputs ++ [
+          args.bootstrap_cmds args.automake args.autoconf
+          args.apple_sdk.libs.Xplugin
+          args.apple_sdk.frameworks.Carbon
+          args.apple_sdk.frameworks.Cocoa
+        ];
         propagatedBuildInputs = commonPropagatedBuildInputs ++ [
           libAppleWM applewmproto
         ];
-        # Patches can be pulled from the server-*-apple branches of:
-        # http://cgit.freedesktop.org/~jeremyhu/xserver/
-        patches = commonPatches ++ [
-          ./darwin/0001-XQuartz-GLX-Use-__glXEnableExtension-to-build-extens.patch
-          ./darwin/0002-sdksyms.sh-Use-CPPFLAGS-not-CFLAGS.patch
-          ./darwin/0003-Workaround-the-GC-clipping-problem-in-miPaintWindow-.patch
-          ./darwin/0004-Use-old-miTrapezoids-and-miTriangles-routines.patch
-          ./darwin/0005-fb-Revert-fb-changes-that-broke-XQuartz.patch
-          ./darwin/0006-fb-Revert-fb-changes-that-broke-XQuartz.patch
-          ./darwin/private-extern.patch
-          ./darwin/bundle_main.patch
-          ./darwin/stub.patch
-          ./darwin/function-pointer-test.patch
+
+        # XQuartz patchset
+        patches = [
+          (args.fetchpatch {
+            url = "https://github.com/XQuartz/xorg-server/commit/e88fd6d785d5be477d5598e70d105ffb804771aa.patch";
+            sha256 = "1q0a30m1qj6ai924afz490xhack7rg4q3iig2gxsjjh98snikr1k";
+            name = "use-cppflags-not-cflags.patch";
+          })
+          (args.fetchpatch {
+            url = "https://github.com/XQuartz/xorg-server/commit/75ee9649bcfe937ac08e03e82fd45d9e18110ef4.patch";
+            sha256 = "1vlfylm011y00j8mig9zy6gk9bw2b4ilw2qlsc6la49zi3k0i9fg";
+            name = "use-old-mitrapezoids-and-mitriangles-routines.patch";
+          })
+          (args.fetchpatch {
+            url = "https://github.com/XQuartz/xorg-server/commit/c58f47415be79a6564a9b1b2a62c2bf866141e73.patch";
+            sha256 = "19sisqzw8x2ml4lfrwfvavc2jfyq2bj5xcf83z89jdxg8g1gdd1i";
+            name = "revert-fb-changes-1.patch";
+          })
+          (args.fetchpatch {
+            url = "https://github.com/XQuartz/xorg-server/commit/56e6f1f099d2821e5002b9b05b715e7b251c0c97.patch";
+            sha256 = "0zm9g0g1jvy79sgkvy0rjm6ywrdba2xjd1nsnjbxjccckbr6i396";
+            name = "revert-fb-changes-2.patch";
+          })
         ];
+
         configureFlags = [
           # note: --enable-xquartz is auto
           "CPPFLAGS=-I${./darwin/dri}"
@@ -352,12 +576,12 @@ in
           "--with-sha1=CommonCrypto"
         ];
         preConfigure = ''
-          ensureDir $out/Applications
+          mkdir -p $out/Applications
           export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -Wno-error"
+          substituteInPlace hw/xquartz/pbproxy/Makefile.in --replace -F/System -F${args.apple_sdk.frameworks.ApplicationServices}
         '';
         postInstall = ''
           rm -fr $out/share/X11/xkb/compiled
-          ln -s /var/tmp $out/share/X11/xkb/compiled
 
           cp -rT ${darwinOtherX}/bin $out/bin
           rm -f $out/bin/X
@@ -376,7 +600,11 @@ in
   };
 
   twm = attrs: attrs // {
-    nativeBuildInputs = [args.bison args.flex];
+    nativeBuildInputs = attrs.nativeBuildInputs ++ [args.bison args.flex];
+  };
+
+  xauth = attrs: attrs // {
+    doCheck = false; # fails
   };
 
   xcursorthemes = attrs: attrs // {
@@ -384,15 +612,11 @@ in
     configureFlags = "--with-cursordir=$(out)/share/icons";
   };
 
-  xinput = attrs: attrs // {
-    propagatedBuildInputs = [xorg.libXfixes];
-  };
-
   xinit = attrs: attrs // {
     stdenv = if isDarwin then args.clangStdenv else stdenv;
     buildInputs = attrs.buildInputs ++ lib.optional isDarwin args.bootstrap_cmds;
     configureFlags = [
-      "--with-xserver=${xorg.xorgserver}/bin/X"
+      "--with-xserver=${xorg.xorgserver.out}/bin/X"
     ] ++ lib.optionals isDarwin [
       "--with-bundle-id-prefix=org.nixos.xquartz"
       "--with-launchdaemons-dir=\${out}/LaunchDaemons"
@@ -406,8 +630,41 @@ in
   };
 
   xf86videointel = attrs: attrs // {
-    buildInputs = attrs.buildInputs ++ [xorg.libXfixes];
-    nativeBuildInputs = [args.autoreconfHook xorg.utilmacros];
+    # the update script only works with released tarballs :-/
+    name = "xf86-video-intel-2017-10-19";
+    src = args.fetchurl {
+      url = "http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/snapshot/"
+          + "4798e18b2b2c8b0a05dc967e6140fd9962bc1a73.tar.gz";
+      sha256 = "1zpgbibfpdassswfj68zwhhfpvd2p80rpxw92bis6lv81ssknwby";
+    };
+    buildInputs = attrs.buildInputs ++ [xorg.libXfixes xorg.libXScrnSaver xorg.pixman];
+    nativeBuildInputs = attrs.nativeBuildInputs ++ [args.autoreconfHook xorg.utilmacros];
+    configureFlags = "--with-default-dri=3 --enable-tools";
+
+    meta = attrs.meta // {
+      platforms = ["i686-linux" "x86_64-linux"];
+    };
+  };
+
+  xf86videoxgi = attrs: attrs // {
+    patches = [
+      # fixes invalid open mode
+      # https://cgit.freedesktop.org/xorg/driver/xf86-video-xgi/commit/?id=bd94c475035739b42294477cff108e0c5f15ef67
+      (args.fetchpatch {
+        url = "https://cgit.freedesktop.org/xorg/driver/xf86-video-xgi/patch/?id=bd94c475035739b42294477cff108e0c5f15ef67";
+        sha256 = "0myfry07655adhrpypa9rqigd6rfx57pqagcwibxw7ab3wjay9f6";
+      })
+      (args.fetchpatch {
+        url = "https://cgit.freedesktop.org/xorg/driver/xf86-video-xgi/patch/?id=78d1138dd6e214a200ca66fa9e439ee3c9270ec8";
+        sha256 = "0z3643afgrync280zrp531ija0hqxc5mrwjif9nh9lcnzgnz2d6d";
+      })
+    ];
+  };
+
+  xorgcffiles = attrs: attrs // {
+    postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+      substituteInPlace $out/lib/X11/config/darwin.cf --replace "/usr/bin/" ""
+    '';
   };
 
   xwd = attrs: attrs // {
@@ -430,4 +687,13 @@ in
     configureFlags = "--with-cpp=${args.mcpp}/bin/mcpp";
   };
 
+  sessreg = attrs: attrs // {
+    preBuild = "sed -i 's|gcc -E|gcc -E -P|' man/Makefile";
+  };
+
+  xrandr = attrs: attrs // {
+    postInstall = ''
+      rm $out/bin/xkeystone
+    '';
+  };
 }
diff --git a/pkgs/servers/x11/xorg/replacements.nix b/pkgs/servers/x11/xorg/replacements.nix
deleted file mode 100644
index 175d05b0a364..000000000000
--- a/pkgs/servers/x11/xorg/replacements.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-{stdenv, fetchurl, xorg, automake, autoconf, libtool, makeOverridable}:
-{
-  xf86videoati = {src, suffix}: 
-  makeOverridable stdenv.mkDerivation {
-      name = "xf86-video-ati-${suffix}";
-      buildInputs = xorg.xf86videoati.buildInputs ++
-         [autoconf automake libtool];
-      builder = ./builder.sh;
-      inherit src;
-      preConfigure = ''
-        export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DPACKAGE_VERSION_MAJOR=6"
-        export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DPACKAGE_VERSION_MINOR=9"
-        export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DPACKAGE_VERSION_PATCHLEVEL=999"
-
-        sed -e 's/@DRIVER_MAN_SUFFIX@/man/g' -i man/Makefile.am
-        export DRIVER_MAN_DIR=$out/share/man/man5 
-
-        ./autogen.sh
-      '';
-  };
-}
diff --git a/pkgs/servers/x11/xorg/tarballs-7.7.list b/pkgs/servers/x11/xorg/tarballs-7.7.list
index 67e125528c95..70f3a35505e0 100644
--- a/pkgs/servers/x11/xorg/tarballs-7.7.list
+++ b/pkgs/servers/x11/xorg/tarballs-7.7.list
@@ -1,12 +1,13 @@
 mirror://xorg/X11R7.7/src/everything/applewmproto-1.4.2.tar.bz2
-mirror://xorg/individual/app/bdftopcf-1.0.5.tar.bz2
+mirror://xorg/individual/app/bdftopcf-1.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/bigreqsproto-1.1.2.tar.bz2
+mirror://xorg/individual/app/bitmap-1.0.8.tar.gz
 mirror://xorg/X11R7.7/src/everything/compositeproto-0.4.2.tar.bz2
 mirror://xorg/X11R7.7/src/everything/damageproto-1.2.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/dmxproto-2.3.1.tar.bz2
 mirror://xorg/individual/proto/dri2proto-2.8.tar.bz2
 mirror://xorg/individual/proto/dri3proto-1.0.tar.bz2
-mirror://xorg/individual/proto/presentproto-1.0.tar.bz2
+mirror://xorg/individual/proto/presentproto-1.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/encodings-1.0.4.tar.bz2
 mirror://xorg/X11R7.7/src/everything/fixesproto-5.0.tar.bz2
 mirror://xorg/X11R7.7/src/everything/font-adobe-100dpi-1.0.3.tar.bz2
@@ -48,7 +49,7 @@ mirror://xorg/X11R7.7/src/everything/font-winitzki-cyrillic-1.0.3.tar.bz2
 mirror://xorg/X11R7.7/src/everything/font-xfree86-type1-1.0.4.tar.bz2
 mirror://xorg/individual/proto/glproto-1.4.17.tar.bz2
 mirror://xorg/individual/app/iceauth-1.0.7.tar.bz2
-mirror://xorg/individual/proto/inputproto-2.3.1.tar.bz2
+mirror://xorg/individual/proto/inputproto-2.3.2.tar.bz2
 mirror://xorg/individual/proto/kbproto-1.0.7.tar.bz2
 mirror://xorg/X11R7.7/src/everything/libAppleWM-1.4.1.tar.bz2
 mirror://xorg/individual/lib/libdmx-1.1.3.tar.bz2
@@ -56,34 +57,35 @@ mirror://xorg/individual/lib/libxshmfence-1.2.tar.bz2
 mirror://xorg/individual/lib/libfontenc-1.1.3.tar.bz2
 mirror://xorg/individual/lib/libFS-1.0.7.tar.bz2
 mirror://xorg/individual/lib/libICE-1.0.9.tar.bz2
-mirror://xorg/individual/lib/libpciaccess-0.13.4.tar.bz2
+mirror://xorg/individual/lib/libpciaccess-0.14.tar.bz2
 mirror://xorg/individual/lib/libSM-1.2.2.tar.bz2
 mirror://xorg/X11R7.7/src/everything/libWindowsWM-1.0.1.tar.bz2
-mirror://xorg/individual/lib/libX11-1.6.3.tar.bz2
+mirror://xorg/individual/lib/libX11-1.6.5.tar.bz2
 mirror://xorg/individual/lib/libXau-1.0.8.tar.bz2
 mirror://xorg/individual/lib/libXaw-1.0.13.tar.bz2
 mirror://xorg/individual/lib/libXcomposite-0.4.4.tar.bz2
-mirror://xorg/individual/lib/libXcursor-1.1.14.tar.bz2
+mirror://xorg/individual/lib/libXcursor-1.1.15.tar.bz2
 mirror://xorg/individual/lib/libXdamage-1.1.4.tar.bz2
 mirror://xorg/individual/lib/libXdmcp-1.1.2.tar.bz2
 mirror://xorg/individual/lib/libXext-1.3.3.tar.bz2
-mirror://xorg/individual/lib/libXfixes-5.0.1.tar.bz2
-mirror://xorg/individual/lib/libXfont-1.5.1.tar.bz2
+mirror://xorg/individual/lib/libXfixes-5.0.3.tar.bz2
+mirror://xorg/individual/lib/libXfont-1.5.4.tar.bz2
+mirror://xorg/individual/lib/libXfont2-2.0.3.tar.bz2
 mirror://xorg/individual/lib/libXft-2.3.2.tar.bz2
-mirror://xorg/individual/lib/libXi-1.7.5.tar.bz2
+mirror://xorg/individual/lib/libXi-1.7.9.tar.bz2
 mirror://xorg/individual/lib/libXinerama-1.1.3.tar.bz2
 mirror://xorg/individual/lib/libxkbfile-1.0.9.tar.bz2
 mirror://xorg/individual/lib/libXmu-1.1.2.tar.bz2
-mirror://xorg/individual/lib/libXpm-3.5.11.tar.bz2
+mirror://xorg/individual/lib/libXpm-3.5.12.tar.bz2
 mirror://xorg/individual/lib/libXpresent-1.0.0.tar.bz2
-mirror://xorg/individual/lib/libXrandr-1.5.0.tar.bz2
-mirror://xorg/individual/lib/libXrender-0.9.9.tar.bz2
-mirror://xorg/individual/lib/libXres-1.0.7.tar.bz2
+mirror://xorg/individual/lib/libXrandr-1.5.1.tar.bz2
+mirror://xorg/individual/lib/libXrender-0.9.10.tar.bz2
+mirror://xorg/individual/lib/libXres-1.2.0.tar.bz2
 mirror://xorg/X11R7.7/src/everything/libXScrnSaver-1.2.2.tar.bz2
 mirror://xorg/individual/lib/libXt-1.1.5.tar.bz2
-mirror://xorg/individual/lib/libXtst-1.2.2.tar.bz2
-mirror://xorg/individual/lib/libXv-1.0.10.tar.bz2
-mirror://xorg/individual/lib/libXvMC-1.0.9.tar.bz2
+mirror://xorg/individual/lib/libXtst-1.2.3.tar.bz2
+mirror://xorg/individual/lib/libXv-1.0.11.tar.bz2
+mirror://xorg/individual/lib/libXvMC-1.0.10.tar.bz2
 mirror://xorg/individual/lib/libXxf86dga-1.1.4.tar.bz2
 mirror://xorg/individual/lib/libXxf86vm-1.1.4.tar.bz2
 mirror://xorg/X11R7.7/src/everything/luit-1.1.1.tar.bz2
@@ -95,15 +97,15 @@ mirror://xorg/X11R7.7/src/everything/recordproto-1.14.2.tar.bz2
 mirror://xorg/X11R7.7/src/everything/renderproto-0.11.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/resourceproto-1.2.0.tar.bz2
 mirror://xorg/X11R7.7/src/everything/scrnsaverproto-1.2.2.tar.bz2
-mirror://xorg/individual/app/sessreg-1.1.0.tar.bz2
+mirror://xorg/individual/app/sessreg-1.1.1.tar.bz2
 mirror://xorg/individual/app/setxkbmap-1.3.1.tar.bz2
 mirror://xorg/individual/app/smproxy-1.0.6.tar.bz2
 mirror://xorg/individual/app/twm-1.0.9.tar.bz2
-mirror://xorg/individual/util/util-macros-1.19.0.tar.bz2
-mirror://xorg/individual/proto/videoproto-2.3.2.tar.bz2
+mirror://xorg/individual/util/util-macros-1.19.2.tar.bz2
+mirror://xorg/individual/proto/videoproto-2.3.3.tar.bz2
 mirror://xorg/X11R7.7/src/everything/windowswmproto-1.0.4.tar.bz2
 mirror://xorg/individual/app/x11perf-1.6.0.tar.bz2
-mirror://xorg/individual/app/xauth-1.0.9.tar.bz2
+mirror://xorg/individual/app/xauth-1.0.10.tar.bz2
 mirror://xorg/individual/app/xbacklight-1.2.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xbitmaps-1.1.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xcmiscproto-1.2.2.tar.bz2
@@ -118,60 +120,65 @@ mirror://xorg/individual/proto/xextproto-7.3.0.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86bigfontproto-1.2.0.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86dgaproto-2.1.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86driproto-2.1.1.tar.bz2
-mirror://xorg/individual/driver/xf86-input-evdev-2.9.2.tar.bz2
-mirror://xorg/individual/driver/xf86-input-joystick-1.6.2.tar.bz2
-mirror://xorg/individual/driver/xf86-input-keyboard-1.8.1.tar.bz2
-mirror://xorg/individual/driver/xf86-input-libinput-0.12.0.tar.bz2
-mirror://xorg/individual/driver/xf86-input-mouse-1.9.1.tar.bz2
-mirror://xorg/individual/driver/xf86-input-synaptics-1.8.2.tar.bz2
+mirror://xorg/individual/driver/xf86-input-evdev-2.10.5.tar.bz2
+mirror://xorg/individual/driver/xf86-input-joystick-1.6.3.tar.bz2
+mirror://xorg/individual/driver/xf86-input-keyboard-1.9.0.tar.bz2
+mirror://xorg/individual/driver/xf86-input-libinput-0.26.0.tar.bz2
+mirror://xorg/individual/driver/xf86-input-mouse-1.9.2.tar.bz2
+mirror://xorg/individual/driver/xf86-input-synaptics-1.9.0.tar.bz2
 mirror://xorg/individual/driver/xf86-input-vmmouse-13.1.0.tar.bz2
 mirror://xorg/individual/driver/xf86-input-void-1.4.1.tar.bz2
+mirror://xorg/individual/driver/xf86-video-amdgpu-1.4.0.tar.bz2
 mirror://xorg/individual/driver/xf86-video-ark-0.7.5.tar.bz2
-mirror://xorg/individual/driver/xf86-video-ast-0.98.0.tar.bz2
-mirror://xorg/individual/driver/xf86-video-ati-7.5.0.tar.bz2
-mirror://xorg/individual/driver/glamor-egl-0.6.0.tar.bz2
-mirror://xorg/individual/driver/xf86-video-nouveau-1.0.11.tar.bz2
+mirror://xorg/individual/driver/xf86-video-ast-1.1.5.tar.bz2
+mirror://xorg/individual/driver/xf86-video-ati-18.0.1.tar.bz2
+mirror://xorg/individual/driver/xf86-video-nouveau-1.0.15.tar.bz2
+mirror://xorg/individual/driver/xf86-video-chips-1.2.7.tar.bz2
 mirror://xorg/individual/driver/xf86-video-cirrus-1.5.3.tar.bz2
-mirror://xorg/individual/driver/xf86-video-dummy-0.3.7.tar.bz2
+mirror://xorg/individual/driver/xf86-video-dummy-0.3.8.tar.bz2
 mirror://xorg/individual/driver/xf86-video-fbdev-0.4.4.tar.bz2
 mirror://xorg/individual/driver/xf86-video-geode-2.11.17.tar.bz2
 mirror://xorg/individual/driver/xf86-video-glide-1.2.2.tar.bz2
-mirror://xorg/individual/driver/xf86-video-glint-1.2.8.tar.bz2
+mirror://xorg/individual/driver/xf86-video-glint-1.2.9.tar.bz2
 mirror://xorg/individual/driver/xf86-video-i128-1.3.6.tar.bz2
-mirror://xorg/individual/driver/xf86-video-i740-1.3.5.tar.bz2
+mirror://xorg/individual/driver/xf86-video-i740-1.3.6.tar.bz2
 mirror://xorg/individual/driver/xf86-video-intel-2.99.917.tar.bz2
 mirror://xorg/individual/driver/xf86-video-mach64-6.9.5.tar.bz2
-mirror://xorg/individual/driver/xf86-video-mga-1.6.4.tar.bz2
-mirror://xorg/individual/driver/xf86-video-modesetting-0.9.0.tar.bz2
-mirror://xorg/individual/driver/xf86-video-qxl-0.1.3.tar.bz2
+mirror://xorg/individual/driver/xf86-video-mga-1.6.5.tar.bz2
+mirror://xorg/individual/driver/xf86-video-qxl-0.1.5.tar.bz2
 mirror://xorg/individual/driver/xf86-video-neomagic-1.2.9.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86-video-newport-0.2.4.tar.bz2
-mirror://xorg/individual/driver/xf86-video-nv-2.1.20.tar.bz2
-mirror://xorg/individual/driver/xf86-video-openchrome-0.3.3.tar.bz2
-mirror://xorg/individual/driver/xf86-video-r128-6.10.0.tar.bz2
-mirror://xorg/individual/driver/xf86-video-savage-2.3.8.tar.bz2
-mirror://xorg/individual/driver/xf86-video-siliconmotion-1.7.8.tar.bz2
-mirror://xorg/individual/driver/xf86-video-sis-0.10.7.tar.bz2
+mirror://xorg/individual/driver/xf86-video-nv-2.1.21.tar.bz2
+mirror://xorg/individual/driver/xf86-video-openchrome-0.6.0.tar.bz2
+mirror://xorg/individual/driver/xf86-video-r128-6.10.2.tar.bz2
+mirror://xorg/individual/driver/xf86-video-rendition-4.2.6.tar.bz2
+mirror://xorg/individual/driver/xf86-video-s3virge-1.10.7.tar.bz2
+mirror://xorg/individual/driver/xf86-video-savage-2.3.9.tar.bz2
+mirror://xorg/individual/driver/xf86-video-siliconmotion-1.7.9.tar.bz2
+mirror://xorg/individual/driver/xf86-video-sis-0.10.9.tar.bz2
+mirror://xorg/individual/driver/xf86-video-sisusb-0.9.7.tar.bz2
 mirror://xorg/individual/driver/xf86-video-suncg6-1.1.2.tar.bz2
 mirror://xorg/individual/driver/xf86-video-sunffb-1.2.2.tar.bz2
-mirror://xorg/individual/driver/xf86-video-tdfx-1.4.6.tar.bz2
+mirror://xorg/individual/driver/xf86-video-sunleo-1.2.2.tar.bz2
+mirror://xorg/individual/driver/xf86-video-tdfx-1.4.7.tar.bz2
 mirror://xorg/individual/driver/xf86-video-tga-1.2.2.tar.bz2
-mirror://xorg/individual/driver/xf86-video-trident-1.3.7.tar.bz2
+mirror://xorg/individual/driver/xf86-video-trident-1.3.8.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86-video-v4l-0.2.0.tar.bz2
-mirror://xorg/individual/driver/xf86-video-vesa-2.3.4.tar.bz2
-mirror://xorg/individual/driver/xf86-video-vmware-13.1.0.tar.bz2
+mirror://xorg/individual/driver/xf86-video-vesa-2.4.0.tar.bz2
+mirror://xorg/individual/driver/xf86-video-vmware-13.2.1.tar.bz2
 mirror://xorg/individual/driver/xf86-video-voodoo-1.2.5.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86-video-wsfb-0.4.0.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xf86vidmodeproto-2.3.1.tar.bz2
+mirror://xorg/individual/driver/xf86-video-xgi-1.6.1.tar.bz2
 mirror://xorg/individual/app/xgamma-1.0.6.tar.bz2
 mirror://xorg/individual/app/xgc-1.0.5.tar.bz2
 mirror://xorg/individual/app/xhost-1.0.7.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xineramaproto-1.2.1.tar.bz2
-mirror://xorg/individual/app/xinput-1.6.1.tar.bz2
-mirror://xorg/individual/app/xkbcomp-1.3.0.tar.bz2
+mirror://xorg/individual/app/xinput-1.6.2.tar.bz2
+mirror://xorg/individual/app/xkbcomp-1.4.0.tar.bz2
 mirror://xorg/individual/app/xkbevd-1.1.4.tar.bz2
 mirror://xorg/individual/app/xkbutils-1.0.4.tar.bz2
-mirror://xorg/individual/data/xkeyboard-config/xkeyboard-config-2.15.tar.bz2
+mirror://xorg/individual/data/xkeyboard-config/xkeyboard-config-2.22.tar.bz2
 mirror://xorg/individual/app/xkill-1.0.4.tar.bz2
 mirror://xorg/individual/app/xlsatoms-1.1.2.tar.bz2
 mirror://xorg/individual/app/xlsclients-1.1.3.tar.bz2
@@ -179,12 +186,12 @@ mirror://xorg/individual/app/xlsfonts-1.0.5.tar.bz2
 mirror://xorg/individual/app/xmag-1.0.6.tar.bz2
 mirror://xorg/individual/app/xmodmap-1.0.9.tar.bz2
 mirror://xorg/individual/doc/xorg-docs-1.7.1.tar.bz2
-mirror://xorg/individual/xserver/xorg-server-1.17.2.tar.bz2
+mirror://xorg/individual/xserver/xorg-server-1.19.6.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xorg-sgml-doctools-1.11.tar.bz2
 mirror://xorg/X11R7.7/src/everything/xpr-1.0.4.tar.bz2
 mirror://xorg/individual/app/xprop-1.2.2.tar.bz2
-mirror://xorg/individual/proto/xproto-7.0.28.tar.bz2
-mirror://xorg/individual/app/xrandr-1.4.3.tar.bz2
+mirror://xorg/individual/proto/xproto-7.0.31.tar.bz2
+mirror://xorg/individual/app/xrandr-1.5.0.tar.bz2
 mirror://xorg/individual/app/xrdb-1.1.0.tar.bz2
 mirror://xorg/individual/app/xrefresh-1.0.5.tar.bz2
 mirror://xorg/individual/app/xset-1.2.3.tar.bz2
diff --git a/pkgs/servers/x11/xorg/unichrome/configure.patch b/pkgs/servers/x11/xorg/unichrome/configure.patch
deleted file mode 100644
index 3c9fc927711b..000000000000
--- a/pkgs/servers/x11/xorg/unichrome/configure.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff --git a/configure.ac b/configure.ac
-index bacea8a..691a9fa 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -77,6 +77,14 @@ AC_MSG_CHECKING([X protocol headers directory])
- protodir=$(pkg-config --variable=includex11dir xproto)
- AC_MSG_RESULT([$protodir])
- 
-+AC_MSG_CHECKING([X extension protocol headers directory])
-+extprotodir=$(pkg-config --variable=includedir xextproto)
-+AC_MSG_RESULT([$extprotodir])
-+
-+AC_MSG_CHECKING([XvMC headers directory])
-+xvmcdir=$(pkg-config --variable=includedir xvmc)
-+AC_MSG_RESULT([$extprotodir])
-+
- # Checks for libraries.
- 
- # Checks for header files.
-@@ -139,7 +147,7 @@ if test "x$have_xvmc" != xno; then
- 		      [have_xvmc_h="yes"], [have_xvmc_h="no"])
- 	AC_CHECK_FILE([${protodir}/extensions/vldXvMC.h],
- 		      [have_vldxvmc_h="yes"], [have_vldxvmc_h="no"])
--	AC_CHECK_FILE([${protodir}/extensions/XvMClib.h],
-+	AC_CHECK_FILE([${xvmcdir}/X11/extensions/XvMClib.h],
- 		      [have_xvmclib_h="yes"], [have_xvmclib_h="no"])
- fi
- 
-@@ -225,7 +233,7 @@ fi
- CFLAGS="$SAVED_CFLAGS"
- 
- # in the xserver 1.7 timeframe, the protocol headers were split up.
--AC_CHECK_FILE([${protodir}/extensions/dpmsconst.h],
-+AC_CHECK_FILE([${extprotodir}/X11/extensions/dpmsconst.h],
- 	      [have_dpmsconst_h="yes"], [have_dpmsconst_h="no"])
- if test "x$have_dpmsconst_h" = xyes; then
- 	AC_DEFINE(HAVE_DPMSCONST_H, 1, [Proto Headers have dpmsconst.h])
diff --git a/pkgs/servers/x11/xorg/unichrome/default.nix b/pkgs/servers/x11/xorg/unichrome/default.nix
deleted file mode 100644
index b9cedfc4679f..000000000000
--- a/pkgs/servers/x11/xorg/unichrome/default.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{stdenv, fetchgit, pkgconfig, fontsproto, libdrm, libpciaccess, randrproto, renderproto,
-videoproto, libX11,
-xextproto, xf86driproto, xorgserver, xproto, libXvMC, glproto, mesa, automake,
-autoconf, libtool, libXext, utilmacros, pixman}:
-
-stdenv.mkDerivation {
-  name = "xf86-video-unichrome";
-  src = fetchgit {
-    url = "git://people.freedesktop.org/~libv/xf86-video-unichrome";
-    md5 = "6e5e0f8ee204af2385a02e502d1ca8f1";
-    rev = "6260e0fc9f0754d101dda014a8f4b5f76f58e978";
-  };
-  buildInputs = [pkgconfig fontsproto libdrm libpciaccess randrproto renderproto
-    videoproto libX11 libXext xextproto xf86driproto xorgserver xproto libXvMC
-    glproto mesa automake autoconf libtool libXext utilmacros pixman ];
-  preConfigure = "chmod +x autogen.sh";
-  prePatch = ''
-    sed s,/bin/bash,/bin/sh, -i git_version.sh
-  '';
-  patches = [ ./configure.patch ];
-  configureScript = "./autogen.sh";
-  CFLAGS="-I${pixman}/include/pixman-1";
-
-  meta = {
-    homepage = "http://unichrome.sourceforge.net/";
-    description = "Xorg video driver for the S3 Unichrome family of integrated graphics devices";
-    license = stdenv.lib.licenses.free;
-    maintainers = with stdenv.lib.maintainers; [viric];
-    platforms = with stdenv.lib.platforms; linux;
-    broken = true;
-  };
-}
diff --git a/pkgs/servers/x11/xorg/xcb-util-xrm.nix b/pkgs/servers/x11/xorg/xcb-util-xrm.nix
new file mode 100644
index 000000000000..c38d4e80143b
--- /dev/null
+++ b/pkgs/servers/x11/xorg/xcb-util-xrm.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, pkgconfig, m4, libxcb, xcbutil, libX11 }:
+
+stdenv.mkDerivation rec {
+  version = "1.2";
+  name = "xcb-util-xrm-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/Airblader/xcb-util-xrm/releases/download/v${version}/${name}.tar.bz2";
+    sha256 = "0vbqhag51i0njc8d5fc8c6aa12496cwrc3s6s7sa5kfc17cwhppp";
+  };
+
+  nativeBuildInputs = [ pkgconfig m4 ];
+  buildInputs = [ libxcb xcbutil ]
+    ++ stdenv.lib.optional doCheck libX11;
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "XCB utility functions for the X resource manager";
+    homepage = https://github.com/Airblader/xcb-util-xrm;
+    license = licenses.mit; # X11 variant
+    platforms = with platforms; unix;
+  };
+}
diff --git a/pkgs/servers/x11/xorg/xkeyboard-config-eo.patch b/pkgs/servers/x11/xorg/xkeyboard-config-eo.patch
new file mode 100644
index 000000000000..66f45a410f71
--- /dev/null
+++ b/pkgs/servers/x11/xorg/xkeyboard-config-eo.patch
@@ -0,0 +1,69 @@
+diff --git a/rules/base.xml.in b/rules/base.xml.in
+index ec321f8..e9c3546 100644
+--- a/rules/base.xml.in
++++ b/rules/base.xml.in
+@@ -1786,6 +1786,13 @@
+     </layout>
+     <layout>
+       <configItem>
++        <name>eo</name>
++        <_shortDescription>Esp</_shortDescription>
++        <_description>Esperanto</_description>
++      </configItem>
++    </layout>
++    <layout>
++      <configItem>
+         <name>ir</name>
+         <_shortDescription>Irn</_shortDescription>
+         <_description>Iran</_description>
+diff --git a/symbols/Makefile.am b/symbols/Makefile.am
+--- a/symbols/Makefile.am
++++ b/symbols/Makefile.am
+@@ -10,7 +10,7 @@ bt by braille \
+ ca cd ch \
+ ch cn cz \
+ de dk dz \
+-ee es et epo eu \
++ee eo es et epo eu \
+ fi fo fr \
+ gb ge gh gn \
+ gr hr hu \
+diff --git a/symbols/Makefile.in b/symbols/Makefile.in
+--- a/symbols/Makefile.in
++++ b/symbols/Makefile.in
+@@ -222,7 +222,7 @@ bt by braille \
+ ca cd ch \
+ ch cn cz \
+ de dk dz \
+-ee es et epo eu \
++ee eo es et epo eu \
+ fi fo fr \
+ gb ge gh gn \
+ gr hr hu \
+diff --git a/symbols/eo b/symbols/eo
+new file mode 100644
+index 0000000..d6358c9
+--- /dev/null
++++ b/symbols/eo
+@@ -0,0 +1,21 @@
++// $XFree86$
++
++partial alphanumeric_keys
++xkb_symbols "basic" {
++
++     // Describes the differences between a very simple en_US
++     // keyboard and a simple Esperanto keyboard
++     // Press AltGr or Windows Menu key together with C, H, J, S, U
++     // to get accented letters.
++     // 2001 by Radovan Garabik <garabik@melkor.dnp.fmph.uniba.sk>
++
++    key.type = "FOUR_LEVEL";
++
++    key <AD02>  { [w,W, ubreve,Ubreve ] };
++    key <AD07>  { [u,U, ubreve, Ubreve ] };
++    key <AC02>  { [s,S, scircumflex,    Scircumflex ] };
++    key <AC05>  { [g,G, gcircumflex,Gcircumflex ] };
++    key <AC06>  { [h,H, hcircumflex,Hcircumflex ] };
++    key <AC07>  { [j,J, jcircumflex,Jcircumflex ] };
++    key <AB03>  { [c,C, ccircumflex,Ccircumflex ] };
++};
diff --git a/pkgs/servers/x11/xorg/xorgserver-xkbcomp-path.patch b/pkgs/servers/x11/xorg/xorgserver-xkbcomp-path.patch
deleted file mode 100644
index 69216ec70733..000000000000
--- a/pkgs/servers/x11/xorg/xorgserver-xkbcomp-path.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/os/utils.c b/os/utils.c
-index ed7581e..6593455 100644
---- a/os/utils.c
-+++ b/os/utils.c
-@@ -658,6 +658,10 @@ ProcessCommandLine(int argc, char *argv[])
- 
-     defaultKeyboardControl.autoRepeat = TRUE;
- 
-+    char *xkbBinDir = getenv("XKB_BINDIR");
-+    if (xkbBinDir)
-+        XkbBinDirectory = Xstrdup(xkbBinDir);
-+
- #ifdef NO_PART_NET
-     PartialNetwork = FALSE;
- #else
diff --git a/pkgs/servers/x11/xorg/xwayland.nix b/pkgs/servers/x11/xorg/xwayland.nix
index 729fcc2e3447..6de53faf7710 100644
--- a/pkgs/servers/x11/xorg/xwayland.nix
+++ b/pkgs/servers/x11/xorg/xwayland.nix
@@ -1,13 +1,13 @@
 
-{ stdenv, wayland, xorgserver, xkbcomp, xkeyboard_config, epoxy, libxslt, libunwind, makeWrapper }:
+{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config, epoxy, libxslt, libunwind, makeWrapper }:
 
 with stdenv.lib;
 
 overrideDerivation xorgserver (oldAttrs: {
 
   name = "xwayland-${xorgserver.version}";
-  propagatedNativeBuildInputs = oldAttrs.propagatedNativeBuildInputs
-    ++ [wayland epoxy libxslt makeWrapper libunwind];
+  propagatedBuildInputs = oldAttrs.propagatedBuildInputs
+    ++ [wayland wayland-protocols epoxy libxslt makeWrapper libunwind];
   configureFlags = [
     "--disable-docs"
     "--disable-devel-docs"
@@ -17,6 +17,7 @@ overrideDerivation xorgserver (oldAttrs: {
     "--disable-xnest"
     "--disable-xquartz"
     "--disable-xwin"
+    "--enable-glamor"
     "--with-default-font-path="
     "--with-xkb-bin-directory=${xkbcomp}/bin"
     "--with-xkb-path=${xkeyboard_config}/etc/X11/xkb"
@@ -25,7 +26,6 @@ overrideDerivation xorgserver (oldAttrs: {
 
   postInstall = ''
     rm -fr $out/share/X11/xkb/compiled
-    ln -s /var/tmp $out/share/X11/xkb/compiled
   '';
 
 }) // {
diff --git a/pkgs/servers/x11/xquartz/X11 b/pkgs/servers/x11/xquartz/X11
index 39bcce2c10b6..e6bb87fab3fe 100755
--- a/pkgs/servers/x11/xquartz/X11
+++ b/pkgs/servers/x11/xquartz/X11
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@shell@
 
 set "$(dirname "$0")"/X11.bin "${@}"
 
diff --git a/pkgs/servers/x11/xquartz/default.nix b/pkgs/servers/x11/xquartz/default.nix
index 3e9e7cb779ee..9c133f9d5d99 100644
--- a/pkgs/servers/x11/xquartz/default.nix
+++ b/pkgs/servers/x11/xquartz/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, buildEnv, makeFontsConf, gnused, writeScript, xorg, bashInteractive, substituteAll, xterm, makeWrapper, ruby
-, openssl, quartz-wm, fontconfig, xkeyboard_config, xlsfonts, xfontsel
-, ttf_bitstream_vera, freefont_ttf, liberation_ttf_binary
+, openssl, quartz-wm, fontconfig, xlsfonts, xfontsel
+, ttf_bitstream_vera, freefont_ttf, liberation_ttf
 , shell ? "${bashInteractive}/bin/bash"
 }:
 
@@ -37,7 +37,6 @@
 # that point into the user's profile.
 
 let
-  shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
   installer = writeScript "xquartz-install" ''
     NIX_LINK=$HOME/.nix-profile
 
@@ -61,12 +60,11 @@ let
     sudo launchctl load -w /Library/LaunchDaemons/$daemonName
   '';
   fontDirs = [
-    xorg.fontbhttf
     xorg.fontbhlucidatypewriter100dpi
     xorg.fontbhlucidatypewriter75dpi
     ttf_bitstream_vera
     freefont_ttf
-    liberation_ttf_binary
+    liberation_ttf
     xorg.fontbh100dpi
     xorg.fontmiscmisc
     xorg.fontcursormisc
@@ -97,10 +95,14 @@ let
     ];
   };
 in stdenv.mkDerivation {
-  name = "xquartz";
+  name = "xquartz-${stdenv.lib.getVersion xorg.xorgserver}";
+
   buildInputs = [ ruby makeWrapper ];
+
   unpackPhase = "sourceRoot=.";
-  buildPhase = ":";
+
+  dontBuild = true;
+
   installPhase = ''
     cp -rT ${xorg.xinit} $out
     chmod -R u+w $out
@@ -109,8 +111,7 @@ in stdenv.mkDerivation {
 
     cp ${installer} $out/bin/xquartz-install
 
-    rm -r $out/LaunchAgents
-    rm -r $out/LaunchDaemons
+    rm -rf $out/LaunchAgents $out/LaunchDaemons
 
     fontsConfPath=$out/etc/X11/fonts.conf
     cp ${fontsConf} $fontsConfPath
@@ -125,29 +126,26 @@ in stdenv.mkDerivation {
       --replace "@DEFAULT_CLIENT@"    "${xterm}/bin/xterm" \
       --replace "@XINIT@"             "$out/bin/xinit" \
       --replace "@XINITRC@"           "$out/etc/X11/xinit/xinitrc" \
-      --replace "@XKEYBOARD_CONFIG@"  "${xkeyboard_config}/etc/X11/xkb" \
       --replace "@FONTCONFIG_FILE@"   "$fontsConfPath"
 
     wrapProgram $out/bin/Xquartz \
-      --set XQUARTZ_X11 $out/Applications/XQuartz.app/Contents/MacOS/X11 \
-      --set XKB_BINDIR "${xorg.xkbcomp}/bin"
+      --set XQUARTZ_X11 $out/Applications/XQuartz.app/Contents/MacOS/X11
 
     defaultStartX="$out/bin/startx -- $out/bin/Xquartz"
 
     ruby ${./patch_plist.rb} \
-      ${shellEscape (builtins.toXML {
+      ${lib.escapeShellArg (builtins.toXML {
         XQUARTZ_DEFAULT_CLIENT = "${xterm}/bin/xterm";
         XQUARTZ_DEFAULT_SHELL  = "${shell}";
         XQUARTZ_DEFAULT_STARTX = "@STARTX@";
         FONTCONFIG_FILE        = "@FONTCONFIG_FILE@";
-        XKB_BINDIR             = "${xorg.xkbcomp}/bin";
       })} \
       $out/Applications/XQuartz.app/Contents/Info.plist
     substituteInPlace $out/Applications/XQuartz.app/Contents/Info.plist \
       --replace "@STARTX@"          "$defaultStartX" \
       --replace "@FONTCONFIG_FILE@" "$fontsConfPath"
 
-    rm $out/lib/X11/xinit/privileged_startx.d/*
+    mkdir -p $out/lib/X11/xinit/privileged_startx.d
     cp ${./privileged} $out/lib/X11/xinit/privileged_startx.d/privileged
     substituteInPlace $out/lib/X11/xinit/privileged_startx.d/privileged \
       --replace "@PATH@"            "$out/bin:${env}" \
@@ -160,7 +158,7 @@ in stdenv.mkDerivation {
       --replace "@ENCODINGSDIR@"    "${xorg.encodings}/share/fonts/X11/encodings" \
       --replace "@MKFONTDIR@"       "${xorg.mkfontdir}/bin/mkfontdir" \
       --replace "@MKFONTSCALE@"     "${xorg.mkfontscale}/bin/mkfontscale" \
-      --replace "@FC_CACHE@"        "${fontconfig}/bin/fc-cache" \
+      --replace "@FC_CACHE@"        "${fontconfig.bin}/bin/fc-cache" \
       --replace "@FONTCONFIG_FILE@" "$fontsConfPath"
 
     cp ${./xinitrc} $out/etc/X11/xinit/xinitrc
@@ -180,6 +178,7 @@ in stdenv.mkDerivation {
       --replace "@DEFAULT_CLIENT@"  "${xterm}/bin/xterm" \
       --replace "@FONTCONFIG_FILE@" "$fontsConfPath"
   '';
+
   meta = with lib; {
     platforms   = platforms.darwin;
     maintainers = with maintainers; [ cstrahan ];
diff --git a/pkgs/servers/x11/xquartz/font_cache b/pkgs/servers/x11/xquartz/font_cache
index 12858af8bc60..b1191980d77f 100755
--- a/pkgs/servers/x11/xquartz/font_cache
+++ b/pkgs/servers/x11/xquartz/font_cache
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@shell@
 
 export PATH=@PATH@:$PATH
 
@@ -83,7 +83,7 @@ get_fontdirs() {
         if [[ $osxfonts == 1 ]] ; then
             find {/System/,/}Library/Fonts -type d
         fi
-    else 
+    else
         if [[ $osxfonts == 1 && -d "${HOME}/Library/Fonts" ]] ; then
             find "${HOME}/Library/Fonts" -type d
         fi
diff --git a/pkgs/servers/x11/xquartz/startx b/pkgs/servers/x11/xquartz/startx
index 131fbc43b8b6..e908e1042d78 100755
--- a/pkgs/servers/x11/xquartz/startx
+++ b/pkgs/servers/x11/xquartz/startx
@@ -217,7 +217,7 @@ EOF
     done
 fi
 
-eval @XINIT@ \"$client\" $clientargs -- \"$server\" $display $serverargs "-xkbdir" "@XKEYBOARD_CONFIG@"
+eval @XINIT@ \"$client\" $clientargs -- \"$server\" $display $serverargs
 retval=$?
 
 if [ x"$enable_xauth" = x1 ] ; then
diff --git a/pkgs/servers/x11/xquartz/system-fonts.nix b/pkgs/servers/x11/xquartz/system-fonts.nix
index cf24bb439b91..db47f8afe015 100644
--- a/pkgs/servers/x11/xquartz/system-fonts.nix
+++ b/pkgs/servers/x11/xquartz/system-fonts.nix
@@ -26,9 +26,7 @@ stdenv.mkDerivation {
       fi;
     done;
     cd $out/share/X11-fonts/
-    rm fonts.dir
-    rm fonts.scale
-    rm fonts.alias
+    rm -f fonts.dir fonts.scale fonts.alias
     mkfontdir
     mkfontscale
     cat $( find ${xorg.fontalias}/ -name fonts.alias) >fonts.alias
diff --git a/pkgs/servers/xinetd/default.nix b/pkgs/servers/xinetd/default.nix
index 34e67e171f4a..445c6c57bbf1 100644
--- a/pkgs/servers/xinetd/default.nix
+++ b/pkgs/servers/xinetd/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, stdenv }:
+{ fetchurl, fetchpatch, stdenv }:
 
 stdenv.mkDerivation rec {
   name = "xinetd-2.3.15";
@@ -8,6 +8,14 @@ stdenv.mkDerivation rec {
     sha256 = "1qsv1al506x33gh92bqa8w21k7mxqrbsrwmxvkj0amn72420ckmz";
   };
 
+  patches = [
+    (fetchpatch {
+      url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-apps/xinetd/files/xinetd-2.3.15-creds.patch?id=426002bfe2789fb6213fba832c8bfee634d68d02";
+      name = "CVE-2013-4342.patch";
+      sha256 = "1iqcrqzgisz4b6vamprzg2y6chai7qpifqcihisrwbjwbc4wzj8v";
+    })
+  ];
+
   meta = {
     description = "Secure replacement for inetd";
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/servers/xmpp/biboumi/catch.patch b/pkgs/servers/xmpp/biboumi/catch.patch
new file mode 100644
index 000000000000..05cf534ecfef
--- /dev/null
+++ b/pkgs/servers/xmpp/biboumi/catch.patch
@@ -0,0 +1,30 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -273,27 +273,6 @@ foreach(file ${source_all})
+ endforeach()
+ 
+ #
+-## Add a rule to download the catch unit test framework
+-#
+-include(ExternalProject)
+-ExternalProject_Add(catch
+-  GIT_REPOSITORY "https://lab.louiz.org/louiz/Catch.git"
+-  PREFIX "external"
+-  UPDATE_COMMAND ""
+-  CONFIGURE_COMMAND ""
+-  BUILD_COMMAND ""
+-  INSTALL_COMMAND ""
+-  )
+-set_target_properties(catch PROPERTIES EXCLUDE_FROM_ALL TRUE)
+-ExternalProject_Get_Property(catch SOURCE_DIR)
+-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/tests/catch.hpp)
+-  target_include_directories(test_suite
+-    PUBLIC "${SOURCE_DIR}/include/"
+-    )
+-  add_dependencies(test_suite catch)
+-endif()
+-
+-#
+ ## Add some custom rules to launch the tests
+ #
+ add_custom_target(check COMMAND "test_suite"
diff --git a/pkgs/servers/xmpp/biboumi/default.nix b/pkgs/servers/xmpp/biboumi/default.nix
new file mode 100644
index 000000000000..7ef6242d2b25
--- /dev/null
+++ b/pkgs/servers/xmpp/biboumi/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, fetchgit, cmake, libuuid, expat, sqlite, libidn,
+  libiconv, botan2, systemd, pkgconfig, udns, pandoc, coreutils } :
+
+stdenv.mkDerivation rec {
+  name = "biboumi-${version}";
+  version = "7.2";
+
+  src = fetchurl {
+    url = "https://git.louiz.org/biboumi/snapshot/biboumi-${version}.tar.xz";
+    sha256 = "0gyr2lp2imrjm5hvijcq0s7k9fzkirfl70cprjy9r4yvq6mg1jvd";
+  };
+
+  louiz_catch = fetchgit {
+    url = https://lab.louiz.org/louiz/Catch.git;
+    rev = "35f510545d55a831372d3113747bf1314ff4f2ef";
+    sha256 = "1l5b32sgr9zc2hlfr445hwwxv18sh3cn5q1xmvf588z6jyf88g2g";
+  };
+
+  patches = [ ./catch.patch ];
+
+  nativeBuildInputs = [ cmake pkgconfig pandoc ];
+  buildInputs = [ libuuid expat sqlite libiconv libidn botan2 systemd
+    udns ];
+
+  preConfigure = ''
+    substituteInPlace CMakeLists.txt --replace /etc/biboumi $out/etc/biboumi
+    substituteInPlace unit/biboumi.service.cmake --replace /bin/kill ${coreutils}/bin/kill
+    cp $louiz_catch/single_include/catch.hpp tests/
+    # echo "policy_directory=$out/etc/biboumi" >> conf/biboumi.cfg
+    # TODO include conf/biboumi.cfg as example somewhere
+  '';
+
+  enableParallelBuilding = true;
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Modern XMPP IRC gateway";
+    platforms = platforms.unix;
+    homepage = https://lab.louiz.org/louiz/biboumi;
+    license = licenses.zlib;
+    maintainers = [ maintainers.woffs ];
+  };
+}
diff --git a/pkgs/servers/xmpp/ejabberd/default.nix b/pkgs/servers/xmpp/ejabberd/default.nix
index 3a77c5cd15c6..6a0bedeab260 100644
--- a/pkgs/servers/xmpp/ejabberd/default.nix
+++ b/pkgs/servers/xmpp/ejabberd/default.nix
@@ -1,28 +1,119 @@
-{stdenv, fetchurl, expat, erlang, zlib, openssl, pam, lib}:
+{ stdenv, writeScriptBin, lib, fetchurl, git, cacert
+, erlang, openssl, expat, libyaml, bash, gnused, gnugrep, coreutils, utillinux, procps, gd
+, flock
+, withMysql ? false
+, withPgsql ? false
+, withSqlite ? false, sqlite
+, withPam ? false, pam
+, withZlib ? true, zlib
+, withRiak ? false
+, withElixir ? false, elixir
+, withIconv ? true
+, withTools ? false
+, withRedis ? false
+}:
 
-stdenv.mkDerivation rec {
-  version = "2.1.13";
+let
+  fakegit = writeScriptBin "git" ''
+    #! ${stdenv.shell} -e
+    if [ "$1" = "describe" ]; then
+      [ -r .rev ] && cat .rev || true
+    fi
+  '';
+
+  ctlpath = lib.makeBinPath [ bash gnused gnugrep coreutils utillinux procps ];
+
+in stdenv.mkDerivation rec {
+  version = "18.01";
   name = "ejabberd-${version}";
+
   src = fetchurl {
-    url = "http://www.process-one.net/downloads/ejabberd/${version}/${name}.tgz";
-    sha256 = "0vf8mfrx7vr3c5h3nfp3qcgwf2kmzq20rjv1h9sk3nimwir1q3d8";
+    url = "https://www.process-one.net/downloads/ejabberd/${version}/${name}.tgz";
+    sha256 = "01i2n8mlgw293jdf4172f9q8ca8m35vysjws791p7nynpfdb4cn6";
   };
-  buildInputs = [ expat erlang zlib openssl pam ];
-  patchPhase = ''
-    sed -i \
-      -e "s|erl \\\|${erlang}/bin/erl \\\|" \
-      -e 's|EXEC_CMD=\"sh -c\"|EXEC_CMD=\"${stdenv.shell} -c\"|' \
-      src/ejabberdctl.template
+
+  nativeBuildInputs = [ fakegit ];
+
+  buildInputs = [ erlang openssl expat libyaml gd ]
+    ++ lib.optional withSqlite sqlite
+    ++ lib.optional withPam pam
+    ++ lib.optional withZlib zlib
+    ++ lib.optional withElixir elixir
+    ;
+
+  # Apparently needed for Elixir
+  LANG = "en_US.UTF-8";
+
+  deps = stdenv.mkDerivation {
+    name = "ejabberd-deps-${version}";
+
+    inherit src;
+
+    configureFlags = [ "--enable-all" "--with-sqlite3=${sqlite.dev}" ];
+
+    nativeBuildInputs = [ git erlang openssl expat libyaml sqlite pam zlib elixir ];
+
+    GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
+
+    makeFlags = [ "deps" ];
+
+    phases = [ "unpackPhase" "configurePhase" "buildPhase" "installPhase" ];
+
+    installPhase = ''
+      for i in deps/*; do
+        ( cd $i
+          git reset --hard
+          git clean -ffdx
+          git describe --always --tags > .rev
+          rm -rf .git
+        )
+      done
+      rm deps/.got
+
+      cp -r deps $out
+    '';
+
+    outputHashMode = "recursive";
+    outputHashAlgo = "sha256";
+    outputHash = "1v3h0c7kfifb6wsfxyv5j1wc7rlxbb7r0pgd4s340wiyxnllzzhk";
+  };
+
+  configureFlags =
+    [ (lib.enableFeature withMysql "mysql")
+      (lib.enableFeature withPgsql "pgsql")
+      (lib.enableFeature withSqlite "sqlite")
+      (lib.enableFeature withPam "pam")
+      (lib.enableFeature withZlib "zlib")
+      (lib.enableFeature withRiak "riak")
+      (lib.enableFeature withElixir "elixir")
+      (lib.enableFeature withIconv "iconv")
+      (lib.enableFeature withTools "tools")
+      (lib.enableFeature withRedis "redis")
+    ] ++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}";
+
+  enableParallelBuilding = true;
+
+  preBuild = ''
+    cp -r $deps deps
+    chmod -R +w deps
+    patchShebangs deps
   '';
-  preConfigure = ''
-    cd src
+
+  postInstall = ''
+    sed -i \
+      -e '2iexport PATH=${ctlpath}:$PATH' \
+      -e 's,\(^ *FLOCK=\).*,\1${flock}/bin/flock,' \
+      -e 's,\(^ *JOT=\).*,\1,' \
+      -e 's,\(^ *CONNLOCKDIR=\).*,\1/var/lock/ejabberdctl,' \
+      $out/sbin/ejabberdctl
   '';
-  configureFlags = ["--enable-pam"];
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Open-source XMPP application server written in Erlang";
-    license = stdenv.lib.licenses.gpl2;
-    homepage = http://www.ejabberd.im;
-    maintainers = [ lib.maintainers.sander ];
+    license = licenses.gpl2;
+    homepage = https://www.ejabberd.im;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ sander abbradar ];
+    broken = withElixir;
   };
 }
diff --git a/pkgs/servers/xmpp/openfire/default.nix b/pkgs/servers/xmpp/openfire/default.nix
index 53924f9888c0..0e6fcd5e9896 100644
--- a/pkgs/servers/xmpp/openfire/default.nix
+++ b/pkgs/servers/xmpp/openfire/default.nix
@@ -22,5 +22,10 @@ stdenv.mkDerivation rec {
 
   meta = {
     description = "XMPP server in Java";
+    platforms = stdenv.lib.platforms.unix;
+    # Some security advisories seem to apply, and each next version wants to
+    # write into larger parts of installation directory; installation is just
+    # unpacking, though
+    broken = true;
   };
 }
diff --git a/pkgs/servers/xmpp/prosody/default.nix b/pkgs/servers/xmpp/prosody/default.nix
index 631073da4d4a..40f630999450 100644
--- a/pkgs/servers/xmpp/prosody/default.nix
+++ b/pkgs/servers/xmpp/prosody/default.nix
@@ -1,16 +1,22 @@
 { stdenv, fetchurl, libidn, openssl, makeWrapper, fetchhg
-, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop, luaevent ? null, luazlib ? null
-, withLibevent ? true, withZlib ? true }:
+, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop
+, withLibevent ? true, luaevent ? null
+, withDBI ? true, luadbi ? null
+# use withExtraLibs to add additional dependencies of community modules
+, withExtraLibs ? [ ]
+, withOnlyInstalledCommunityModules ? [ ]
+, withCommunityModules ? [ ] }:
 
 assert withLibevent -> luaevent != null;
-assert withZlib -> luazlib != null;
+assert withDBI -> luadbi != null;
 
 with stdenv.lib;
 
 let
   libs        = [ luasocket luasec luaexpat luafilesystem luabitop ]
                 ++ optional withLibevent luaevent
-                ++ optional withZlib luazlib;
+                ++ optional withDBI luadbi
+                ++ withExtraLibs;
   getPath     = lib : type : "${lib}/lib/lua/${lua5.luaversion}/?.${type};${lib}/share/lua/${lua5.luaversion}/?.${type}";
   getLuaPath  = lib : getPath lib "lua";
   getLuaCPath = lib : getPath lib "so";
@@ -19,23 +25,22 @@ let
 in
 
 stdenv.mkDerivation rec {
-  version = "0.9.8";
+  version = "0.10.2";
   name = "prosody-${version}";
 
   src = fetchurl {
     url = "http://prosody.im/downloads/source/${name}.tar.gz";
-    sha256 = "0wbq4ps69l09fjb5dfjzab6i30hzpi4bvyj5kc44gf70arf42w4l";
+    sha256 = "13knr7izscw0zx648b9582dx11aap4cq9bzfiqh5ykd7wwsz1dbm";
   };
 
   communityModules = fetchhg {
-    url = "http://prosody-modules.googlecode.com/hg/";
-    rev = "4b55110b0aa8";
-    sha256 = "0010x2rl9f9ihy2nwqan2jdlz25433srj2zna1xh10490mc28hij";
+    url = "https://hg.prosody.im/prosody-modules";
+    rev = "150a7bd59043";
+    sha256 = "0nfx3lngcy88nd81gb7v4kh3nz1bzsm67bxgpd2lprk54diqcrz1";
   };
 
-  buildInputs = [ lua5 luasocket luasec luaexpat luabitop libidn openssl makeWrapper ]
-                ++ optional withLibevent luaevent
-                ++ optional withZlib luazlib;
+  buildInputs = [ lua5 makeWrapper libidn openssl ]
+    ++ optional withDBI luadbi;
 
   configureFlags = [
     "--ostype=linux"
@@ -44,21 +49,25 @@ stdenv.mkDerivation rec {
   ];
 
   postInstall = ''
-      cp $communityModules/mod_websocket/mod_websocket.lua $out/lib/prosody/modules/
+      ${concatMapStringsSep "\n" (module: ''
+        cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
+      '') (withCommunityModules ++ withOnlyInstalledCommunityModules)}
       wrapProgram $out/bin/prosody \
-        --set LUA_PATH '"${luaPath};"' \
-        --set LUA_CPATH '"${luaCPath};"'
+        --set LUA_PATH '${luaPath};' \
+        --set LUA_CPATH '${luaCPath};'
       wrapProgram $out/bin/prosodyctl \
         --add-flags '--config "/etc/prosody/prosody.cfg.lua"' \
-        --set LUA_PATH '"${luaPath};"' \
-        --set LUA_CPATH '"${luaCPath};"'
+        --set LUA_PATH '${luaPath};' \
+        --set LUA_CPATH '${luaCPath};'
     '';
 
+  passthru.communityModules = withCommunityModules;
+
   meta = {
     description = "Open-source XMPP application server written in Lua";
     license = licenses.mit;
-    homepage = http://www.prosody.im;
+    homepage = https://prosody.im;
     platforms = platforms.linux;
-    maintainers = [ maintainers.flosse ];
+    maintainers = with maintainers; [ fpletz globin ];
   };
 }
diff --git a/pkgs/servers/xmpp/pyIRCt/default.nix b/pkgs/servers/xmpp/pyIRCt/default.nix
index 4481ad4a14a6..ebdc73aec30a 100644
--- a/pkgs/servers/xmpp/pyIRCt/default.nix
+++ b/pkgs/servers/xmpp/pyIRCt/default.nix
@@ -1,38 +1,41 @@
-a @ { xmpppy, pythonIRClib, python, makeWrapper, ... } :
-let
-  fetchurl = a.fetchurl;
+{ stdenv, fetchurl, xmpppy, pythonIRClib, python, pythonPackages } :
+
+stdenv.mkDerivation rec {
+  name = "pyIRCt-${version}";
+  version = "0.4";
 
-  version = a.lib.attrByPath ["version"] "0.4" a;
-  buildInputs = with a; [
-    xmpppy pythonIRClib python makeWrapper
-  ];
-in
-rec {
   src = fetchurl {
     url = "mirror://sourceforge/xmpppy/irc-transport-${version}.tar.gz";
     sha256 = "0gbc0dvj1p3088b6x315yjrlwnc5vvzp0var36wlf9z60ghvk8yb";
   };
 
-  inherit buildInputs;
-  configureFlags = [];
+  buildInputs = [ pythonPackages.wrapPython ];
+
+  pythonPath = [
+    xmpppy pythonIRClib
+  ];
 
   /* doConfigure should be removed if not needed */
-  phaseNames = ["deploy" (a.makeManyWrappers "$out/share/${name}/irc.py" a.pythonWrapperArguments)];
-  deploy = a.fullDepEntry (''
+  # phaseNames = ["deploy" (a.makeManyWrappers "$out/share/${name}/irc.py" a.pythonWrapperArguments)];
+
+  installPhase = ''
     mkdir -p $out/bin $out/share/${name}
-    sed -e 's@/usr/bin/@${a.python}/bin/@' -i irc.py
+    sed -e 's@/usr/bin/@${python}/bin/@' -i irc.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.pyIRCt.xml"]' -i config.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.python-irc-transport.xml"]' -i config.py
     sed -e '/configFiles/iimport os' -i config.py
-    cp * $out/share/$name
-    echo "#! /bin/sh" > $out/bin/pyIRCt
-    echo "cd $out/share/${name}" >> $out/bin/pyIRCt
-    echo "./irc.py \"$@\"" >> $out/bin/pyIRCt
+    cp * $out/share/${name}
+    cat > $out/bin/pyIRCt <<EOF
+      #!${stdenv.shell}
+      cd $out/share/${name}
+      ./irc.py \"$@\"
+    EOF
     chmod a+rx  $out/bin/pyIRCt $out/share/${name}/irc.py
-  '') ["minInit" "addInputs" "doUnpack" "defEnsureDir"];
+    wrapPythonPrograms
+  '';
 
-  name = "pyIRCt-" + version;
   meta = {
     description = "IRC transport module for XMPP";
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/servers/xmpp/pyMAILt/default.nix b/pkgs/servers/xmpp/pyMAILt/default.nix
index eb4f55f7aebd..aeed7484f82e 100644
--- a/pkgs/servers/xmpp/pyMAILt/default.nix
+++ b/pkgs/servers/xmpp/pyMAILt/default.nix
@@ -1,40 +1,39 @@
-a @ { xmpppy, python, makeWrapper, fetchcvs, ... } :
-let
-  fetchurl = a.fetchurl;
+{ stdenv, python, xmpppy, pythonPackages, fetchcvs } :
 
-  buildInputs = with a; [
-    xmpppy python makeWrapper
-  ];
-in
-rec {
-  src = a.fetchcvs {
+stdenv.mkDerivation rec {
+  name = "pyMAILt-${version}";
+  version = "20090101";
+
+  src = fetchcvs {
 		cvsRoot = ":pserver:anonymous@xmpppy.cvs.sourceforge.net:/cvsroot/xmpppy";
 		module = "xmpppy/mail-transport";
 		date = "2009-01-01";
 		sha256 = "15301252e52b4ccb2156baefed8982a2a0cce3ae8eae3caf3cc28dfa615c8d6e";
 	};
 
-  inherit buildInputs;
-  configureFlags = [];
+  pythonPath = [ xmpppy ];
+  buildInputs = [ pythonPackages.wrapPython ];
 
   /* doConfigure should be removed if not needed */
-  phaseNames = ["deploy" (a.makeManyWrappers "$out/share/${name}/mail.py" a.pythonWrapperArguments)];
-  deploy = a.fullDepEntry (''
+  installPhase = ''
     cd mail-transport
     mkdir -p $out/bin $out/share/${name}
-    sed -e 's@/usr/bin/@${a.python}/bin/@' -i mail.py
+    sed -e 's@/usr/bin/@${python}/bin/@' -i mail.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.pyMAILt.xml"]' -i config.py
     sed -e '/configFiles/aconfigFiles += [os.getenv("HOME")+"/.python-mail-transport.xml"]' -i config.py
     sed -e '/configFiles/iimport os' -i config.py
     cp * $out/share/$name
-    echo "#! /bin/sh" > $out/bin/pyMAILt
-    echo "cd $out/share/${name}" >> $out/bin/pyMAILt
-    echo "./mail.py \"$@\"" >> $out/bin/pyMAILt
+    cat > $out/bin/pyMAILt <<EOF
+      #!${stdenv.shell}
+      cd $out/share/${name}
+      ./mail.py \"$@\"
+    EOF
     chmod a+rx  $out/bin/pyMAILt $out/share/${name}/mail.py
-  '') ["minInit" "addInputs" "doUnpack" "defEnsureDir"];
+    wrapPythonPrograms
+  '';
 
-  name = "pyMAILt-20090101";
   meta = {
     description = "Email transport module for XMPP";
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/servers/zookeeper/default.nix b/pkgs/servers/zookeeper/default.nix
index 307993a958ad..c382061f1ef6 100644
--- a/pkgs/servers/zookeeper/default.nix
+++ b/pkgs/servers/zookeeper/default.nix
@@ -1,36 +1,54 @@
-{ stdenv, fetchurl, jre, makeWrapper, bash }:
+{ stdenv, fetchurl, jre, makeWrapper, bash, coreutils }:
 
 stdenv.mkDerivation rec {
-	name = "zookeeper-3.4.6";
-
-	src = fetchurl {
-		url = "mirror://apache/zookeeper/${name}/${name}.tar.gz";
-		sha256 = "01b3938547cd620dc4c93efe07c0360411f4a66962a70500b163b59014046994";
-	};
-
-	buildInputs = [ makeWrapper jre ];
-
-	phases = ["unpackPhase" "installPhase"];
-
-	installPhase = ''
-		mkdir -p $out
-		cp -R conf docs lib ${name}.jar $out
-		mkdir -p $out/bin
-		cp -R bin/{zkCli,zkCleanup,zkEnv}.sh $out/bin
-		for i in $out/bin/{zkCli,zkCleanup}.sh; do
-			wrapProgram $i \
-				--set JAVA_HOME "${jre}" \
-				--prefix PATH : "${bash}/bin"
-		done
-                chmod -x $out/bin/zkEnv.sh
-	'';
-
-	meta = with stdenv.lib; {
-		homepage = "http://zookeeper.apache.org";
-		description = "Apache Zookeeper";
-		license = licenses.asl20;
-		maintainers = [ maintainers.nathan-gs ];	
-		platforms = platforms.unix;	
-	};		
+  name = "zookeeper-${version}";
+  version = "3.4.12";
 
+  src = fetchurl {
+    url = "mirror://apache/zookeeper/${name}/${name}.tar.gz";
+    sha256 = "1fcljn2741jw1jvjrk5a0xr8rk69wjwrq522wrc5nmjhj0qzk1n6";
+  };
+
+  buildInputs = [ makeWrapper jre ];
+
+  phases = ["unpackPhase" "installPhase"];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -R conf docs lib ${name}.jar $out
+    mkdir -p $out/bin
+    cp -R bin/{zkCli,zkCleanup,zkEnv,zkServer}.sh $out/bin
+    for i in $out/bin/{zkCli,zkCleanup}.sh; do
+      wrapProgram $i \
+        --set JAVA_HOME "${jre}" \
+        --prefix PATH : "${bash}/bin"
+    done
+    substituteInPlace $out/bin/zkServer.sh \
+        --replace /bin/echo ${coreutils}/bin/echo \
+        --replace "/usr/bin/env bash" ${bash}/bin/bash
+    chmod -x $out/bin/zkEnv.sh
+
+    mkdir -p $out/share/zooinspector
+    cp -r contrib/ZooInspector/{${name}-ZooInspector.jar,icons,lib,config} $out/share/zooinspector
+
+    classpath="$out/${name}.jar:$out/share/zooinspector/${name}-ZooInspector.jar"
+    for jar in $out/lib/*.jar $out/share/zooinspector/lib/*.jar; do
+      classpath="$classpath:$jar"
+    done
+
+    cat << EOF > $out/bin/zooInspector.sh
+    #!${stdenv.shell}
+    cd $out/share/zooinspector
+    exec ${jre}/bin/java -cp $classpath org.apache.zookeeper.inspector.ZooInspector
+    EOF
+    chmod +x $out/bin/zooInspector.sh
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://zookeeper.apache.org;
+    description = "Apache Zookeeper";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ nathan-gs cstrahan pradeepchhetri ];
+    platforms = platforms.unix;
+  };
 }