# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.

#---------------------------------------------------------------------
# Imports and basic configuration
#---------------------------------------------------------------------
{ config, lib, pkgs, modulesPath, ... }:

{
  #---------------------------------------------------------------------
  # Module imports
  #---------------------------------------------------------------------
  imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];

  #---------------------------------------------------------------------
  # Boot configuration
  #---------------------------------------------------------------------
  boot = {
    initrd.availableKernelModules = [

      "ahci"        # Enables the Advanced Host Controller Interface (AHCI) driver, typically used for SATA (Serial ATA) controllers.
      "ehci_pci"    # Enables the Enhanced Host Controller Interface (EHCI) driver for PCI-based USB controllers, providing support for USB 2.0.
      "firewire_ohci"
      "ohci_pci"
      "pata_amd"
      "sata_nv"
      "sd_mod"      # Enables the SCSI disk module (sd_mod), which allows the system to recognize and interact with SCSI-based storage devices.
  #    "sdhci_pci"
      "sr_mod"      # Loads the SCSI (Small Computer System Interface) CD/DVD-ROM driver, allowing the system to recognize and use optical drives.
      "usbhid"      # Enables the USB Human Interface Device (HID) driver, which provides support for USB input devices such as keyboards and mice.
      "usb_storage" # Enables the USB Mass Storage driver, allowing the system to recognize and use USB storage devices like USB flash drives and external hard drives.
  #    "xhci_pci"    # Enables the eXtensible Host Controller Interface (xHCI) driver for PCI-based USB controllers, providing support for USB 3.0 and later standards.
  ];

    extraModulePackages = [ ];
    initrd.kernelModules = [ ];
    kernelModules = [
    "kvm-intel"
    "tcp_cubic"     # Cubic: A traditional and widely used congestion control algorithm
    "tcp_reno"      # Reno: Another widely used and stable algorithm
    "tcp_newreno"   # New Reno: An extension of the Reno algorithm with some improvements
    "tcp_bbr"       # BBR: Dynamically optimize how data is sent over a network, aiming for higher throughput and reduced latency
    "tcp_westwood"  # Westwood: Particularly effective in wireless networks
    ];

    # Enable BBR congestion control algorithm for TCP, , which can lead to improved network throughput and reduced latency.

 #   kernel.sysctl = {

 #     "net.ipv4.tcp_congestion_control" = "bbr";     # Tweak local networking

 #   "kernel.sysrq" = 1;                           # Enable SysRQ for rebooting the machine properly if it freezes. [Source](https://oglo.dev/tutorials/sysrq/index.html)
 #   "net.core.netdev_max_backlog" = 30000;        # Help prevent packet loss during high traffic periods.
 #   "net.core.rmem_default" = 262144;             # Default socket receive buffer size, improve network performance & applications that use sockets. Adjusted for 16GB RAM.
 #   "net.core.rmem_max" = 67108864;               # Maximum socket receive buffer size, determine the amount of data that can be buffered in memory for network operations. Adjusted for 16GB RAM.
 #   "net.core.wmem_default" = 262144;             # Default socket send buffer size, improve network performance & applications that use sockets. Adjusted for 16GB RAM.
 #   "net.core.wmem_max" = 67108864;               # Maximum socket send buffer size, determine the amount of data that can be buffered in memory for network operations. Adjusted for 16GB RAM.
 #   "net.ipv4.ipfrag_high_threshold" = 5242880;   # Reduce the chances of fragmentation. Adjusted for SSD.
 #   "net.ipv4.tcp_keepalive_intvl" = 30;          # TCP keepalive interval between probes to detect if a connection is still alive.
 #   "net.ipv4.tcp_keepalive_probes" = 5;          # TCP keepalive probes to detect if a connection is still alive.
 #   "net.ipv4.tcp_keepalive_time" = 300;          # TCP keepalive interval in seconds to detect if a connection is still alive.
 #   "vm.dirty_background_bytes" = 583200768;      # 556 MB (128 MB + 450 MB)
 #   "vm.dirty_bytes" = 851968768;                 # 812 MB (384 MB + 450 MB)
 #   "vm.min_free_kbytes" = 65536;                 # Minimum free memory for safety (in KB)
 #   "vm.swappiness" = 0;                          # Adjust how aggressively the kernel swaps data from RAM to disk. Lower values prioritize keeping data in RAM. Adjusted for 16GB RAM.
 #   "vm.vfs_cache_pressure" = 90;                 # Adjust vfs_cache_pressure (0-1000) to manage memory used for caching filesystem objects. Adjusted for 16GB RAM.

 #   };
    
    kernelParams = [

    "mitigations=off"
    "quiet"
  #  "intel_pstate=ondemand"

    ];
  };

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/15a24bc9-1264-41f0-9c4f-a10263a8ea21";
      fsType = "ext4";
    };

  swapDevices =
    [ { device = "/dev/disk/by-uuid/ae46017a-71a5-4a60-8a39-3eece13df336"; }
    ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.

  networking.useDHCP = lib.mkDefault true;

  # networking.interfaces.enp0s25.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlo1.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode =
    lib.mkDefault config.hardware.enableRedistributableFirmware;
}
