summaryrefslogtreecommitdiff
path: root/os/core/storage.nix
diff options
context:
space:
mode:
authoradikro <adikro@disroot.org>2025-12-24 16:21:00 +0100
committeradikro <adikro@disroot.org>2025-12-24 16:21:00 +0100
commit6aaa5993e4c1cfb205ed555d958702f9bba1770d (patch)
tree3af8cf20967cf10542edd2e51232b1da70002fde /os/core/storage.nix
parent2ceabfd1d1dc03ca895e960048b73a82e29e45e8 (diff)
a bunch of changes, renames sys to os and refactored some of the logic
Diffstat (limited to 'os/core/storage.nix')
-rw-r--r--os/core/storage.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/os/core/storage.nix b/os/core/storage.nix
new file mode 100644
index 0000000..693e5e7
--- /dev/null
+++ b/os/core/storage.nix
@@ -0,0 +1,36 @@
+{ config, lib, ... }:
+let
+ cfg = config.sys.core.storage;
+in
+{
+ options.sys.core.storage = {
+ enable = lib.mkEnableOption "enables storage management";
+
+ keepDays = lib.mkOption {
+ type = lib.types.int;
+ default = 14;
+ description = "Number of days to keep old Nix generations before GC";
+ };
+ };
+ config = lib.mkIf cfg.enable {
+ nix.settings.auto-optimise-store = true;
+
+ programs.nh = {
+ enable = true;
+ clean.enable = true;
+ clean.extraArgs = "--keep-days ${toString cfg.keepDays} --keep 5";
+ };
+
+ services.fstrim.enable = true;
+
+ services.btrfs.autoScrub = {
+ enable = true;
+ fileSystems = [ "/" ];
+ };
+
+ boot.tmp = {
+ useTmpfs = true;
+ tmpfsSize = "50%";
+ };
+ };
+}