Merge pull request #115 from bjornfor/lighttpd-service

Add lighttpd web server module
This commit is contained in:
Rok Garbas 2013-03-03 23:32:37 -08:00
commit 162fd7d568
2 changed files with 90 additions and 0 deletions

View File

@ -179,6 +179,7 @@
./services/ttys/agetty.nix
./services/web-servers/apache-httpd/default.nix
./services/web-servers/jboss/default.nix
./services/web-servers/lighttpd.nix
./services/web-servers/nginx/default.nix
./services/web-servers/tomcat.nix
./services/x11/desktop-managers/default.nix

View File

@ -0,0 +1,89 @@
# NixOS module for lighttpd web server
{ config, pkgs, ... }:
with pkgs.lib;
let
cfg = config.services.lighttpd;
in
{
options = {
services.lighttpd = {
enable = mkOption {
default = false;
type = types.uniq types.bool;
description = ''
Enable the lighttpd web server. You must configure it with
services.lighttpd.configText.
'';
};
configText = mkOption {
default = "";
type = types.string;
example = ''
server.document-root = "/srv/www/"
server.port = 80
server.username = "lighttpd"
server.groupname = "lighttpd"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )
'';
description = ''
Contents of lighttpd configuration file. The user and group
"lighttpd" is available for privilege separation. See configuration
tutorial at
http://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration
or full documentation at
http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.lighttpd = {
description = "Lighttpd Web Server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "${pkgs.lighttpd}/sbin/lighttpd -D -f /etc/lighttpd.conf";
# SIGINT => graceful shutdown
serviceConfig.KillSignal = "SIGINT";
};
environment.etc =
[
{ source = pkgs.writeText "lighttpd.conf"
''
${cfg.configText}
'';
target = "lighttpd.conf";
}
];
users.extraUsers.lighttpd = {
group = "lighttpd";
description = "lighttpd web server privilege separation user";
};
users.extraGroups.lighttpd = {};
};
}