systemd: add "requiredBy" option.
"require" is a stronger version of "want", and just like wantedBy allows you to specify this relation in reverse, requiredBy does the same. It may seem pointless to be able to specify these stronger relations in reverse, because if something is really required, you would expect the other unit to specify this himself. However, this is still useful for virtual/automatic units (like devices) that are created by systemd on demand and hence have no unit file you can alter.
This commit is contained in:
parent
8c702b7c28
commit
8de00c328a
2 changed files with 22 additions and 5 deletions
|
@ -76,6 +76,12 @@ rec {
|
|||
'';
|
||||
};
|
||||
|
||||
requiredBy = mkOption {
|
||||
default = [];
|
||||
types = types.listOf types.string;
|
||||
description = "Units that require (i.e. depend on and need to go down with) this unit.";
|
||||
};
|
||||
|
||||
wantedBy = mkOption {
|
||||
default = [];
|
||||
types = types.listOf types.string;
|
||||
|
|
|
@ -211,7 +211,7 @@ let
|
|||
as));
|
||||
|
||||
targetToUnit = name: def:
|
||||
{ inherit (def) wantedBy enable;
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text =
|
||||
''
|
||||
[Unit]
|
||||
|
@ -220,7 +220,7 @@ let
|
|||
};
|
||||
|
||||
serviceToUnit = name: def:
|
||||
{ inherit (def) wantedBy enable;
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text =
|
||||
''
|
||||
[Unit]
|
||||
|
@ -267,7 +267,7 @@ let
|
|||
};
|
||||
|
||||
socketToUnit = name: def:
|
||||
{ inherit (def) wantedBy enable;
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text =
|
||||
''
|
||||
[Unit]
|
||||
|
@ -279,7 +279,7 @@ let
|
|||
};
|
||||
|
||||
timerToUnit = name: def:
|
||||
{ inherit (def) wantedBy enable;
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text =
|
||||
''
|
||||
[Unit]
|
||||
|
@ -291,7 +291,7 @@ let
|
|||
};
|
||||
|
||||
mountToUnit = name: def:
|
||||
{ inherit (def) wantedBy enable;
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text =
|
||||
''
|
||||
[Unit]
|
||||
|
@ -343,6 +343,12 @@ let
|
|||
ln -sfn ../${name} $out/${name2}.wants/
|
||||
'') unit.wantedBy) cfg.units)}
|
||||
|
||||
${concatStrings (mapAttrsToList (name: unit:
|
||||
concatMapStrings (name2: ''
|
||||
mkdir -p $out/${name2}.requires
|
||||
ln -sfn ../${name} $out/${name2}.requires/
|
||||
'') unit.requiredBy) cfg.units)}
|
||||
|
||||
ln -s ${cfg.defaultUnit} $out/default.target
|
||||
|
||||
ln -s rescue.target $out/kbrequest.target
|
||||
|
@ -387,6 +393,11 @@ in
|
|||
from being started.
|
||||
'';
|
||||
};
|
||||
requiredBy = mkOption {
|
||||
default = [];
|
||||
types = types.listOf types.string;
|
||||
description = "Units that require (i.e. depend on and need to go down with) this unit.";
|
||||
};
|
||||
wantedBy = mkOption {
|
||||
default = [];
|
||||
types = types.listOf types.string;
|
||||
|
|
Loading…
Reference in a new issue