From 77285bdb0aac082d3df262bb9768d83154157ee7 Mon Sep 17 00:00:00 2001 From: shinya Date: Mon, 27 Jan 2025 14:40:53 +0100 Subject: [PATCH] Added system update options and cleanup --- ginoza/configuration.nix | 3 ++ kogami/configuration.nix | 4 +++ nixos/home/packages/applications/vencord.nix | 1 - nixos/system/settings/updates.nix | 37 ++++++++++++++++++++ nixos/system/system.nix | 4 +++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 nixos/system/settings/updates.nix diff --git a/ginoza/configuration.nix b/ginoza/configuration.nix index b1cdd7b..22e3b24 100644 --- a/ginoza/configuration.nix +++ b/ginoza/configuration.nix @@ -41,6 +41,9 @@ enable = true; blueman.enable = false; }; + autoupdate.enable = false; + autocleanup.enable = true; + nvidia = { enable = false; }; diff --git a/kogami/configuration.nix b/kogami/configuration.nix index 17ccdd8..7f590da 100644 --- a/kogami/configuration.nix +++ b/kogami/configuration.nix @@ -43,6 +43,10 @@ enable = true; blueman.enable = true; }; + + autoupdate.enable = true; + autocleanup.enable = true; + nvidia = { enable = true; mode = "offload"; diff --git a/nixos/home/packages/applications/vencord.nix b/nixos/home/packages/applications/vencord.nix index 9232d18..b3ddea1 100644 --- a/nixos/home/packages/applications/vencord.nix +++ b/nixos/home/packages/applications/vencord.nix @@ -60,4 +60,3 @@ }; }; } - diff --git a/nixos/system/settings/updates.nix b/nixos/system/settings/updates.nix new file mode 100644 index 0000000..cb45b76 --- /dev/null +++ b/nixos/system/settings/updates.nix @@ -0,0 +1,37 @@ +{ + lib, + config, + inputs, + ... +}: +{ + options = { + sys.autoupdate.enable = lib.mkEnableOption "Enable automatic updates"; + sys.autocleanup.enable = lib.mkEnableOption "Enable automatic cleanup"; + }; + + config = lib.mkMerge [ + (lib.mkIf config.sys.autoupdate.enable { + system.autoUpgrade = { + enable = true; + flake = inputs.self.outPath; + flags = [ + "--commit-lock-file" + "-L" # print build logs + ]; + dates = "weekly"; + randomizedDelaySec = "45min"; + }; + }) + (lib.mkIf config.sys.autocleanup.enable { + nix = { + gc ={ + automatic = true; + dates = "weekly"; + options = "--delete-older-than 5d"; + }; + settings.auto-optimise-store = true; + }; + }) + ]; +} \ No newline at end of file diff --git a/nixos/system/system.nix b/nixos/system/system.nix index af91d7b..9b513f5 100644 --- a/nixos/system/system.nix +++ b/nixos/system/system.nix @@ -16,6 +16,7 @@ ./settings/style.nix ./settings/default-applications.nix ./settings/logind.nix + ./settings/updates.nix #./settings/bootloader.nix ./settings/user.nix @@ -46,6 +47,9 @@ blueman.enable = lib.mkDefault true; }; + autoupdate.enable = lib.mkDefault true; + autocleanup.enable = lib.mkDefault false; + nvidia = { enable = lib.mkDefault false; mode = lib.mkDefault "none";