mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-19 23:03:11 +00:00
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.
68 lines
1.9 KiB
Nix
68 lines
1.9 KiB
Nix
# Based off: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-gc.nix
|
|
# When making changes please try to keep it in sync.
|
|
{ config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.nix.gc;
|
|
launchdTypes = import ../../launchd/types.nix { inherit config lib; };
|
|
in
|
|
|
|
{
|
|
imports = [
|
|
(mkRemovedOptionModule [ "nix" "gc" "dates" ] "Use `nix.gc.interval` instead.")
|
|
(mkRemovedOptionModule [ "nix" "gc" "randomizedDelaySec" ] "No `nix-darwin` equivalent to this NixOS option.")
|
|
(mkRemovedOptionModule [ "nix" "gc" "persistent" ] "No `nix-darwin` equivalent to this NixOS option.")
|
|
(mkRemovedOptionModule [ "nix" "gc" "user" ] "The garbage collection service now always runs as `root`.")
|
|
];
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
nix.gc = {
|
|
|
|
automatic = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = "Automatically run the garbage collector at a specific time.";
|
|
};
|
|
|
|
interval = mkOption {
|
|
type = launchdTypes.StartCalendarInterval;
|
|
default = [{ Weekday = 7; Hour = 3; Minute = 15; }];
|
|
description = ''
|
|
The calendar interval at which the garbage collector will run.
|
|
See the {option}`serviceConfig.StartCalendarInterval` option of
|
|
the {option}`launchd` module for more info.
|
|
'';
|
|
};
|
|
|
|
options = mkOption {
|
|
default = "";
|
|
example = "--max-freed $((64 * 1024**3))";
|
|
type = types.str;
|
|
description = ''
|
|
Options given to {file}`nix-collect-garbage` when the
|
|
garbage collector is run automatically.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.automatic {
|
|
|
|
launchd.daemons.nix-gc = {
|
|
command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}";
|
|
serviceConfig.RunAtLoad = false;
|
|
serviceConfig.StartCalendarInterval = cfg.interval;
|
|
};
|
|
|
|
};
|
|
}
|