mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-14 01:33:10 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
54 lines
1.3 KiB
Nix
54 lines
1.3 KiB
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
cfg = config.nix.optimise;
|
|
in
|
|
|
|
{
|
|
options = {
|
|
nix.optimise = {
|
|
automatic = lib.mkOption {
|
|
default = false;
|
|
type = lib.types.bool;
|
|
description = "Automatically run the nix store optimiser at a specific time.";
|
|
};
|
|
|
|
dates = lib.mkOption {
|
|
default = ["03:45"];
|
|
type = with lib.types; listOf str;
|
|
description = ''
|
|
Specification (in the format described by
|
|
{manpage}`systemd.time(7)`) of the time at
|
|
which the optimiser will run.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
assertions = [
|
|
{
|
|
assertion = cfg.automatic -> config.nix.enable;
|
|
message = ''nix.optimise.automatic requires nix.enable'';
|
|
}
|
|
];
|
|
|
|
systemd = lib.mkIf config.nix.enable {
|
|
services.nix-optimise = {
|
|
description = "Nix Store Optimiser";
|
|
# No point this if the nix daemon (and thus the nix store) is outside
|
|
unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
|
|
serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise";
|
|
startAt = lib.optionals cfg.automatic cfg.dates;
|
|
};
|
|
|
|
timers.nix-optimise = lib.mkIf cfg.automatic {
|
|
timerConfig = {
|
|
Persistent = true;
|
|
RandomizedDelaySec = 1800;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|