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 {
default = [];
types = types.listOf types.string;

View File

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

View File

@ -54,17 +54,20 @@ let
'';
in {
inherit (job) description requires wants before environment path;
inherit (job) description requires wants before partOf environment path;
after =
(if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.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}." []
) ++ job.after;
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 =
''