{ config, ... }:
{
    nix = {
      gc = {
        automatic = true;
        options = "--delete-older-than 2d";
      };

      settings = {
        experimental-features = [ "nix-command" "flakes" ];

        # Limit resource usage to prevent Linux OOM
        max-jobs = 4;
        cores = 5;

        max-silent-time = 3600;
        timeout = 0;

        auto-optimise-store = true;

        # Package caches
        substituters = [
          "https://cache.nixos.org"
          "https://nix-community.cachix.org"
          "https://hyprland.cachix.org"
	        "https://nix-citizen.cachix.org"
          "https://attic.xuyh0120.win/lantian"
        ];
        trusted-public-keys = [
          "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
	        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
          "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
          "nix-citizen.cachix.org-1:lPMkWc2X8XD4/7YPEEwXKKBg+SVbYTVrAaLA2wQTKCo="
          "lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc="
	      ];
      };
    };
    
    nixpkgs = {
      config = {
        allowUnfree = true;
      };
    };
}
