From fd8727163d3b0bd77a274e201adf75a3c412d2d6 Mon Sep 17 00:00:00 2001 From: Janne Heß Date: Sat, 20 Jan 2024 13:14:57 +0100 Subject: nixos/nix-gc: Drop with lib; --- nixos/modules/services/misc/nix-gc.nix | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix index 97596d28cd89b..977a0af8bb25c 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.str; 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.str; 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.str; description = lib.mdDoc '' Options given to {file}`nix-collect-garbage` when the garbage collector is run automatically. @@ -89,7 +87,7 @@ 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; + startAt = lib.optional cfg.automatic cfg.dates; }; systemd.timers.nix-gc = lib.mkIf cfg.automatic { -- cgit 1.4.1 From 23151743843ecc95ffdd87298df6121090c0b698 Mon Sep 17 00:00:00 2001 From: Janne Heß Date: Sat, 20 Jan 2024 13:15:20 +0100 Subject: nixos/nix-gc: Add Type so systemctl waits properly --- nixos/modules/services/misc/nix-gc.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'nixos') diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix index 977a0af8bb25c..c786287587520 100644 --- a/nixos/modules/services/misc/nix-gc.nix +++ b/nixos/modules/services/misc/nix-gc.nix @@ -87,6 +87,7 @@ 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}"; + serviceConfig.Type = "oneshot"; startAt = lib.optional cfg.automatic cfg.dates; }; -- cgit 1.4.1 From e04524a931766d943e7ab1c13d763bcc913608d6 Mon Sep 17 00:00:00 2001 From: Janne Heß Date: Sat, 20 Jan 2024 13:16:39 +0100 Subject: nixos/nix-gc: Use singleLineStr where possible --- nixos/modules/services/misc/nix-gc.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix index c786287587520..de6bd76c7eb9d 100644 --- a/nixos/modules/services/misc/nix-gc.nix +++ b/nixos/modules/services/misc/nix-gc.nix @@ -19,7 +19,7 @@ in }; dates = lib.mkOption { - type = lib.types.str; + type = lib.types.singleLineStr; default = "03:15"; example = "weekly"; description = lib.mdDoc '' @@ -33,7 +33,7 @@ in randomizedDelaySec = lib.mkOption { default = "0"; - type = lib.types.str; + type = lib.types.singleLineStr; example = "45min"; description = lib.mdDoc '' Add a randomized delay before each garbage collection. @@ -62,7 +62,7 @@ in options = lib.mkOption { default = ""; example = "--max-freed $((64 * 1024**3))"; - type = lib.types.str; + type = lib.types.singleLineStr; description = lib.mdDoc '' Options given to {file}`nix-collect-garbage` when the garbage collector is run automatically. -- cgit 1.4.1