about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2020-06-16 23:35:22 +0200
committerGitHub <noreply@github.com>2020-06-16 23:35:22 +0200
commitd72530162a70aa8fdd10e8351a88c8f08ac14e8e (patch)
tree6d90b35a48229440005cb3a229d6dccc84abc465 /nixos/modules
parentdcf36b65c3f9c2753bc51d4e45fce4f98b823c31 (diff)
parent0d4134de4a3436fabf7ea8afbac3c0a3028d0fbb (diff)
downloadnixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.tar
nixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.tar.gz
nixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.tar.bz2
nixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.tar.lz
nixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.tar.xz
nixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.tar.zst
nixlib-d72530162a70aa8fdd10e8351a88c8f08ac14e8e.zip
Merge pull request #90604 from maralorn/systemd-oneshot-warning
nixos/systemd: Update warning for restarting oneshots
Diffstat (limited to 'nixos/modules')
-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;