From 118418ba319ff15e4d52b0b5713be3289b1e8068 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 15 Jul 2009 09:06:36 +0000 Subject: [PATCH] * 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 --- modules/module-list.nix | 39 +------- modules/services/printing/cupsd.nix | 30 +++--- modules/system/upstart/make-job.nix | 3 - modules/system/upstart/upstart.nix | 142 ++++++++++++---------------- 4 files changed, 78 insertions(+), 136 deletions(-) diff --git a/modules/module-list.nix b/modules/module-list.nix index c806495c833f..750a39ba105b 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -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 `' 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 `' 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 `' 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 `' 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 `' 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 `' 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 `' 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 diff --git a/modules/services/printing/cupsd.nix b/modules/services/printing/cupsd.nix index b240b7c8a9c7..4f2bffe7773d 100644 --- a/modules/services/printing/cupsd.nix +++ b/modules/services/printing/cupsd.nix @@ -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 ''; - }]; - }; + }; } diff --git a/modules/system/upstart/make-job.nix b/modules/system/upstart/make-job.nix index df56b5dee290..26cce3af2a96 100644 --- a/modules/system/upstart/make-job.nix +++ b/modules/system/upstart/make-job.nix @@ -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 ""; diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix index ca9b6e2ddf5c..699fcc4c2f4f 100644 --- a/modules/system/upstart/upstart.nix +++ b/modules/system/upstart/upstart.nix @@ -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., - nix-build /etc/nixos/nixos -A - tests.upstartJobs.xserver). - "; - }; - }; - }; -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., + nix-build /etc/nixos/nixos -A + tests.upstartJobs.xserver). + ''; + }; + }; - 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); + }; + }