{
  lib,
  pkgs,
  inputs,
  ...
}: {
  nix = {
    package = pkgs.nixVersions.stable;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';

    daemonCPUSchedPolicy = "idle";
    daemonIOSchedClass = "idle";
    daemonIOSchedPriority = 7;

    nixPath = [
      "nixpkgs=${inputs.nixpkgs}"
    ];

    settings = {
      trusted-users = ["@wheel"];
      auto-optimise-store = true;
      allowed-users = ["@wheel"];

      log-lines = lib.mkDefault 25;

      # Avoid disk full issues
      max-free = lib.mkDefault (3000 * 1024 * 1024);
      min-free = lib.mkDefault (512 * 1024 * 10);

      download-buffer-size = lib.mkDefault (512 * 1024 * 1024);
    };

    gc = {
      automatic = true;
      options = "--delete-older-than 30d";
      randomizedDelaySec = "60 min";
    };
  };

  systemd.services.nix-daemon.serviceConfig.OOMScoreAdjust = 250;

  nixpkgs.overlays = with inputs; [
    self.overlays.default
  ];

  environment.systemPackages = with pkgs; [
    cached-nix-shell
    git
  ];
}
