nixos/systemd: validate the values of systemd.services.<name>.after
and similar option. Notably check that they end with one of .service, .target, etc.
This commit is contained in:
parent
cb372c3b88
commit
2a37dd8ab3
2 changed files with 15 additions and 12 deletions
|
@ -11,6 +11,9 @@ in rec {
|
||||||
|
|
||||||
mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""];
|
mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""];
|
||||||
|
|
||||||
|
# a type for options that take a unit name
|
||||||
|
unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)";
|
||||||
|
|
||||||
makeUnit = name: unit:
|
makeUnit = name: unit:
|
||||||
if unit.enable then
|
if unit.enable then
|
||||||
pkgs.runCommand "unit-${mkPathSafeName name}"
|
pkgs.runCommand "unit-${mkPathSafeName name}"
|
||||||
|
|
|
@ -45,7 +45,7 @@ in rec {
|
||||||
|
|
||||||
requiredBy = mkOption {
|
requiredBy = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
Units that require (i.e. depend on and need to go down with)
|
Units that require (i.e. depend on and need to go down with)
|
||||||
this unit. The discussion under <literal>wantedBy</literal>
|
this unit. The discussion under <literal>wantedBy</literal>
|
||||||
|
@ -56,7 +56,7 @@ in rec {
|
||||||
|
|
||||||
wantedBy = mkOption {
|
wantedBy = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
Units that want (i.e. depend on) this unit. The standard way
|
Units that want (i.e. depend on) this unit. The standard way
|
||||||
to make a unit start by default at boot is to set this option
|
to make a unit start by default at boot is to set this option
|
||||||
|
@ -73,7 +73,7 @@ in rec {
|
||||||
|
|
||||||
aliases = mkOption {
|
aliases = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = "Aliases of that unit.";
|
description = "Aliases of that unit.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ in rec {
|
||||||
|
|
||||||
requires = mkOption {
|
requires = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
Start the specified units when this unit is started, and stop
|
Start the specified units when this unit is started, and stop
|
||||||
this unit when the specified units are stopped or fail.
|
this unit when the specified units are stopped or fail.
|
||||||
|
@ -119,7 +119,7 @@ in rec {
|
||||||
|
|
||||||
wants = mkOption {
|
wants = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
Start the specified units when this unit is started.
|
Start the specified units when this unit is started.
|
||||||
'';
|
'';
|
||||||
|
@ -127,7 +127,7 @@ in rec {
|
||||||
|
|
||||||
after = mkOption {
|
after = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
If the specified units are started at the same time as
|
If the specified units are started at the same time as
|
||||||
this unit, delay this unit until they have started.
|
this unit, delay this unit until they have started.
|
||||||
|
@ -136,7 +136,7 @@ in rec {
|
||||||
|
|
||||||
before = mkOption {
|
before = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
If the specified units are started at the same time as
|
If the specified units are started at the same time as
|
||||||
this unit, delay them until this unit has started.
|
this unit, delay them until this unit has started.
|
||||||
|
@ -145,7 +145,7 @@ in rec {
|
||||||
|
|
||||||
bindsTo = mkOption {
|
bindsTo = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
Like ‘requires’, but in addition, if the specified units
|
Like ‘requires’, but in addition, if the specified units
|
||||||
unexpectedly disappear, this unit will be stopped as well.
|
unexpectedly disappear, this unit will be stopped as well.
|
||||||
|
@ -154,7 +154,7 @@ in rec {
|
||||||
|
|
||||||
partOf = mkOption {
|
partOf = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
If the specified units are stopped or restarted, then this
|
If the specified units are stopped or restarted, then this
|
||||||
unit is stopped or restarted as well.
|
unit is stopped or restarted as well.
|
||||||
|
@ -163,7 +163,7 @@ in rec {
|
||||||
|
|
||||||
conflicts = mkOption {
|
conflicts = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
If the specified units are started, then this unit is stopped
|
If the specified units are started, then this unit is stopped
|
||||||
and vice versa.
|
and vice versa.
|
||||||
|
@ -172,7 +172,7 @@ in rec {
|
||||||
|
|
||||||
requisite = mkOption {
|
requisite = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
Similar to requires. However if the units listed are not started,
|
Similar to requires. However if the units listed are not started,
|
||||||
they will not be started and the transaction will fail.
|
they will not be started and the transaction will fail.
|
||||||
|
@ -203,7 +203,7 @@ in rec {
|
||||||
|
|
||||||
onFailure = mkOption {
|
onFailure = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf types.str;
|
type = types.listOf unitNameType;
|
||||||
description = ''
|
description = ''
|
||||||
A list of one or more units that are activated when
|
A list of one or more units that are activated when
|
||||||
this unit enters the "failed" state.
|
this unit enters the "failed" state.
|
||||||
|
|
Loading…
Reference in a new issue