systemd service: add aliases option

This commit is contained in:
Nikolay Amiantov 2017-02-02 00:51:16 +03:00
parent dd934beb9f
commit 8ef14f80e3
3 changed files with 21 additions and 9 deletions

View File

@ -159,7 +159,13 @@ rec {
fi
done
# Created .wants and .requires symlinks from the wantedBy and
# Create service aliases from aliases option.
${concatStrings (mapAttrsToList (name: unit:
concatMapStrings (name2: ''
ln -sfn '${name}' $out/'${name2}'
'') unit.aliases) units)}
# Create .wants and .requires symlinks from the wantedBy and
# requiredBy options.
${concatStrings (mapAttrsToList (name: unit:
concatMapStrings (name2: ''

View File

@ -52,6 +52,12 @@ in rec {
description = "Units that want (i.e. depend on) this unit.";
};
aliases = mkOption {
default = [];
type = types.listOf types.str;
description = "Aliases of that unit.";
};
};
concreteUnitOptions = sharedOptions // {

View File

@ -301,7 +301,7 @@ let
'';
targetToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text =
''
[Unit]
@ -310,7 +310,7 @@ let
};
serviceToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Service]
@ -330,7 +330,7 @@ let
};
socketToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Socket]
@ -340,7 +340,7 @@ let
};
timerToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Timer]
@ -349,7 +349,7 @@ let
};
pathToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Path]
@ -358,7 +358,7 @@ let
};
mountToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Mount]
@ -367,7 +367,7 @@ let
};
automountToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Automount]
@ -376,7 +376,7 @@ let
};
sliceToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
{ inherit (def) aliases wantedBy requiredBy enable;
text = commonUnitText def +
''
[Slice]