feat(nixos): add scheduled garbage collection and optimization for Nix ⚡🎨
Implement launchd daemons for automatic Nix garbage collection and store optimization on a weekly schedule. The configuration includes intervals for both tasks to ensure efficient management of Nix store resources.
This commit is contained in:
parent
be4233a53b
commit
309d97c708
1 changed files with 23 additions and 0 deletions
|
|
@ -3,6 +3,11 @@
|
|||
let
|
||||
alacrittySyncSystemTheme = pkgs.writeShellScriptBin "alacritty-sync-system-theme"
|
||||
(builtins.readFile ../../scripts/alacritty-sync-system-theme.sh);
|
||||
|
||||
# nix-darwin's nix.gc / nix.optimise require nix.enable; with Determinate (nix.enable = false)
|
||||
# we schedule the same commands via launchd using nixpkgs' nix CLI (same defaults as upstream modules).
|
||||
nixGcInterval = [{ Weekday = 7; Hour = 3; Minute = 15; }];
|
||||
nixOptimiseInterval = [{ Weekday = 7; Hour = 4; Minute = 15; }];
|
||||
in {
|
||||
# Apple Silicon + nix-darwin basics
|
||||
nixpkgs.hostPlatform = "aarch64-darwin";
|
||||
|
|
@ -72,6 +77,24 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
launchd.daemons = {
|
||||
nix-gc-determ = {
|
||||
command =
|
||||
"${lib.getExe' pkgs.nix "nix-collect-garbage"} --delete-older-than 14d";
|
||||
serviceConfig = {
|
||||
RunAtLoad = false;
|
||||
StartCalendarInterval = nixGcInterval;
|
||||
};
|
||||
};
|
||||
nix-store-optimise-determ = {
|
||||
command = "${lib.getExe' pkgs.nix "nix-store"} --optimise";
|
||||
serviceConfig = {
|
||||
RunAtLoad = false;
|
||||
StartCalendarInterval = nixOptimiseInterval;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Keep for darwin as well (tracks defaults across upgrades)
|
||||
# current max per nix-darwin; bump only if a release notes says so
|
||||
system.stateVersion = 6;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue