{ inputs, lib, ... }: 

let
  build-tmp = "/var/tmp";
in {

  nix = {
    settings = {
      auto-optimise-store = lib.mkDefault true;
      build-dir = build-tmp;
      experimental-features = [ "nix-command" "flakes" ];
      trusted-users = [ "root" "@wheel" ];
      warn-dirty = false;
    };

    # Garbage Collection
    gc = {
      automatic = true;
      dates = "weekly";
      randomizedDelaySec = "14m";
      # Keep the last 2 generations
      options = "--delete-older-than 28d";
    };

  };

  systemd.services."nix-daemon".environment.TMPDIR = build-tmp;

}