about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorMalte Brandy <malte.brandy@maralorn.de>2020-06-16 14:34:03 +0200
committerMalte Brandy <malte.brandy@maralorn.de>2020-06-16 22:10:12 +0200
commit0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb (patch)
tree287fe2412625edc7d0eb29830137e03a461d1eaf /nixos/modules/system
parentf1603aa18a123feb7796145db8f17afb992069a6 (diff)
downloadnixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.tar
nixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.tar.gz
nixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.tar.bz2
nixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.tar.lz
nixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.tar.xz
nixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.tar.zst
nixlib-0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb.zip
nixos/systemd: Update warning for restarting oneshots
Restart= can be anything other than on-success and always for onehost units as of
https://github.com/systemd/systemd/pull/13754/commits/10e72727eeeeb1a495303ec406fa8d1e1a83dc6e
which is contained in systemd 245.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/systemd.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 99892a28115c..a8e51fc09014 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -826,8 +826,13 @@ in
   config = {
 
     warnings = concatLists (mapAttrsToList (name: service:
-      optional (service.serviceConfig.Type or "" == "oneshot" && service.serviceConfig.Restart or "no" != "no")
-        "Service ‘${name}.service’ with ‘Type=oneshot’ must have ‘Restart=no’") cfg.services);
+      let
+        type = service.serviceConfig.Type or "";
+        restart = service.serviceConfig.Restart or "no";
+      in optional
+      (type == "oneshot" && (restart == "always" || restart == "on-success"))
+      "Service '${name}.service' with 'Type=oneshot' cannot have 'Restart=always' or 'Restart=on-success'")
+      cfg.services);
 
     system.build.units = cfg.units;