about summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authornikstur <nikstur@outlook.com>2024-01-22 17:49:18 +0100
committerGitHub <noreply@github.com>2024-01-22 17:49:18 +0100
commit3ea482163b4a859da594a16f3fc7f2c936db6082 (patch)
treed984e0b8b1b70a1712c91c531836277566ca072f /nixos/modules/services
parent733c8ee46988f6e805f4faed26e677c8bacab891 (diff)
parente04524a931766d943e7ab1c13d763bcc913608d6 (diff)
downloadnixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.tar
nixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.tar.gz
nixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.tar.bz2
nixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.tar.lz
nixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.tar.xz
nixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.tar.zst
nixlib-3ea482163b4a859da594a16f3fc7f2c936db6082.zip
Merge pull request #282320 from helsinki-systems/fix/nix-gc-unit-type
nixos/nix-gc: Minor module fixups
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/misc/nix-gc.nix25
1 files changed, 12 insertions, 13 deletions
diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix
index 97596d28cd89..de6bd76c7eb9 100644
--- a/nixos/modules/services/misc/nix-gc.nix
+++ b/nixos/modules/services/misc/nix-gc.nix
@@ -1,7 +1,5 @@
 { config, lib, ... }:
 
-with lib;
-
 let
   cfg = config.nix.gc;
 in
@@ -14,14 +12,14 @@ in
 
     nix.gc = {
 
-      automatic = mkOption {
+      automatic = lib.mkOption {
         default = false;
-        type = types.bool;
+        type = lib.types.bool;
         description = lib.mdDoc "Automatically run the garbage collector at a specific time.";
       };
 
-      dates = mkOption {
-        type = types.str;
+      dates = lib.mkOption {
+        type = lib.types.singleLineStr;
         default = "03:15";
         example = "weekly";
         description = lib.mdDoc ''
@@ -33,9 +31,9 @@ in
         '';
       };
 
-      randomizedDelaySec = mkOption {
+      randomizedDelaySec = lib.mkOption {
         default = "0";
-        type = types.str;
+        type = lib.types.singleLineStr;
         example = "45min";
         description = lib.mdDoc ''
           Add a randomized delay before each garbage collection.
@@ -45,9 +43,9 @@ in
         '';
       };
 
-      persistent = mkOption {
+      persistent = lib.mkOption {
         default = true;
-        type = types.bool;
+        type = lib.types.bool;
         example = false;
         description = lib.mdDoc ''
           Takes a boolean argument. If true, the time when the service
@@ -61,10 +59,10 @@ in
         '';
       };
 
-      options = mkOption {
+      options = lib.mkOption {
         default = "";
         example = "--max-freed $((64 * 1024**3))";
-        type = types.str;
+        type = lib.types.singleLineStr;
         description = lib.mdDoc ''
           Options given to {file}`nix-collect-garbage` when the
           garbage collector is run automatically.
@@ -89,7 +87,8 @@ in
     systemd.services.nix-gc = lib.mkIf config.nix.enable {
       description = "Nix Garbage Collector";
       script = "exec ${config.nix.package.out}/bin/nix-collect-garbage ${cfg.options}";
-      startAt = optional cfg.automatic cfg.dates;
+      serviceConfig.Type = "oneshot";
+      startAt = lib.optional cfg.automatic cfg.dates;
     };
 
     systemd.timers.nix-gc = lib.mkIf cfg.automatic {