Add support for PartOf dependencies

This commit is contained in:
Eelco Dolstra 2012-08-15 15:36:54 -04:00
parent c2b2a3369a
commit 981347429a
3 changed files with 17 additions and 4 deletions

View File

@ -47,6 +47,15 @@ with pkgs.lib;
''; '';
}; };
partOf = mkOption {
default = [];
types = types.listOf types.string;
description = ''
If the specified units are stopped or restarted, then this
unit is stopped or restarted as well.
'';
};
wantedBy = mkOption { wantedBy = mkOption {
default = []; default = [];
types = types.listOf types.string; types = types.listOf types.string;

View File

@ -191,8 +191,9 @@ let
''} ''}
Requires=${concatStringsSep " " def.requires} Requires=${concatStringsSep " " def.requires}
Wants=${concatStringsSep " " def.wants} Wants=${concatStringsSep " " def.wants}
Before=${concatStringsSep " " def.before}
After=${concatStringsSep " " def.after} After=${concatStringsSep " " def.after}
Before=${concatStringsSep " " def.before}
PartOf=${concatStringsSep " " def.partOf}
${def.unitConfig} ${def.unitConfig}
[Service] [Service]

View File

@ -54,17 +54,20 @@ let
''; '';
in { in {
inherit (job) description requires wants before environment path; inherit (job) description requires wants before partOf environment path;
after = after =
(if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.service" ] else (if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.service" ] else
if job.startOn == "started udev" then [ "systemd-udev.service" ] else if job.startOn == "started udev" then [ "systemd-udev.service" ] else
if job.startOn == "" || job.startOn == "startup" then [ ] else if job.startOn == "ip-up" then [] else
if job.startOn == "" || job.startOn == "startup" then [] else
builtins.trace "Warning: job ${job.name} has unknown startOn value ${job.startOn}." [] builtins.trace "Warning: job ${job.name} has unknown startOn value ${job.startOn}." []
) ++ job.after; ) ++ job.after;
wantedBy = wantedBy =
(if job.startOn == "" then [ ] else [ "multi-user.target" ]) ++ job.wantedBy; (if job.startOn == "" then [] else
if job.startOn == "ip-up" then [ "ip-up.target" ] else
[ "multi-user.target" ]) ++ job.wantedBy;
serviceConfig = serviceConfig =
'' ''