From d0c68bc9ab4aa7618b508777767ab1dd6aaa4199 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Mon, 5 Oct 2009 18:31:27 +0000 Subject: [PATCH] adding jobAttrs which is filled from jobs contents Purpose: Allow overwriding of properties such as: config.jobAttrs.sshd.startOn = "never"; thanks to Nicolas Pierron for reviewing and extending nixpkgs to make this possible I'll convert most of the jobs ASAP so please don't care about the depreceateion much right now svn path=/nixos/trunk/; revision=17650 --- modules/system/upstart/upstart.nix | 69 ++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix index cdf96d7cb79f..c6fcd7f81e81 100644 --- a/modules/system/upstart/upstart.nix +++ b/modules/system/upstart/upstart.nix @@ -76,7 +76,7 @@ let jobs = [pkgs.upstart] # for the built-in logd job - ++ map makeJob (config.jobs ++ config.services.extraJobs); + ++ (map makeJob (mapAttrsFlatten (name: job: job // { inherit name; } ) config.jobAttrs)); # Create an etc/event.d directory containing symlinks to the # specified list of Upstart job files. @@ -94,24 +94,7 @@ let done ''; # */ -in - -{ - - ###### interface - - options = { - - jobs = mkOption { - default = []; - description = '' - This option defines the system jobs started and managed by the - Upstart daemon. - ''; - - type = types.list types.optionSet; - - options = { + listJobOptions = { name = mkOption { type = types.string; @@ -250,6 +233,44 @@ in }; }; + + attrJobOptions = builtins.removeAttrs listJobOptions ["name"]; + +in + +{ + + ###### interface + + options = { + + jobAttrs = mkOption { + default = {}; + description = '' + This option defines the system jobs started and managed by the + Upstart daemon. + + It's filled by config.jobs by now. A warning is print. + + You can overwrite settings easily. Example: + + config.jobAttrs.sshd.startOn = "never"; + ''; + + options = attrJobOptions; + type = types.attrsOf types.optionSet; + }; + + + jobs = mkOption { + default = []; + description = '' + See jobAttrs + ''; + + type = types.list types.optionSet; + + options = listJobOptions; }; @@ -277,6 +298,16 @@ in config = { + # add jobs of list style. If there are some print deprecation message + jobAttrs = + let deprecatedJobDefs = config.jobs ++ config.services.extraJobs; + jobList = concatStringsSep ", " (map (j: j.name) deprecatedJobDefs); + jobs = if deprecatedJobDefs != [] then + builtins.trace "Make the following jobs use jobAttrs please. Using jobs is depreceated: ${jobList}" + deprecatedJobDefs + else deprecatedJobDefs; + in builtins.listToAttrs (map (job: { inherit (job) name; value = builtins.removeAttrs job ["name"]; }) jobs); + environment.etc = [ { # The Upstart events defined above. source = "${jobsDir}/etc/event.d";