at 17.09-beta 1.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.nix.gc; 7in 8 9{ 10 11 ###### interface 12 13 options = { 14 15 nix.gc = { 16 17 automatic = mkOption { 18 default = false; 19 type = types.bool; 20 description = "Automatically run the garbage collector at a specific time."; 21 }; 22 23 dates = mkOption { 24 default = "03:15"; 25 type = types.str; 26 description = '' 27 Specification (in the format described by 28 <citerefentry><refentrytitle>systemd.time</refentrytitle> 29 <manvolnum>7</manvolnum></citerefentry>) of the time at 30 which the garbage collector will run. 31 ''; 32 }; 33 34 options = mkOption { 35 default = ""; 36 example = "--max-freed $((64 * 1024**3))"; 37 type = types.str; 38 description = '' 39 Options given to <filename>nix-collect-garbage</filename> when the 40 garbage collector is run automatically. 41 ''; 42 }; 43 44 }; 45 46 }; 47 48 49 ###### implementation 50 51 config = { 52 53 systemd.services.nix-gc = 54 { description = "Nix Garbage Collector"; 55 script = "exec ${config.nix.package.out}/bin/nix-collect-garbage ${cfg.options}"; 56 startAt = optional cfg.automatic cfg.dates; 57 }; 58 59 }; 60 61}