···11111212 mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""];
13131414+ # a type for options that take a unit name
1515+ unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)";
1616+1417 makeUnit = name: unit:
1518 if unit.enable then
1619 pkgs.runCommand "unit-${mkPathSafeName name}"
+12-12
nixos/lib/systemd-unit-options.nix
···45454646 requiredBy = mkOption {
4747 default = [];
4848- type = types.listOf types.str;
4848+ type = types.listOf unitNameType;
4949 description = ''
5050 Units that require (i.e. depend on and need to go down with)
5151 this unit. The discussion under <literal>wantedBy</literal>
···56565757 wantedBy = mkOption {
5858 default = [];
5959- type = types.listOf types.str;
5959+ type = types.listOf unitNameType;
6060 description = ''
6161 Units that want (i.e. depend on) this unit. The standard way
6262 to make a unit start by default at boot is to set this option
···73737474 aliases = mkOption {
7575 default = [];
7676- type = types.listOf types.str;
7676+ type = types.listOf unitNameType;
7777 description = "Aliases of that unit.";
7878 };
7979···110110111111 requires = mkOption {
112112 default = [];
113113- type = types.listOf types.str;
113113+ type = types.listOf unitNameType;
114114 description = ''
115115 Start the specified units when this unit is started, and stop
116116 this unit when the specified units are stopped or fail.
···119119120120 wants = mkOption {
121121 default = [];
122122- type = types.listOf types.str;
122122+ type = types.listOf unitNameType;
123123 description = ''
124124 Start the specified units when this unit is started.
125125 '';
···127127128128 after = mkOption {
129129 default = [];
130130- type = types.listOf types.str;
130130+ type = types.listOf unitNameType;
131131 description = ''
132132 If the specified units are started at the same time as
133133 this unit, delay this unit until they have started.
···136136137137 before = mkOption {
138138 default = [];
139139- type = types.listOf types.str;
139139+ type = types.listOf unitNameType;
140140 description = ''
141141 If the specified units are started at the same time as
142142 this unit, delay them until this unit has started.
···145145146146 bindsTo = mkOption {
147147 default = [];
148148- type = types.listOf types.str;
148148+ type = types.listOf unitNameType;
149149 description = ''
150150 Like ‘requires’, but in addition, if the specified units
151151 unexpectedly disappear, this unit will be stopped as well.
···154154155155 partOf = mkOption {
156156 default = [];
157157- type = types.listOf types.str;
157157+ type = types.listOf unitNameType;
158158 description = ''
159159 If the specified units are stopped or restarted, then this
160160 unit is stopped or restarted as well.
···163163164164 conflicts = mkOption {
165165 default = [];
166166- type = types.listOf types.str;
166166+ type = types.listOf unitNameType;
167167 description = ''
168168 If the specified units are started, then this unit is stopped
169169 and vice versa.
···172172173173 requisite = mkOption {
174174 default = [];
175175- type = types.listOf types.str;
175175+ type = types.listOf unitNameType;
176176 description = ''
177177 Similar to requires. However if the units listed are not started,
178178 they will not be started and the transaction will fail.
···203203204204 onFailure = mkOption {
205205 default = [];
206206- type = types.listOf types.str;
206206+ type = types.listOf unitNameType;
207207 description = ''
208208 A list of one or more units that are activated when
209209 this unit enters the "failed" state.