0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-12 05:16:25 +03:00

* 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:
Eelco Dolstra 2009-07-15 11:19:11 +00:00
parent def0be732f
commit ca8e00cafa
8 changed files with 544 additions and 554 deletions

View file

@ -1,12 +1,28 @@
{pkgs, config, ...}: {pkgs, config, ...}:
###### interface
let let
inherit (pkgs.lib) mkOption mkIf; inherit (pkgs.lib) mkOption mkIf singleton;
cfg = config.services.mysql;
mysql = pkgs.mysql;
pidFile = "${cfg.pidDir}/mysqld.pid";
mysqldOptions =
"--user=${cfg.user} --datadir=${cfg.dataDir} " +
"--log-error=${cfg.logError} --pid-file=${pidFile}";
in
{
###### interface
options = { options = {
services = {
mysql = { services.mysql = {
enable = mkOption { enable = mkOption {
default = false; default = false;
description = " description = "
@ -38,48 +54,26 @@ let
default = "/var/run/mysql"; default = "/var/run/mysql";
description = "Location of the file which stores the PID of the MySQL server"; description = "Location of the file which stores the PID of the MySQL server";
}; };
}; };
}; };
};
in
###### implementation ###### implementation
let config = mkIf config.services.mysql.enable {
cfg = config.services.mysql; users.extraUsers = singleton
mysql = pkgs.mysql;
pidFile = "${cfg.pidDir}/mysqld.pid";
mysqldOptions =
"--user=${cfg.user} --datadir=${cfg.dataDir} " +
"--log-error=${cfg.logError} --pid-file=${pidFile}";
in
mkIf config.services.mysql.enable {
require = [
options
];
users = {
extraUsers = [
{ name = "mysql"; { name = "mysql";
description = "MySQL server user"; description = "MySQL server user";
}
];
}; };
services = { environment.systemPackages = [mysql];
extraJobs = [{
jobs = singleton {
name = "mysql"; name = "mysql";
extraPath = [mysql];
job = '' job = ''
description "MySQL server" description "MySQL server"
@ -104,6 +98,8 @@ mkIf config.services.mysql.enable {
${mysql}/bin/mysql_waitpid "$pid" 1000 ${mysql}/bin/mysql_waitpid "$pid" 1000
end script end script
''; '';
}];
}; };
};
} }

View file

@ -1,80 +1,7 @@
{pkgs, config, ...}: {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 let
inherit (pkgs.lib) mkOption mkIf singleton;
cfg = config.services.postgresql; cfg = config.services.postgresql;
@ -83,35 +10,111 @@ let
startDependency = if config.services.gw6c.enable then startDependency = if config.services.gw6c.enable then
"gw6c" else "network-interfaces"; "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 []; flags = if cfg.enableTCPIP then ["-i"] else [];
in in
mkIf config.services.postgresql.enable { {
require = [
options
];
###### interface
users = { options = {
extraUsers = [
{ name = "postgres";
description = "PostgreSQL server user";
}
];
extraGroups = [ services.postgresql = {
{ name = "postgres"; }
]; enable = mkOption {
default = false;
description = ''
Whether to run PostgreSQL.
'';
}; };
services = { port = mkOption {
extraJobs = [{ default = "5432";
name = "postgresql"; description = ''
Port for PostgreSQL.
'';
};
extraPath = [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.
'';
};
};
};
###### 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 = '' job = ''
description "PostgreSQL server" description "PostgreSQL server"
@ -130,6 +133,8 @@ mkIf config.services.postgresql.enable {
respawn ${run} -c '${postgresql}/bin/postgres -D ${cfg.dataDir} ${toString flags}' respawn ${run} -c '${postgresql}/bin/postgres -D ${cfg.dataDir} ${toString flags}'
''; '';
}];
}; };
};
} }

View file

@ -1,49 +1,7 @@
{pkgs, config, ...}: {pkgs, config, ...}:
###### interface
let let
inherit (pkgs.lib) mkOption inherit (pkgs.lib) mkOption mkIf mergeEnableOption mergeListOption;
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) nettools dhcp lib; inherit (pkgs) nettools dhcp lib;
@ -80,16 +38,47 @@ let
in in
{ {
require = [
#../upstart-jobs/default.nix ###### interface
options
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.
";
};
services.extraJobs = ifEnable [{ };
###### implementation
config = mkIf config.networking.useDHCP {
jobs = pkgs.lib.singleton {
name = "dhclient"; name = "dhclient";
extraPath = [dhcp];
job = '' job = ''
description "DHCP client" description "DHCP client"
@ -121,14 +110,18 @@ in
exec ${dhcp}/sbin/dhclient -d $interfaces -e "PATH=$PATH" -lf ${stateDir}/dhclient.leases exec ${dhcp}/sbin/dhclient -d $interfaces -e "PATH=$PATH" -lf ${stateDir}/dhclient.leases
end script end script
''; '';
}]; };
environment.etc = ifEnable environment.systemPackages = [dhcp];
environment.etc =
[ # Dhclient hooks for emitting ip-up/ip-down events. [ # Dhclient hooks for emitting ip-up/ip-down events.
{ source = dhclientExitHooks; { source = dhclientExitHooks;
target = "dhclient-exit-hooks"; target = "dhclient-exit-hooks";
} }
]; ];
};
} }

View file

@ -1,14 +1,34 @@
{pkgs, config, ...}: {pkgs, config, ...}:
###### interface
let let
inherit (pkgs.lib) mkOption mkIf; inherit (pkgs.lib) mkOption mkIf;
options = { inherit (pkgs) ifplugd;
networking = {
interfaceMonitor = {
enable = mkOption { # 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 = pkgs.writeScript "ifplugd.action"
''
#! ${pkgs.stdenv.shell}
if test "$2" = up; then
initctl stop dhclient
sleep 1
initctl start dhclient
fi
'';
in
{
###### interface
options = {
networking.interfaceMonitor.enable = mkOption {
default = false; default = false;
description = " description = "
If <literal>true</literal>, monitor Ethernet interfaces for If <literal>true</literal>, monitor Ethernet interfaces for
@ -19,50 +39,24 @@ let
"; ";
}; };
beep = mkOption { networking.interfaceMonitor.beep = mkOption {
default = false; default = false;
description = " description = "
If <literal>true</literal>, beep when an Ethernet cable is If <literal>true</literal>, beep when an Ethernet cable is
plugged in or unplugged. plugged in or unplugged.
"; ";
}; };
}; };
};
};
in
###### implementation ###### implementation
let config = mkIf config.networking.interfaceMonitor.enable {
inherit (pkgs) ifplugd writeScript bash; jobs = pkgs.lib.singleton {
# 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
";
in
mkIf config.networking.interfaceMonitor.enable {
require = [
options
];
services = {
extraJobs = [{
name = "ifplugd"; name = "ifplugd";
extraPath = [ifplugd];
job = '' job = ''
description "Network interface connectivity monitor" description "Network interface connectivity monitor"
@ -73,6 +67,10 @@ mkIf config.networking.interfaceMonitor.enable {
${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \ ${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \
--run ${plugScript} --run ${plugScript}
''; '';
}];
}; };
environment.systemPackages = [ifplugd];
};
} }

View file

@ -1,202 +1,8 @@
{pkgs, config, ...}: {pkgs, config, ...}:
###### interface with pkgs.lib;
let 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; mainCfg = config.services.httpd;
@ -204,14 +10,12 @@ let
httpd = pkgs.apacheHttpd; 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; getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80;
extraModules = pkgs.lib.attrByPath ["extraModules"] [] mainCfg; extraModules = attrByPath ["extraModules"] [] mainCfg;
extraForeignModules = pkgs.lib.filter builtins.isAttrs extraModules; extraForeignModules = 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 extraApacheModules = filter (x: !(builtins.isAttrs x)) extraModules; # I'd prefer using builtins.isString here, but doesn't exist yet
makeServerInfo = cfg: { makeServerInfo = cfg: {
# Canonical name must not include a trailing slash. # Canonical name must not include a trailing slash.
@ -231,7 +35,7 @@ let
vhostOptions = import ./per-server-options.nix { vhostOptions = import ./per-server-options.nix {
inherit (pkgs.lib) mkOption; inherit mkOption;
forMainServer = false; forMainServer = false;
}; };
@ -276,7 +80,7 @@ let
mainSubservices = subservicesFor mainCfg; mainSubservices = subservicesFor mainCfg;
allSubservices = mainSubservices ++ pkgs.lib.concatMap subservicesFor vhosts; allSubservices = mainSubservices ++ concatMap subservicesFor vhosts;
# !!! should be in lib # !!! should be in lib
@ -284,7 +88,7 @@ let
pkgs.runCommand name {inherit text;} "ensureDir $out; echo -n \"$text\" > $out/$name"; 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. # Names of modules from ${httpd}/modules that we want to load.
@ -484,7 +288,7 @@ let
${let ${let
ports = map getPort allHosts; ports = map getPort allHosts;
uniquePorts = pkgs.lib.uniqList {inputList = ports;}; uniquePorts = uniqList {inputList = ports;};
in concatMapStrings (port: "Listen ${toString port}\n") uniquePorts in concatMapStrings (port: "Listen ${toString port}\n") uniquePorts
} }
@ -540,7 +344,7 @@ let
# Always enable virtual hosts; it doesn't seem to hurt. # Always enable virtual hosts; it doesn't seem to hurt.
${let ${let
ports = map getPort allHosts; ports = map getPort allHosts;
uniquePorts = pkgs.lib.uniqList {inputList = ports;}; uniquePorts = uniqList {inputList = ports;};
in concatMapStrings (port: "NameVirtualHost *:${toString port}\n") uniquePorts in concatMapStrings (port: "NameVirtualHost *:${toString port}\n") uniquePorts
} }
@ -558,28 +362,222 @@ let
in in
mkIf config.services.httpd.enable { {
require = [
options
];
users = { ###### interface
extraUsers = [
{ name = mainCfg.user; options = {
description = "Apache httpd user";
} services.httpd = {
];
extraGroups = [ enable = mkOption {
{ name = mainCfg.group; default = false;
} description = "
]; Whether to enable the Apache httpd server.
";
}; };
services = { extraConfig = mkOption {
extraJobs = [{ default = "";
name = "httpd"; description = "
These configuration lines will be passed verbatim to the apache config
";
};
extraPath = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices; 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
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 # Statically verify the syntactic correctness of the generated
# httpd.conf. !!! this is impure! It doesn't just check for # 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"; 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 respawn ${httpd}/bin/httpd -f ${httpdConf} -DNO_DETACH
''; '';
}];
}; };
};
} }

View file

@ -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. # Allow jobs to declare user accounts that should be created.
users = if job ? users then job.users else []; users = if job ? users then job.users else [];

View file

@ -8,7 +8,7 @@ let
inherit (pkgs.lib) mkOption mergeListOption; 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 # Create an etc/event.d directory containing symlinks to the
# specified list of Upstart job files. # specified list of Upstart job files.
@ -34,7 +34,7 @@ in
options = { options = {
services.extraJobs = mkOption { jobs = mkOption {
default = []; default = [];
example = example =
[ { name = "test-job"; [ { name = "test-job";
@ -50,7 +50,16 @@ in
# should have some checks to verify the syntax # should have some checks to verify the syntax
merge = pkgs.lib.mergeListOption; merge = pkgs.lib.mergeListOption;
description = '' 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 = users.extraUsers =
pkgs.lib.concatLists (map (job: job.users) jobs); pkgs.lib.concatLists (map (job: job.users) jobs);

View file

@ -2,12 +2,26 @@
let let
# 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
{
###### interface ###### interface
# most options are defined in i18n.nix
options = { options = {
# most options are defined in i18n.nix
boot.extraTTYs = pkgs.lib.mkOption { boot.extraTTYs = pkgs.lib.mkOption {
default = []; default = [];
example = [8 9]; example = [8 9];
@ -35,32 +49,15 @@ let
###### implementation ###### implementation
# think about where to put this chunk of code! config = {
# 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 inherit requiredTTYs; # pass it to ./modules/tasks/tty-backgrounds.nix
{ environment.systemPackages = [pkgs.kbd];
require = [options];
inherit requiredTTYs; # pass them to ./modules/tasks/tty-backgrounds.nix jobs = pkgs.lib.singleton {
services = {
extraJobs = [{
name = "kbd"; name = "kbd";
extraPath = [
pkgs.kbd
];
job = '' job = ''
description "Keyboard / console initialisation" description "Keyboard / console initialisation"
@ -122,8 +119,8 @@ in
end script end script
''; '';
};
}];
}; };
} }