29 lines
766 B
Nix
29 lines
766 B
Nix
{lib, pkgs, config, ...}:
|
|
let
|
|
cfg = config.nixGc;
|
|
in
|
|
{
|
|
options.nixGc = {
|
|
enable = lib.mkEnableOption "enable nix gc default settings";
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# Limit the number of generations to keep
|
|
boot.loader.systemd-boot.configurationLimit = 5;
|
|
|
|
# Perform garbage collection weekly to maintain low disk usage
|
|
nix.gc = {
|
|
automatic = true;
|
|
dates = "weekly";
|
|
options = "--delete-older-than 1w";
|
|
};
|
|
|
|
# Optimize storage
|
|
# You can also manually optimize the store via:
|
|
# nix-store --optimise
|
|
# Refer to the following link for more details:
|
|
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
|
|
nix.settings.auto-optimise-store = true;
|
|
};
|
|
}
|