* Got rid of the extraPath field in jobs (use
environment.systemPackages instead). Also renamed services.extraJobs to jobs. svn path=/nixos/branches/modular-nixos/; revision=16370
This commit is contained in:
parent
def0be732f
commit
ca8e00cafa
8 changed files with 544 additions and 554 deletions
|
@ -1,51 +1,7 @@
|
|||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
mysql = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the MySQL server.
|
||||
";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
default = "3306";
|
||||
description = "Port of MySQL";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "mysql";
|
||||
description = "User account under which MySQL runs";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
default = "/var/mysql";
|
||||
description = "Location where MySQL stores its table files";
|
||||
};
|
||||
|
||||
logError = mkOption {
|
||||
default = "/var/log/mysql_err.log";
|
||||
description = "Location of the MySQL error logfile";
|
||||
};
|
||||
|
||||
pidDir = mkOption {
|
||||
default = "/var/run/mysql";
|
||||
description = "Location of the file which stores the PID of the MySQL server";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf singleton;
|
||||
|
||||
cfg = config.services.mysql;
|
||||
|
||||
|
@ -59,26 +15,64 @@ let
|
|||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
mkIf config.services.mysql.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
###### interface
|
||||
|
||||
users = {
|
||||
extraUsers = [
|
||||
{ name = "mysql";
|
||||
description = "MySQL server user";
|
||||
}
|
||||
];
|
||||
options = {
|
||||
|
||||
services.mysql = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the MySQL server.
|
||||
";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
default = "3306";
|
||||
description = "Port of MySQL";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "mysql";
|
||||
description = "User account under which MySQL runs";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
default = "/var/mysql";
|
||||
description = "Location where MySQL stores its table files";
|
||||
};
|
||||
|
||||
logError = mkOption {
|
||||
default = "/var/log/mysql_err.log";
|
||||
description = "Location of the MySQL error logfile";
|
||||
};
|
||||
|
||||
pidDir = mkOption {
|
||||
default = "/var/run/mysql";
|
||||
description = "Location of the file which stores the PID of the MySQL server";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
name = "mysql";
|
||||
|
||||
|
||||
extraPath = [mysql];
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.services.mysql.enable {
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = "mysql";
|
||||
description = "MySQL server user";
|
||||
};
|
||||
|
||||
environment.systemPackages = [mysql];
|
||||
|
||||
jobs = singleton {
|
||||
name = "mysql";
|
||||
|
||||
job = ''
|
||||
description "MySQL server"
|
||||
|
@ -104,6 +98,8 @@ mkIf config.services.mysql.enable {
|
|||
${mysql}/bin/mysql_waitpid "$pid" 1000
|
||||
end script
|
||||
'';
|
||||
}];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,80 +1,7 @@
|
|||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
postgresql = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to run PostgreSQL.
|
||||
";
|
||||
};
|
||||
port = mkOption {
|
||||
default = "5432";
|
||||
description = "
|
||||
Port for PostgreSQL.
|
||||
";
|
||||
};
|
||||
logDir = mkOption {
|
||||
default = "/var/log/postgresql";
|
||||
description = "
|
||||
Log directory for PostgreSQL.
|
||||
";
|
||||
};
|
||||
dataDir = mkOption {
|
||||
default = "/var/db/postgresql";
|
||||
description = "
|
||||
Data directory for PostgreSQL.
|
||||
";
|
||||
};
|
||||
subServices = mkOption {
|
||||
default = [];
|
||||
description = "
|
||||
Subservices list. As it is already implememnted,
|
||||
here is an interface...
|
||||
";
|
||||
};
|
||||
authentication = mkOption {
|
||||
default = ''
|
||||
# Generated file; do not edit!
|
||||
local all all ident sameuser
|
||||
host all all 127.0.0.1/32 md5
|
||||
host all all ::1/128 md5
|
||||
'';
|
||||
description = "
|
||||
Hosts (except localhost), who you allow to connect.
|
||||
";
|
||||
};
|
||||
allowedHosts = mkOption {
|
||||
default = [];
|
||||
description = "
|
||||
Hosts (except localhost), who you allow to connect.
|
||||
";
|
||||
};
|
||||
authMethod = mkOption {
|
||||
default = " ident sameuser ";
|
||||
description = "
|
||||
How to authorize users.
|
||||
Note: ident needs absolute trust to all allowed client hosts.";
|
||||
};
|
||||
enableTCPIP = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to run PostgreSQL with -i flag to enable TCP/IP connections.
|
||||
";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf singleton;
|
||||
|
||||
cfg = config.services.postgresql;
|
||||
|
||||
|
@ -83,35 +10,111 @@ let
|
|||
startDependency = if config.services.gw6c.enable then
|
||||
"gw6c" else "network-interfaces";
|
||||
|
||||
run = "${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh postgres";
|
||||
run = "${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} postgres";
|
||||
|
||||
flags = if cfg.enableTCPIP then ["-i"] else [];
|
||||
|
||||
in
|
||||
|
||||
mkIf config.services.postgresql.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
services.postgresql = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to run PostgreSQL.
|
||||
'';
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
default = "5432";
|
||||
description = ''
|
||||
Port for PostgreSQL.
|
||||
'';
|
||||
};
|
||||
|
||||
logDir = mkOption {
|
||||
default = "/var/log/postgresql";
|
||||
description = ''
|
||||
Log directory for PostgreSQL.
|
||||
'';
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
default = "/var/db/postgresql";
|
||||
description = ''
|
||||
Data directory for PostgreSQL.
|
||||
'';
|
||||
};
|
||||
|
||||
subServices = mkOption {
|
||||
default = [];
|
||||
description = ''
|
||||
Subservices list. As it is already implememnted,
|
||||
here is an interface...
|
||||
'';
|
||||
};
|
||||
|
||||
authentication = mkOption {
|
||||
default = ''
|
||||
# Generated file; do not edit!
|
||||
local all all ident sameuser
|
||||
host all all 127.0.0.1/32 md5
|
||||
host all all ::1/128 md5
|
||||
'';
|
||||
description = ''
|
||||
Hosts (except localhost), who you allow to connect.
|
||||
'';
|
||||
};
|
||||
|
||||
allowedHosts = mkOption {
|
||||
default = [];
|
||||
description = ''
|
||||
Hosts (except localhost), who you allow to connect.
|
||||
'';
|
||||
};
|
||||
|
||||
authMethod = mkOption {
|
||||
default = " ident sameuser ";
|
||||
description = ''
|
||||
How to authorize users.
|
||||
Note: ident needs absolute trust to all allowed client hosts.
|
||||
'';
|
||||
};
|
||||
|
||||
enableTCPIP = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to run PostgreSQL with -i flag to enable TCP/IP connections.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
users = {
|
||||
extraUsers = [
|
||||
{ name = "postgres";
|
||||
description = "PostgreSQL server user";
|
||||
}
|
||||
];
|
||||
|
||||
extraGroups = [
|
||||
{ name = "postgres"; }
|
||||
];
|
||||
};
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
name = "postgresql";
|
||||
|
||||
extraPath = [postgresql];
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.services.postgresql.enable {
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = "postgres";
|
||||
description = "PostgreSQL server user";
|
||||
};
|
||||
|
||||
users.extraGroups = singleton
|
||||
{ name = "postgres"; };
|
||||
|
||||
environment.systemPackages = [postgresql];
|
||||
|
||||
jobs = singleton {
|
||||
name = "postgresql";
|
||||
|
||||
job = ''
|
||||
description "PostgreSQL server"
|
||||
|
@ -130,6 +133,8 @@ mkIf config.services.postgresql.enable {
|
|||
|
||||
respawn ${run} -c '${postgresql}/bin/postgres -D ${cfg.dataDir} ${toString flags}'
|
||||
'';
|
||||
}];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,49 +1,7 @@
|
|||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption
|
||||
mergeEnableOption mergeListOption;
|
||||
|
||||
options = {
|
||||
networking = {
|
||||
useDHCP = mkOption {
|
||||
default = true;
|
||||
merge = mergeEnableOption;
|
||||
description = "
|
||||
Whether to use DHCP to obtain an IP adress and other
|
||||
configuration for all network interfaces that are not manually
|
||||
configured.
|
||||
";
|
||||
};
|
||||
|
||||
interfaces = mkOption {
|
||||
default = [];
|
||||
merge = mergeListOption;
|
||||
example = [
|
||||
{ name = "eth0";
|
||||
ipAddress = "131.211.84.78";
|
||||
subnetMask = "255.255.255.128";
|
||||
}
|
||||
];
|
||||
description = "
|
||||
The configuration for each network interface. If
|
||||
<option>networking.useDHCP</option> is true, then each interface
|
||||
not listed here will be configured using DHCP.
|
||||
";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
|
||||
ifEnable = arg:
|
||||
if config.networking.useDHCP then arg
|
||||
else if builtins.isList arg then []
|
||||
else if builtins.isAttrs arg then {}
|
||||
else null;
|
||||
inherit (pkgs.lib) mkOption mkIf mergeEnableOption mergeListOption;
|
||||
|
||||
inherit (pkgs) nettools dhcp lib;
|
||||
|
||||
|
@ -80,55 +38,90 @@ let
|
|||
in
|
||||
|
||||
{
|
||||
require = [
|
||||
#../upstart-jobs/default.nix
|
||||
options
|
||||
];
|
||||
|
||||
services.extraJobs = ifEnable [{
|
||||
name = "dhclient";
|
||||
###### interface
|
||||
|
||||
extraPath = [dhcp];
|
||||
options = {
|
||||
|
||||
networking.useDHCP = mkOption {
|
||||
default = true;
|
||||
merge = mergeEnableOption;
|
||||
description = "
|
||||
Whether to use DHCP to obtain an IP adress and other
|
||||
configuration for all network interfaces that are not manually
|
||||
configured.
|
||||
";
|
||||
};
|
||||
|
||||
networking.interfaces = mkOption {
|
||||
default = [];
|
||||
merge = mergeListOption;
|
||||
example = [
|
||||
{ name = "eth0";
|
||||
ipAddress = "131.211.84.78";
|
||||
subnetMask = "255.255.255.128";
|
||||
}
|
||||
];
|
||||
description = "
|
||||
The configuration for each network interface. If
|
||||
<option>networking.useDHCP</option> is true, then each interface
|
||||
not listed here will be configured using DHCP.
|
||||
";
|
||||
};
|
||||
|
||||
job = ''
|
||||
description "DHCP client"
|
||||
};
|
||||
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
|
||||
env PATH_DHCLIENT_SCRIPT=${dhcp}/sbin/dhclient-script
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.networking.useDHCP {
|
||||
|
||||
script
|
||||
export PATH=${nettools}/sbin:$PATH
|
||||
jobs = pkgs.lib.singleton {
|
||||
name = "dhclient";
|
||||
|
||||
# Determine the interface on which to start dhclient.
|
||||
interfaces=
|
||||
job = ''
|
||||
description "DHCP client"
|
||||
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
if ! for j in ${toString ignoredInterfaces}; do echo $j; done | grep -F -x -q "$i"; then
|
||||
echo "Running dhclient on $i"
|
||||
interfaces="$interfaces $i"
|
||||
fi
|
||||
done
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
|
||||
if test -z "$interfaces"; then
|
||||
echo 'No interfaces on which to start dhclient!'
|
||||
exit 1
|
||||
fi
|
||||
env PATH_DHCLIENT_SCRIPT=${dhcp}/sbin/dhclient-script
|
||||
|
||||
mkdir -m 755 -p ${stateDir}
|
||||
script
|
||||
export PATH=${nettools}/sbin:$PATH
|
||||
|
||||
exec ${dhcp}/sbin/dhclient -d $interfaces -e "PATH=$PATH" -lf ${stateDir}/dhclient.leases
|
||||
end script
|
||||
'';
|
||||
}];
|
||||
# Determine the interface on which to start dhclient.
|
||||
interfaces=
|
||||
|
||||
environment.etc = ifEnable
|
||||
[ # Dhclient hooks for emitting ip-up/ip-down events.
|
||||
{ source = dhclientExitHooks;
|
||||
target = "dhclient-exit-hooks";
|
||||
}
|
||||
];
|
||||
for i in $(cd /sys/class/net && ls -d *); do
|
||||
if ! for j in ${toString ignoredInterfaces}; do echo $j; done | grep -F -x -q "$i"; then
|
||||
echo "Running dhclient on $i"
|
||||
interfaces="$interfaces $i"
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$interfaces"; then
|
||||
echo 'No interfaces on which to start dhclient!'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -m 755 -p ${stateDir}
|
||||
|
||||
exec ${dhcp}/sbin/dhclient -d $interfaces -e "PATH=$PATH" -lf ${stateDir}/dhclient.leases
|
||||
end script
|
||||
'';
|
||||
};
|
||||
|
||||
environment.systemPackages = [dhcp];
|
||||
|
||||
environment.etc =
|
||||
[ # Dhclient hooks for emitting ip-up/ip-down events.
|
||||
{ source = dhclientExitHooks;
|
||||
target = "dhclient-exit-hooks";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,68 +1,62 @@
|
|||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
options = {
|
||||
networking = {
|
||||
interfaceMonitor = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
If <literal>true</literal>, monitor Ethernet interfaces for
|
||||
cables being plugged in or unplugged. When this occurs, the
|
||||
<command>dhclient</command> service is restarted to
|
||||
automatically obtain a new IP address. This is useful for
|
||||
roaming users (laptops).
|
||||
";
|
||||
};
|
||||
|
||||
beep = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
If <literal>true</literal>, beep when an Ethernet cable is
|
||||
plugged in or unplugged.
|
||||
";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
|
||||
let
|
||||
|
||||
inherit (pkgs) ifplugd writeScript bash;
|
||||
inherit (pkgs) ifplugd;
|
||||
|
||||
# The ifplugd action script, which is called whenever the link
|
||||
# status changes (i.e., a cable is plugged in or unplugged). We do
|
||||
# nothing when a cable is unplugged. When a cable is plugged in, we
|
||||
# restart dhclient, which will hopefully give us a new IP address
|
||||
# if appropriate.
|
||||
plugScript = writeScript "ifplugd.action" "#! ${bash}/bin/sh
|
||||
if test \"$2\" = up; then
|
||||
initctl stop dhclient
|
||||
sleep 1
|
||||
initctl start dhclient
|
||||
fi
|
||||
";
|
||||
plugScript = pkgs.writeScript "ifplugd.action"
|
||||
''
|
||||
#! ${pkgs.stdenv.shell}
|
||||
if test "$2" = up; then
|
||||
initctl stop dhclient
|
||||
sleep 1
|
||||
initctl start dhclient
|
||||
fi
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
mkIf config.networking.interfaceMonitor.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
{
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
networking.interfaceMonitor.enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
If <literal>true</literal>, monitor Ethernet interfaces for
|
||||
cables being plugged in or unplugged. When this occurs, the
|
||||
<command>dhclient</command> service is restarted to
|
||||
automatically obtain a new IP address. This is useful for
|
||||
roaming users (laptops).
|
||||
";
|
||||
};
|
||||
|
||||
networking.interfaceMonitor.beep = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
If <literal>true</literal>, beep when an Ethernet cable is
|
||||
plugged in or unplugged.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.networking.interfaceMonitor.enable {
|
||||
|
||||
jobs = pkgs.lib.singleton {
|
||||
name = "ifplugd";
|
||||
|
||||
extraPath = [ifplugd];
|
||||
|
||||
job = ''
|
||||
description "Network interface connectivity monitor"
|
||||
|
||||
|
@ -73,6 +67,10 @@ mkIf config.networking.interfaceMonitor.enable {
|
|||
${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \
|
||||
--run ${plugScript}
|
||||
'';
|
||||
}];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ifplugd];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,202 +1,8 @@
|
|||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
with pkgs.lib;
|
||||
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
httpd = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the Apache httpd server.
|
||||
";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
default = "";
|
||||
description = "
|
||||
These configuration lines will be passed verbatim to the apache config
|
||||
";
|
||||
};
|
||||
|
||||
extraModules = mkOption {
|
||||
default = [];
|
||||
example = [ "proxy_connect" { name = "php5_module"; path = "${pkgs.php}/modules/libphp5.so"; } ];
|
||||
description = ''
|
||||
Specifies additional Apache modules. These can be specified
|
||||
as a string in the case of modules distributed with Apache,
|
||||
or as an attribute set specifying the
|
||||
<varname>name</varname> and <varname>path</varname> of the
|
||||
module.
|
||||
'';
|
||||
};
|
||||
|
||||
logPerVirtualHost = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
If enabled, each virtual host gets its own
|
||||
<filename>access_log</filename> and
|
||||
<filename>error_log</filename>, namely suffixed by the
|
||||
<option>hostName</option> of the virtual host.
|
||||
";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "wwwrun";
|
||||
description = "
|
||||
User account under which httpd runs. The account is created
|
||||
automatically if it doesn't exist.
|
||||
";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
default = "wwwrun";
|
||||
description = "
|
||||
Group under which httpd runs. The account is created
|
||||
automatically if it doesn't exist.
|
||||
";
|
||||
};
|
||||
|
||||
logDir = mkOption {
|
||||
default = "/var/log/httpd";
|
||||
description = "
|
||||
Directory for Apache's log files. It is created automatically.
|
||||
";
|
||||
};
|
||||
|
||||
stateDir = mkOption {
|
||||
default = "/var/run/httpd";
|
||||
description = "
|
||||
Directory for Apache's transient runtime state (such as PID
|
||||
files). It is created automatically. Note that the default,
|
||||
<filename>/var/run/httpd</filename>, is deleted at boot time.
|
||||
";
|
||||
};
|
||||
|
||||
mod_php = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable the PHP module.";
|
||||
};
|
||||
|
||||
mod_jk = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable the Apache Tomcat connector.";
|
||||
};
|
||||
|
||||
applicationMappings = mkOption {
|
||||
default = [];
|
||||
description = "List of Java webapplications that should be mapped to the servlet container (Tomcat/JBoss)";
|
||||
};
|
||||
};
|
||||
|
||||
virtualHosts = mkOption {
|
||||
default = [];
|
||||
example = [
|
||||
{ hostName = "foo";
|
||||
documentRoot = "/data/webroot-foo";
|
||||
}
|
||||
{ hostName = "bar";
|
||||
documentRoot = "/data/webroot-bar";
|
||||
}
|
||||
];
|
||||
description = ''
|
||||
Specification of the virtual hosts served by Apache. Each
|
||||
element should be an attribute set specifying the
|
||||
configuration of the virtual host. The available options
|
||||
are the non-global options permissible for the main host.
|
||||
'';
|
||||
};
|
||||
|
||||
subservices = {
|
||||
|
||||
# !!! remove this
|
||||
subversion = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the Subversion subservice in the webserver.
|
||||
";
|
||||
};
|
||||
|
||||
notificationSender = mkOption {
|
||||
default = "svn-server@example.org";
|
||||
example = "svn-server@example.org";
|
||||
description = "
|
||||
The email address used in the Sender field of commit
|
||||
notification messages sent by the Subversion subservice.
|
||||
";
|
||||
};
|
||||
|
||||
userCreationDomain = mkOption {
|
||||
default = "example.org";
|
||||
example = "example.org";
|
||||
description = "
|
||||
The domain from which user creation is allowed. A client can
|
||||
only create a new user account if its IP address resolves to
|
||||
this domain.
|
||||
";
|
||||
};
|
||||
|
||||
autoVersioning = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether you want the Subversion subservice to support
|
||||
auto-versioning, which enables Subversion repositories to be
|
||||
mounted as read/writable file systems on operating systems that
|
||||
support WebDAV.
|
||||
";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
default = "/no/such/path/exists";
|
||||
description = "
|
||||
Place to put SVN repository.
|
||||
";
|
||||
};
|
||||
|
||||
organization = {
|
||||
|
||||
name = mkOption {
|
||||
default = null;
|
||||
description = "
|
||||
Name of the organization hosting the Subversion service.
|
||||
";
|
||||
};
|
||||
|
||||
url = mkOption {
|
||||
default = null;
|
||||
description = "
|
||||
URL of the website of the organization hosting the Subversion service.
|
||||
";
|
||||
};
|
||||
|
||||
logo = mkOption {
|
||||
default = null;
|
||||
description = "
|
||||
Logo the organization hosting the Subversion service.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
} // # Include the options shared between the main server and virtual hosts.
|
||||
(import ./per-server-options.nix {
|
||||
inherit mkOption;
|
||||
forMainServer = true;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
mainCfg = config.services.httpd;
|
||||
|
||||
|
@ -204,15 +10,13 @@ let
|
|||
|
||||
httpd = pkgs.apacheHttpd;
|
||||
|
||||
inherit (pkgs.lib) addDefaultOptionValues optional concatMap concatMapStrings;
|
||||
|
||||
|
||||
getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80;
|
||||
|
||||
extraModules = pkgs.lib.attrByPath ["extraModules"] [] mainCfg;
|
||||
extraForeignModules = pkgs.lib.filter builtins.isAttrs extraModules;
|
||||
extraApacheModules = pkgs.lib.filter (x: !(builtins.isAttrs x)) extraModules; # I'd prefer using builtins.isString here, but doesn't exist yet
|
||||
extraModules = attrByPath ["extraModules"] [] mainCfg;
|
||||
extraForeignModules = filter builtins.isAttrs extraModules;
|
||||
extraApacheModules = filter (x: !(builtins.isAttrs x)) extraModules; # I'd prefer using builtins.isString here, but doesn't exist yet
|
||||
|
||||
|
||||
makeServerInfo = cfg: {
|
||||
# Canonical name must not include a trailing slash.
|
||||
canonicalName =
|
||||
|
@ -231,7 +35,7 @@ let
|
|||
|
||||
|
||||
vhostOptions = import ./per-server-options.nix {
|
||||
inherit (pkgs.lib) mkOption;
|
||||
inherit mkOption;
|
||||
forMainServer = false;
|
||||
};
|
||||
|
||||
|
@ -276,7 +80,7 @@ let
|
|||
|
||||
mainSubservices = subservicesFor mainCfg;
|
||||
|
||||
allSubservices = mainSubservices ++ pkgs.lib.concatMap subservicesFor vhosts;
|
||||
allSubservices = mainSubservices ++ concatMap subservicesFor vhosts;
|
||||
|
||||
|
||||
# !!! should be in lib
|
||||
|
@ -284,7 +88,7 @@ let
|
|||
pkgs.runCommand name {inherit text;} "ensureDir $out; echo -n \"$text\" > $out/$name";
|
||||
|
||||
|
||||
enableSSL = pkgs.lib.any (vhost: vhost.enableSSL) allHosts;
|
||||
enableSSL = any (vhost: vhost.enableSSL) allHosts;
|
||||
|
||||
|
||||
# Names of modules from ${httpd}/modules that we want to load.
|
||||
|
@ -484,7 +288,7 @@ let
|
|||
|
||||
${let
|
||||
ports = map getPort allHosts;
|
||||
uniquePorts = pkgs.lib.uniqList {inputList = ports;};
|
||||
uniquePorts = uniqList {inputList = ports;};
|
||||
in concatMapStrings (port: "Listen ${toString port}\n") uniquePorts
|
||||
}
|
||||
|
||||
|
@ -540,7 +344,7 @@ let
|
|||
# Always enable virtual hosts; it doesn't seem to hurt.
|
||||
${let
|
||||
ports = map getPort allHosts;
|
||||
uniquePorts = pkgs.lib.uniqList {inputList = ports;};
|
||||
uniquePorts = uniqList {inputList = ports;};
|
||||
in concatMapStrings (port: "NameVirtualHost *:${toString port}\n") uniquePorts
|
||||
}
|
||||
|
||||
|
@ -558,28 +362,222 @@ let
|
|||
in
|
||||
|
||||
|
||||
mkIf config.services.httpd.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
{
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
services.httpd = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the Apache httpd server.
|
||||
";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
default = "";
|
||||
description = "
|
||||
These configuration lines will be passed verbatim to the apache config
|
||||
";
|
||||
};
|
||||
|
||||
extraModules = mkOption {
|
||||
default = [];
|
||||
example = [ "proxy_connect" { name = "php5_module"; path = "${pkgs.php}/modules/libphp5.so"; } ];
|
||||
description = ''
|
||||
Specifies additional Apache modules. These can be specified
|
||||
as a string in the case of modules distributed with Apache,
|
||||
or as an attribute set specifying the
|
||||
<varname>name</varname> and <varname>path</varname> of the
|
||||
module.
|
||||
'';
|
||||
};
|
||||
|
||||
logPerVirtualHost = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
If enabled, each virtual host gets its own
|
||||
<filename>access_log</filename> and
|
||||
<filename>error_log</filename>, namely suffixed by the
|
||||
<option>hostName</option> of the virtual host.
|
||||
";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "wwwrun";
|
||||
description = "
|
||||
User account under which httpd runs. The account is created
|
||||
automatically if it doesn't exist.
|
||||
";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
default = "wwwrun";
|
||||
description = "
|
||||
Group under which httpd runs. The account is created
|
||||
automatically if it doesn't exist.
|
||||
";
|
||||
};
|
||||
|
||||
logDir = mkOption {
|
||||
default = "/var/log/httpd";
|
||||
description = "
|
||||
Directory for Apache's log files. It is created automatically.
|
||||
";
|
||||
};
|
||||
|
||||
stateDir = mkOption {
|
||||
default = "/var/run/httpd";
|
||||
description = "
|
||||
Directory for Apache's transient runtime state (such as PID
|
||||
files). It is created automatically. Note that the default,
|
||||
<filename>/var/run/httpd</filename>, is deleted at boot time.
|
||||
";
|
||||
};
|
||||
|
||||
mod_php = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable the PHP module.";
|
||||
};
|
||||
|
||||
mod_jk = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable the Apache Tomcat connector.";
|
||||
};
|
||||
|
||||
applicationMappings = mkOption {
|
||||
default = [];
|
||||
description = "List of Java webapplications that should be mapped to the servlet container (Tomcat/JBoss)";
|
||||
};
|
||||
};
|
||||
|
||||
virtualHosts = mkOption {
|
||||
default = [];
|
||||
example = [
|
||||
{ hostName = "foo";
|
||||
documentRoot = "/data/webroot-foo";
|
||||
}
|
||||
{ hostName = "bar";
|
||||
documentRoot = "/data/webroot-bar";
|
||||
}
|
||||
];
|
||||
description = ''
|
||||
Specification of the virtual hosts served by Apache. Each
|
||||
element should be an attribute set specifying the
|
||||
configuration of the virtual host. The available options
|
||||
are the non-global options permissible for the main host.
|
||||
'';
|
||||
};
|
||||
|
||||
subservices = {
|
||||
|
||||
# !!! remove this
|
||||
subversion = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the Subversion subservice in the webserver.
|
||||
";
|
||||
};
|
||||
|
||||
notificationSender = mkOption {
|
||||
default = "svn-server@example.org";
|
||||
example = "svn-server@example.org";
|
||||
description = "
|
||||
The email address used in the Sender field of commit
|
||||
notification messages sent by the Subversion subservice.
|
||||
";
|
||||
};
|
||||
|
||||
userCreationDomain = mkOption {
|
||||
default = "example.org";
|
||||
example = "example.org";
|
||||
description = "
|
||||
The domain from which user creation is allowed. A client can
|
||||
only create a new user account if its IP address resolves to
|
||||
this domain.
|
||||
";
|
||||
};
|
||||
|
||||
autoVersioning = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether you want the Subversion subservice to support
|
||||
auto-versioning, which enables Subversion repositories to be
|
||||
mounted as read/writable file systems on operating systems that
|
||||
support WebDAV.
|
||||
";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
default = "/no/such/path/exists";
|
||||
description = "
|
||||
Place to put SVN repository.
|
||||
";
|
||||
};
|
||||
|
||||
organization = {
|
||||
|
||||
name = mkOption {
|
||||
default = null;
|
||||
description = "
|
||||
Name of the organization hosting the Subversion service.
|
||||
";
|
||||
};
|
||||
|
||||
url = mkOption {
|
||||
default = null;
|
||||
description = "
|
||||
URL of the website of the organization hosting the Subversion service.
|
||||
";
|
||||
};
|
||||
|
||||
logo = mkOption {
|
||||
default = null;
|
||||
description = "
|
||||
Logo the organization hosting the Subversion service.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
# Include the options shared between the main server and virtual hosts.
|
||||
// (import ./per-server-options.nix {
|
||||
inherit mkOption;
|
||||
forMainServer = true;
|
||||
});
|
||||
|
||||
users = {
|
||||
extraUsers = [
|
||||
{ name = mainCfg.user;
|
||||
description = "Apache httpd user";
|
||||
}
|
||||
];
|
||||
extraGroups = [
|
||||
{ name = mainCfg.group;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
name = "httpd";
|
||||
|
||||
extraPath = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices;
|
||||
###### implementation
|
||||
|
||||
config = mkIf config.services.httpd.enable {
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = mainCfg.user;
|
||||
description = "Apache httpd user";
|
||||
};
|
||||
|
||||
users.extraGroups = singleton
|
||||
{ name = mainCfg.group;
|
||||
};
|
||||
|
||||
environment.systemPackages = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices;
|
||||
|
||||
jobs = singleton {
|
||||
name = "httpd";
|
||||
|
||||
# Statically verify the syntactic correctness of the generated
|
||||
# httpd.conf. !!! this is impure! It doesn't just check for
|
||||
|
@ -617,15 +615,16 @@ mkIf config.services.httpd.enable {
|
|||
|
||||
${
|
||||
let f = {name, value}: "env ${name}=${value}\n";
|
||||
in concatMapStrings f (pkgs.lib.concatMap (svc: svc.globalEnvVars) allSubservices)
|
||||
in concatMapStrings f (concatMap (svc: svc.globalEnvVars) allSubservices)
|
||||
}
|
||||
|
||||
env PATH=${pkgs.coreutils}/bin:${pkgs.gnugrep}/bin:${pkgs.lib.concatStringsSep ":" (pkgs.lib.concatMap (svc: svc.extraServerPath) allSubservices)}
|
||||
env PATH=${pkgs.coreutils}/bin:${pkgs.gnugrep}/bin:${concatStringsSep ":" (concatMap (svc: svc.extraServerPath) allSubservices)}
|
||||
|
||||
respawn ${httpd}/bin/httpd -f ${httpdConf} -DNO_DETACH
|
||||
'';
|
||||
|
||||
}];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
//
|
||||
|
||||
{
|
||||
# Allow jobs to declare extra packages that should be added to the
|
||||
# system path.
|
||||
extraPath = if job ? extraPath then job.extraPath else [];
|
||||
|
||||
# Allow jobs to declare user accounts that should be created.
|
||||
users = if job ? users then job.users else [];
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ let
|
|||
|
||||
inherit (pkgs.lib) mkOption mergeListOption;
|
||||
|
||||
jobs = map makeJob config.services.extraJobs;
|
||||
jobs = map makeJob (config.jobs ++ config.services.extraJobs);
|
||||
|
||||
# Create an etc/event.d directory containing symlinks to the
|
||||
# specified list of Upstart job files.
|
||||
|
@ -34,7 +34,7 @@ in
|
|||
|
||||
options = {
|
||||
|
||||
services.extraJobs = mkOption {
|
||||
jobs = mkOption {
|
||||
default = [];
|
||||
example =
|
||||
[ { name = "test-job";
|
||||
|
@ -50,7 +50,16 @@ in
|
|||
# should have some checks to verify the syntax
|
||||
merge = pkgs.lib.mergeListOption;
|
||||
description = ''
|
||||
Additional Upstart jobs.
|
||||
This option defines the system jobs started and managed by the
|
||||
Upstart daemon.
|
||||
'';
|
||||
};
|
||||
|
||||
services.extraJobs = mkOption {
|
||||
default = [];
|
||||
merge = pkgs.lib.mergeListOption;
|
||||
description = ''
|
||||
Obsolete - don't use.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -78,9 +87,6 @@ in
|
|||
}
|
||||
];
|
||||
|
||||
environment.extraPackages =
|
||||
pkgs.lib.concatLists (map (job: job.extraPath) jobs);
|
||||
|
||||
users.extraUsers =
|
||||
pkgs.lib.concatLists (map (job: job.users) jobs);
|
||||
|
||||
|
|
|
@ -2,12 +2,26 @@
|
|||
|
||||
let
|
||||
|
||||
###### interface
|
||||
# think about where to put this chunk of code!
|
||||
# required by other pieces as well
|
||||
requiredTTYs = config.services.mingetty.ttys
|
||||
++ config.boot.extraTTYs
|
||||
++ [config.services.syslogd.tty];
|
||||
ttyNumbers = requiredTTYs;
|
||||
ttys = map (nr: "/dev/tty" + toString nr) ttyNumbers;
|
||||
defaultLocale = config.i18n.defaultLocale;
|
||||
consoleFont = config.i18n.consoleFont;
|
||||
consoleKeyMap = config.i18n.consoleKeyMap;
|
||||
|
||||
# most options are defined in i18n.nix
|
||||
in
|
||||
|
||||
{
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
# most options are defined in i18n.nix
|
||||
|
||||
boot.extraTTYs = pkgs.lib.mkOption {
|
||||
default = [];
|
||||
example = [8 9];
|
||||
|
@ -29,38 +43,21 @@ let
|
|||
FIXME: find a good description.
|
||||
";
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
|
||||
config = {
|
||||
|
||||
###### implementation
|
||||
inherit requiredTTYs; # pass it to ./modules/tasks/tty-backgrounds.nix
|
||||
|
||||
# think about where to put this chunk of code!
|
||||
# required by other pieces as well
|
||||
requiredTTYs = config.services.mingetty.ttys
|
||||
++ config.boot.extraTTYs
|
||||
++ [config.services.syslogd.tty];
|
||||
ttyNumbers = requiredTTYs;
|
||||
ttys = map (nr: "/dev/tty" + toString nr) ttyNumbers;
|
||||
defaultLocale = config.i18n.defaultLocale;
|
||||
consoleFont = config.i18n.consoleFont;
|
||||
consoleKeyMap = config.i18n.consoleKeyMap;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
require = [options];
|
||||
|
||||
inherit requiredTTYs; # pass them to ./modules/tasks/tty-backgrounds.nix
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
environment.systemPackages = [pkgs.kbd];
|
||||
|
||||
jobs = pkgs.lib.singleton {
|
||||
name = "kbd";
|
||||
|
||||
extraPath = [
|
||||
pkgs.kbd
|
||||
];
|
||||
|
||||
job = ''
|
||||
description "Keyboard / console initialisation"
|
||||
|
||||
|
@ -74,7 +71,7 @@ in
|
|||
|
||||
set +e # continue in case of errors
|
||||
|
||||
|
||||
|
||||
# Enable or disable UTF-8 mode. This is based on
|
||||
# unicode_{start,stop}.
|
||||
echo 'Enabling or disabling Unicode mode...'
|
||||
|
@ -122,8 +119,8 @@ in
|
|||
|
||||
end script
|
||||
'';
|
||||
|
||||
}];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue