From c027fb5ee5df3c33f9a2ce088b30100cdf3fa028 Mon Sep 17 00:00:00 2001 From: Malo Bourgon Date: Sun, 14 Aug 2022 14:44:59 -0700 Subject: [PATCH] Update `nix.gc` module with same indenting/formatting as NixOS module --- modules/services/nix-gc/default.nix | 66 +++++++++++++++++------------ 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/modules/services/nix-gc/default.nix b/modules/services/nix-gc/default.nix index 57b3e22d..d7b90da6 100644 --- a/modules/services/nix-gc/default.nix +++ b/modules/services/nix-gc/default.nix @@ -1,4 +1,6 @@ -{ config, lib, pkgs, ... }: +# Based off: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-gc.nix +# When making changes please try to keep it in sync. +{ config, lib, ... }: with lib; @@ -7,36 +9,48 @@ let in { + + ###### interface + options = { - nix.gc.automatic = mkOption { - type = types.bool; - default = false; - description = "Automatically run the garbage collector at a specific time."; + + nix.gc = { + + automatic = mkOption { + type = types.bool; + default = false; + description = "Automatically run the garbage collector at a specific time."; + }; + + user = mkOption { + type = types.nullOr types.str; + default = null; + description = "User that runs the garbage collector."; + }; + + interval = mkOption { + type = types.attrs; + default = { Hour = 3; Minute = 15; }; + description = "The time interval at which the garbage collector will run."; + }; + + options = mkOption { + type = types.str; + default = ""; + example = "--max-freed $((64 * 1024**3))"; + description = '' + Options given to nix-collect-garbage when the + garbage collector is run automatically. + ''; + }; + }; - nix.gc.user = mkOption { - type = types.nullOr types.str; - default = null; - description = "User that runs the garbage collector."; - }; - - nix.gc.interval = mkOption { - type = types.attrs; - default = { Hour = 3; Minute = 15; }; - description = "The time interval at which the garbage collector will run."; - }; - - nix.gc.options = mkOption { - type = types.str; - default = ""; - example = "--max-freed $((64 * 1024**3))"; - description = '' - Options given to nix-collect-garbage when the - garbage collector is run automatically. - ''; - }; }; + + ###### implementation + config = mkIf cfg.automatic { launchd.daemons.nix-gc = {