1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-19 06:43:06 +00:00
nix-darwin/modules/services/nix-optimise/default.nix
Emily c796587d2e nix: remove nix.useDaemon
We now assume the daemon is used unconditionally when we manage the
Nix installation.

The `nix.gc` and `nix.optimise` services lose their `$NIX_REMOTE`
setting rather than making it unconditional, as the NixOS `nix.gc`
module does not set it. Possibly it should, but I think uniformity
between the two systems is better than diverging, even though I kind
of hate that the non‐daemon method of access is even a thing.
2025-02-07 19:44:59 +00:00

66 lines
1.5 KiB
Nix

# Based off:
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-optimise.nix
# When making changes please try to keep it in sync.
{ config, lib, ... }:
let
inherit (lib)
mkIf
mkOption
mkRemovedOptionModule
optionalString
types
;
cfg = config.nix.optimise;
launchdTypes = import ../../launchd/types.nix { inherit config lib; };
in
{
imports = [
(mkRemovedOptionModule [ "nix" "optimise" "dates" ] "Use `nix.optimise.interval` instead.")
(mkRemovedOptionModule [ "nix" "optimise" "user" ] "The store optimisation service now always runs as `root`.")
];
###### interface
options = {
nix.optimise = {
automatic = mkOption {
type = types.bool;
default = false;
description = "Automatically run the nix store optimiser at a specific time.";
};
interval = mkOption {
type = launchdTypes.StartCalendarInterval;
default = [{ Weekday = 7; Hour = 4; Minute = 15; }];
description = ''
The calendar interval at which the optimiser will run.
See the {option}`serviceConfig.StartCalendarInterval` option of
the {option}`launchd` module for more info.
'';
};
};
};
###### implementation
config = mkIf cfg.automatic {
launchd.daemons.nix-optimise = {
command = "${lib.getExe' config.nix.package "nix-store"} --optimise";
serviceConfig = {
RunAtLoad = false;
StartCalendarInterval = cfg.interval;
};
};
};
}