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
+ # systemd.time
+ # 5) 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 nix-collect-garbage 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; }
+ ];
+ };
+
+ };
+}