diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2017-03-05 20:37:56 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2017-03-05 20:39:48 +0100 |
| commit | d92f0e811767c3bb9e838489f3299b80845b4f99 (patch) | |
| tree | 014dc9b101750b40596155d54e004bfafcceff32 | |
| parent | a12b9def6c05f136dce378b61539937b6da5a868 (diff) | |
nix-gc: init service
| -rw-r--r-- | default.nix | 1 | ||||
| -rw-r--r-- | modules/services/nix-gc.nix | 55 |
2 files changed, 56 insertions, 0 deletions
diff --git a/default.nix b/default.nix index 28316f7..4da081f 100644 --- a/default.nix +++ b/default.nix @@ -40,6 +40,7 @@ let ./modules/services/kwm.nix ./modules/services/emacs.nix ./modules/services/nix-daemon.nix + ./modules/services/nix-gc.nix ./modules/programs/bash.nix ./modules/programs/fish.nix ./modules/programs/nix-script.nix diff --git a/modules/services/nix-gc.nix b/modules/services/nix-gc.nix new file mode 100644 index 0000000..0dc704b --- /dev/null +++ b/modules/services/nix-gc.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.nix.gc; +in + +{ + options = { + nix.gc = { + + automatic = mkOption { + default = false; + type = types.bool; + description = "Automatically run the garbage collector at a specific time."; + }; + + # TODO: parse dates + # dates = mkOption { + # default = "03:15"; + # type = types.str; + # description = '' + # Specification (in the format described by + # <citerefentry><refentrytitle>systemd.time</refentrytitle> + # <manvolnum>5</manvolnum></citerefentry>) of the time at + # which the garbage collector will run. + # ''; + # }; + + options = mkOption { + default = ""; + example = "--max-freed $((64 * 1024**3))"; + type = types.str; + description = '' + Options given to <filename>nix-collect-garbage</filename> when the + garbage collector is run automatically. + ''; + }; + + }; + }; + + config = mkIf cfg.automatic { + + launchd.daemons.nix-gc = { + command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}"; + serviceConfig.RunAtLoad = false; + serviceConfig.StartCalendarInterval = mkDefault + [ { Hour = 3; Minute = 15; } + ]; + }; + + }; +} |
