summary refs log tree commit diff
path: root/nixos/lib/systemd-lib.nix
diff options
context:
space:
mode:
authorGuillaume Girol <symphorien+git@xlumurb.eu>2021-12-27 12:00:00 +0000
committerGuillaume Girol <symphorien+git@xlumurb.eu>2021-12-27 12:00:00 +0000
commit2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8 (patch)
tree49a987063b695ff6a5f4563c7e44f11020530dd3 /nixos/lib/systemd-lib.nix
parentcb372c3b8880e504b06946e8fb2ca9777c685505 (diff)
downloadnixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.tar
nixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.tar.gz
nixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.tar.bz2
nixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.tar.lz
nixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.tar.xz
nixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.tar.zst
nixpkgs-2a37dd8ab3c9fd8f703c7268de3ca3f130904bf8.zip
nixos/systemd: validate the values of systemd.services.<name>.after
and similar option. Notably check that they end with one of .service,
.target, etc.
Diffstat (limited to 'nixos/lib/systemd-lib.nix')
-rw-r--r--nixos/lib/systemd-lib.nix3
1 files changed, 3 insertions, 0 deletions
diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix
index 6c4d27018ee..52b33af9322 100644
--- a/nixos/lib/systemd-lib.nix
+++ b/nixos/lib/systemd-lib.nix
@@ -11,6 +11,9 @@ in rec {
 
   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:
     if unit.enable then
       pkgs.runCommand "unit-${mkPathSafeName name}"