summary refs log tree commit diff
diff options
context:
space:
mode:
authorCraig Younkins <cyounkins@gmail.com>2018-11-20 17:34:43 +0000
committerCraig Younkins <cyounkins@gmail.com>2019-01-28 00:29:43 +0000
commit6f6287fbf9745edb0bf504497c0ab3a3dfedb993 (patch)
tree849ec461abaed90796a10c86df338cb0af490a9c
parentbf041c3f1d5e63e27b531faf69244fe99fcfd6c1 (diff)
downloadnixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.tar
nixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.tar.gz
nixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.tar.bz2
nixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.tar.lz
nixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.tar.xz
nixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.tar.zst
nixpkgs-6f6287fbf9745edb0bf504497c0ab3a3dfedb993.zip
nixos/systemd: add StartLimitIntervalSec to unit config
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix9
-rw-r--r--nixos/modules/system/boot/systemd.nix6
2 files changed, 13 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index 5f2bec5c34a..63f974b704f 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -210,6 +210,15 @@ in rec {
       '';
     };
 
+    startLimitIntervalSec = mkOption {
+       type = types.int;
+       description = ''
+         Configure unit start rate limiting. Units which are started
+         more than burst times within an interval time interval are
+         not permitted to start any more.
+       '';
+    };
+
   };
 
 
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 860268ab23a..f783daba902 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -193,7 +193,7 @@ let
     let mkScriptName =  s: "unit-script-" + (replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape s) );
     in  pkgs.writeTextFile { name = mkScriptName name; executable = true; inherit text; };
 
-  unitConfig = { config, ... }: {
+  unitConfig = { config, options, ... }: {
     config = {
       unitConfig =
         optionalAttrs (config.requires != [])
@@ -219,7 +219,9 @@ let
         // optionalAttrs (config.documentation != []) {
           Documentation = toString config.documentation; }
         // optionalAttrs (config.onFailure != []) {
-          OnFailure = toString config.onFailure;
+          OnFailure = toString config.onFailure; }
+        // optionalAttrs (options.startLimitIntervalSec.isDefined) {
+          StartLimitIntervalSec = toString config.startLimitIntervalSec;
         };
     };
   };