Merge pull request #152372 from symphorien/systemd-validate-after

nixos/systemd: validate the values of systemd.services.<name>.after

authored by

Guillaume Girol and committed by
GitHub
d6f45aa6 27d57625

+15 -12
+3
nixos/lib/systemd-lib.nix
··· 11 12 mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""]; 13 14 makeUnit = name: unit: 15 if unit.enable then 16 pkgs.runCommand "unit-${mkPathSafeName name}"
··· 11 12 mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""]; 13 14 + # a type for options that take a unit name 15 + unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)"; 16 + 17 makeUnit = name: unit: 18 if unit.enable then 19 pkgs.runCommand "unit-${mkPathSafeName name}"
+12 -12
nixos/lib/systemd-unit-options.nix
··· 45 46 requiredBy = mkOption { 47 default = []; 48 - type = types.listOf types.str; 49 description = '' 50 Units that require (i.e. depend on and need to go down with) 51 this unit. The discussion under <literal>wantedBy</literal> ··· 56 57 wantedBy = mkOption { 58 default = []; 59 - type = types.listOf types.str; 60 description = '' 61 Units that want (i.e. depend on) this unit. The standard way 62 to make a unit start by default at boot is to set this option ··· 73 74 aliases = mkOption { 75 default = []; 76 - type = types.listOf types.str; 77 description = "Aliases of that unit."; 78 }; 79 ··· 110 111 requires = mkOption { 112 default = []; 113 - type = types.listOf types.str; 114 description = '' 115 Start the specified units when this unit is started, and stop 116 this unit when the specified units are stopped or fail. ··· 119 120 wants = mkOption { 121 default = []; 122 - type = types.listOf types.str; 123 description = '' 124 Start the specified units when this unit is started. 125 ''; ··· 127 128 after = mkOption { 129 default = []; 130 - type = types.listOf types.str; 131 description = '' 132 If the specified units are started at the same time as 133 this unit, delay this unit until they have started. ··· 136 137 before = mkOption { 138 default = []; 139 - type = types.listOf types.str; 140 description = '' 141 If the specified units are started at the same time as 142 this unit, delay them until this unit has started. ··· 145 146 bindsTo = mkOption { 147 default = []; 148 - type = types.listOf types.str; 149 description = '' 150 Like ‘requires’, but in addition, if the specified units 151 unexpectedly disappear, this unit will be stopped as well. ··· 154 155 partOf = mkOption { 156 default = []; 157 - type = types.listOf types.str; 158 description = '' 159 If the specified units are stopped or restarted, then this 160 unit is stopped or restarted as well. ··· 163 164 conflicts = mkOption { 165 default = []; 166 - type = types.listOf types.str; 167 description = '' 168 If the specified units are started, then this unit is stopped 169 and vice versa. ··· 172 173 requisite = mkOption { 174 default = []; 175 - type = types.listOf types.str; 176 description = '' 177 Similar to requires. However if the units listed are not started, 178 they will not be started and the transaction will fail. ··· 203 204 onFailure = mkOption { 205 default = []; 206 - type = types.listOf types.str; 207 description = '' 208 A list of one or more units that are activated when 209 this unit enters the "failed" state.
··· 45 46 requiredBy = mkOption { 47 default = []; 48 + type = types.listOf unitNameType; 49 description = '' 50 Units that require (i.e. depend on and need to go down with) 51 this unit. The discussion under <literal>wantedBy</literal> ··· 56 57 wantedBy = mkOption { 58 default = []; 59 + type = types.listOf unitNameType; 60 description = '' 61 Units that want (i.e. depend on) this unit. The standard way 62 to make a unit start by default at boot is to set this option ··· 73 74 aliases = mkOption { 75 default = []; 76 + type = types.listOf unitNameType; 77 description = "Aliases of that unit."; 78 }; 79 ··· 110 111 requires = mkOption { 112 default = []; 113 + type = types.listOf unitNameType; 114 description = '' 115 Start the specified units when this unit is started, and stop 116 this unit when the specified units are stopped or fail. ··· 119 120 wants = mkOption { 121 default = []; 122 + type = types.listOf unitNameType; 123 description = '' 124 Start the specified units when this unit is started. 125 ''; ··· 127 128 after = mkOption { 129 default = []; 130 + type = types.listOf unitNameType; 131 description = '' 132 If the specified units are started at the same time as 133 this unit, delay this unit until they have started. ··· 136 137 before = mkOption { 138 default = []; 139 + type = types.listOf unitNameType; 140 description = '' 141 If the specified units are started at the same time as 142 this unit, delay them until this unit has started. ··· 145 146 bindsTo = mkOption { 147 default = []; 148 + type = types.listOf unitNameType; 149 description = '' 150 Like ‘requires’, but in addition, if the specified units 151 unexpectedly disappear, this unit will be stopped as well. ··· 154 155 partOf = mkOption { 156 default = []; 157 + type = types.listOf unitNameType; 158 description = '' 159 If the specified units are stopped or restarted, then this 160 unit is stopped or restarted as well. ··· 163 164 conflicts = mkOption { 165 default = []; 166 + type = types.listOf unitNameType; 167 description = '' 168 If the specified units are started, then this unit is stopped 169 and vice versa. ··· 172 173 requisite = mkOption { 174 default = []; 175 + type = types.listOf unitNameType; 176 description = '' 177 Similar to requires. However if the units listed are not started, 178 they will not be started and the transaction will fail. ··· 203 204 onFailure = mkOption { 205 default = []; 206 + type = types.listOf unitNameType; 207 description = '' 208 A list of one or more units that are activated when 209 this unit enters the "failed" state.