6 cfg = config.nix.optimise;
17 automatic = mkOption {
20 description = lib.mdDoc "Automatically run the nix store optimiser at a specific time.";
25 type = types.listOf types.str;
26 description = lib.mdDoc ''
27 Specification (in the format described by
28 {manpage}`systemd.time(7)`) of the time at
29 which the optimiser will run.
41 assertion = cfg.automatic -> config.nix.enable;
42 message = ''nix.optimise.automatic requires nix.enable'';
46 systemd.services.nix-optimise = lib.mkIf config.nix.enable
47 { description = "Nix Store Optimiser";
48 # No point this if the nix daemon (and thus the nix store) is outside
49 unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
50 serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise";
51 startAt = optionals cfg.automatic cfg.dates;