diff --git a/modules/common/development/nix.nix b/modules/common/development/nix.nix index 7b7f45ffe..70978d0c2 100644 --- a/modules/common/development/nix.nix +++ b/modules/common/development/nix.nix @@ -18,36 +18,38 @@ in default = null; description = "Path to the nixpkgs repository"; }; + automatic-gc = { + enable = mkEnableOption "Enable automatic garbage collection"; + }; }; - config = mkIf cfg.enable { - nix = { - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - keep-outputs = true; - keep-derivations = true; - }; + config.nix = { + inherit (cfg) enable; + settings = mkIf cfg.enable { + experimental-features = [ + "nix-command" + "flakes" + ]; + keep-outputs = true; + keep-derivations = true; + }; - # avoid scenario where the host rootfs gets filled - # with nixos-rebuild ... switch generated excess - # generations and becomes unbootable - gc = { - automatic = true; - dates = "daily"; - options = "--delete-older-than 3d"; - }; + # avoid scenario where the host rootfs gets filled + # with nixos-rebuild ... switch generated excess + # generations and becomes unbootable + gc = { + automatic = cfg.enable; + dates = "daily"; + options = "--delete-older-than 3d"; + }; - # Set the path and registry so that e.g. nix-shell and repl work - nixPath = lib.mkIf (cfg.nixpkgs != null) [ "nixpkgs=${cfg.nixpkgs}" ]; + # Set the path and registry so that e.g. nix-shell and repl work + nixPath = lib.mkIf (cfg.enable && cfg.nixpkgs != null) [ "nixpkgs=${cfg.nixpkgs}" ]; - registry = lib.mkIf (cfg.nixpkgs != null) { - nixpkgs.to = { - type = "path"; - path = cfg.nixpkgs; - }; + registry = lib.mkIf (cfg.enable && cfg.nixpkgs != null) { + nixpkgs.to = { + type = "path"; + path = cfg.nixpkgs; }; }; }; diff --git a/modules/microvm/virtualization/microvm/microvm-host.nix b/modules/microvm/virtualization/microvm/microvm-host.nix index c5944c0b0..e8bff4739 100644 --- a/modules/microvm/virtualization/microvm/microvm-host.nix +++ b/modules/microvm/virtualization/microvm/microvm-host.nix @@ -73,6 +73,7 @@ in withHardenedConfigs = true; }; ghaf.givc.host.enable = true; + ghaf.development.nix-setup.automatic-gc.enable = config.ghaf.development.nix-setup.enable; services.logind.lidSwitch = "ignore"; # TODO: remove hardcoded paths