nixos/nix-gc: Drop with lib;

This commit is contained in:
Janne Heß 2024-01-20 13:14:57 +01:00
parent 08183932ce
commit fd8727163d
No known key found for this signature in database

View File

@ -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 {