* Refactoring the Upstart module. Got rid of job.extraEtc, it's

redundant now (modules can just define environment.etc).

svn path=/nixos/branches/modular-nixos/; revision=16367
This commit is contained in:
Eelco Dolstra 2009-07-15 09:06:36 +00:00
parent b66fd2364c
commit 118418ba31
4 changed files with 78 additions and 136 deletions

View File

@ -1,5 +1,4 @@
[ # This file has been generated by gen-module-list.sh
./config/fonts.nix
[ ./config/fonts.nix
./config/guest-users.nix
./config/i18n.nix
./config/ldap.nix
@ -75,31 +74,6 @@
./services/ttys/gpm.nix
./services/ttys/mingetty.nix
./services/web-servers/apache-httpd/default.nix
##### ./services/web-servers/apache-httpd/per-server-options.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./services/web-servers/apache-httpd/per-server-options.nix:6:2':
# the argument named `forMainServer' required by the function is missing
##### ./services/web-servers/apache-httpd/subversion.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./services/web-servers/apache-httpd/subversion.nix:1:2':
# the argument named `serverInfo' required by the function is missing
##### ./services/web-servers/apache-httpd/tomcat-connector.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./services/web-servers/apache-httpd/tomcat-connector.nix:1:2':
# the argument named `serverInfo' required by the function is missing
##### ./services/web-servers/apache-httpd/twiki.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./services/web-servers/apache-httpd/twiki.nix:1:2':
# the argument named `serverInfo' required by the function is missing
##### ./services/web-servers/apache-httpd/zabbix.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./services/web-servers/apache-httpd/zabbix.nix:1:2':
# the argument named `serverInfo' required by the function is missing
./services/web-servers/jboss.nix
./services/web-servers/tomcat.nix
./services/x11/xfs.nix
@ -128,20 +102,9 @@
./system/boot/stage-1.nix
./system/boot/stage-2.nix
./system/etc/etc.nix
##### ./system/etc/make-etc.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./system/etc/make-etc.nix:1:2':
# the argument named `stdenv' required by the function is missing
./system/upstart-events/ctrl-alt-delete.nix
./system/upstart-events/halt.nix
./system/upstart-events/maintenance-shell.nix
##### ./system/upstart/make-job.nix
# error: while evaluating the attribute `<let-body>' at `(string):2:8':
# while evaluating the function at `(string):3:22':
# while evaluating the function at `./system/upstart/make-job.nix:1:2':
# the argument named `runCommand' required by the function is missing
./system/upstart/tools.nix
./system/upstart/upstart.nix
./tasks/filesystems.nix
./tasks/kbd.nix

View File

@ -134,22 +134,21 @@ mkIf config.services.printing.enable {
options
];
services = {
extraJobs = [{
name = "cupsd";
environment.systemPackages = [cups];
extraPath = [cups];
environment.etc =
[ # CUPS expects the following files in its ServerRoot.
{ source = "${cups}/etc/cups/mime.convs";
target = "cups/mime.convs";
}
{ source = "${cups}/etc/cups/mime.types";
target = "cups/mime.types";
}
];
services.extraJobs = pkgs.lib.singleton
{ name = "cupsd";
extraEtc = [
# CUPS expects the following files in its ServerRoot.
{ source = "${cups}/etc/cups/mime.convs";
target = "cups/mime.convs";
}
{ source = "${cups}/etc/cups/mime.types";
target = "cups/mime.types";
}
];
job = ''
description "CUPS printing daemon"
@ -167,6 +166,5 @@ mkIf config.services.printing.enable {
respawn ${cups}/sbin/cupsd -c ${cupsdConfig} -F
'';
}];
};
};
}

View File

@ -21,9 +21,6 @@
# system path.
extraPath = if job ? extraPath then job.extraPath else [];
# Allow jobs to declare extra files that should be added to /etc.
extraEtc = if job ? extraEtc then job.extraEtc else [];
# Allow jobs to declare extra configuration for Apache (e.g. Nagios
# declaring its web interface).
extraHttpdConfig = if job ? extraHttpdConfig then job.extraHttpdConfig else "";

View File

@ -1,63 +1,13 @@
{config, pkgs, ...}:
###### interface
let
inherit (pkgs.lib) mkOption mapAttrs fold
mergeListOption mergeTypedOption mergeAttrsWithFunc;
options = {
services = {
extraJobs = mkOption {
default = [];
example = [
{ name = "test-job";
job = ''
description "nc"
start on started network-interfaces
respawn
env PATH=/var/run/current-system/sw/bin
exec sh -c "echo 'hello world' | ${pkgs.netcat}/bin/nc -l -p 9000"
'';
} ];
# should have some checks to verify the syntax
merge = pkgs.lib.mergeListOption;
description = "
Additional Upstart jobs.
";
};
tools = {
upstartJobs = mkOption {
default = {};
description = "
List of functions which can be used to create upstart-jobs.
";
};
};
};
tests = {
upstartJobs = mkOption {
internal = true;
default = {};
description = "
Make it easier to build individual Upstart jobs. (e.g.,
<command>nix-build /etc/nixos/nixos -A
tests.upstartJobs.xserver</command>).
";
};
};
};
in
###### implementation
let
makeJob = import ./make-job.nix {
inherit (pkgs) runCommand;
};
optional = cond: service: pkgs.lib.optional cond (makeJob service);
inherit (pkgs.lib) mkOption mergeListOption;
jobs = map makeJob config.services.extraJobs;
# Create an etc/event.d directory containing symlinks to the
@ -76,45 +26,79 @@ let
done
''; # */
in
in
{
require = [
options
./tools.nix # !!! doesn't seem to be used anywhere
];
environment = {
etc = [{ # The Upstart events defined above.
source = command + "/etc/event.d";
target = "event.d";
}]
++ pkgs.lib.concatLists (map (job: job.extraEtc) jobs);
###### interface
options = {
services.extraJobs = mkOption {
default = [];
example =
[ { name = "test-job";
job = ''
description "nc"
start on started network-interfaces
respawn
env PATH=/var/run/current-system/sw/bin
exec sh -c "echo 'hello world' | ${pkgs.netcat}/bin/nc -l -p 9000"
'';
}
];
# should have some checks to verify the syntax
merge = pkgs.lib.mergeListOption;
description = ''
Additional Upstart jobs.
'';
};
extraPackages =
pkgs.lib.concatLists (map (job: job.extraPath) jobs);
tests.upstartJobs = mkOption {
internal = true;
default = {};
description = ''
Make it easier to build individual Upstart jobs. (e.g.,
<command>nix-build /etc/nixos/nixos -A
tests.upstartJobs.xserver</command>).
'';
};
};
users = {
extraUsers =
###### implementation
config = {
environment.etc =
[ { # The Upstart events defined above.
source = command + "/etc/event.d";
target = "event.d";
}
];
environment.extraPackages =
pkgs.lib.concatLists (map (job: job.extraPath) jobs);
users.extraUsers =
pkgs.lib.concatLists (map (job: job.users) jobs);
extraGroups =
users.extraGroups =
pkgs.lib.concatLists (map (job: job.groups) jobs);
};
services = {
extraJobs = [
# For the built-in logd job.
{ jobDrv = pkgs.upstart; }
];
};
services.extraJobs =
[ # For the built-in logd job.
{ jobDrv = pkgs.upstart; }
];
tests = {
# see test/test-upstart-job.sh
upstartJobs = { recurseForDerivations = true; } //
# see test/test-upstart-job.sh (!!! check whether this still works)
tests.upstartJobs = { recurseForDerivations = true; } //
builtins.listToAttrs (map (job:
{ name = if job ? jobName then job.jobName else job.name; value = job; }
) jobs);
};
}