From 873b9814d9331ae64e6211f9d3bd17c3f772fcac Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Fri, 24 May 2024 16:14:32 +0200 Subject: [PATCH] add auto gc --- modules/nix/settings.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/nix/settings.nix b/modules/nix/settings.nix index 3980e51..fffe439 100644 --- a/modules/nix/settings.nix +++ b/modules/nix/settings.nix @@ -1,18 +1,25 @@ -{lib, inputs, config, pkgsVersion, ... }: +{ lib, inputs, config, pkgsVersion, ... }: with lib; -let - cfg = config.custom.nix.settings; -in -{ +let cfg = config.custom.nix.settings; +in { options.custom.nix.settings = { enable = mkEnableOption "Enables various nix settings"; }; - + config = mkIf cfg.enable { nix.optimise.automatic = true; nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.registry.nixpkgs.flake = pkgsVersion; - nix.nixPath = ["nixpkgs=flake:nixpkgs"]; + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + nix.extraOptions = '' + min-free = ${toString (100 * 1024 * 1024)} + max-free = ${toString (1024 * 1024 * 1024)} + ''; + nix.nixPath = [ "nixpkgs=flake:nixpkgs" ]; nixpkgs.config.allowUnfree = true; ##home-manager.users.${config.mainUser.name}.home.sessionVariables = { ## NIX_PATH = "nixpkgs=flake:nixpkgs$\{NIX_PATH:+:$NIX_PATH}";