summaryrefslogtreecommitdiff
path: root/os/core/storage.nix
blob: e4e282b1992ab5de8e6c6d33b96ce7cf6fa8e9f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ config, lib, ... }:
let
  cfg = config.os.core.storage;
in
{
  options.os.core.storage = {
    enable = lib.mkEnableOption "enables storage management";
    
    cleanDates = lib.mkOption {
      type = lib.types.int;
      default = "weekly";
      description = "how often to clean the system of old generations";
    };
  };
  config = lib.mkIf cfg.enable {
    nix.settings.auto-optimise-store = true;

    programs.nh = {
      enable = true;
      clean = {
        enable = true;
        dates = "${toString cfg.cleanDates}";
        clean.extraArgs = "--keep 5";
      };
    };
    
    services.fstrim.enable = true;

    services.btrfs.autoScrub = {
        enable = true;
        fileSystems = [ "/" ];
    };

    boot.tmp = {
      useTmpfs = true;
      tmpfsSize = "50%";
    };
  };
}