# 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.
{
  config,
  lib,
  pkgs,
  modulesPath,
  ...
}:

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

  boot.initrd.availableKernelModules = [
    "xhci_pci"
    "thunderbolt"
    "nvme"
    "usbhid"
  ];
  boot.initrd.kernelModules = [ "xe" ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.kernelParams = [
    # NVMe APST(Autonomous Power State Transition) 관련 이슈 방지
    "nvme_core.default_ps_max_latency_us=0"
    "xe.enable_psr=0"
    "intel_idle.max_cstate=2" # C-state를 깊게 들어가지 않도록 제한 (테스트 후 점진적으로 상향 가능)
  ];
  hardware.enableRedistributableFirmware = true;
  boot.extraModulePackages = [ ];

  fileSystems."/" = {
    device = "/dev/disk/by-uuid/161e6b72-1ec6-4b9c-b1b7-325dd4320c2e";
    fsType = "ext4";
  };

  boot.initrd.luks.devices."luks-5a2a5e2d-749d-408e-82df-82e8607ae67e" = {
    device = "/dev/disk/by-uuid/5a2a5e2d-749d-408e-82df-82e8607ae67e";
    allowDiscards = true;
  };

  fileSystems."/boot" = {
    device = "/dev/disk/by-uuid/7078-16D1";
    fsType = "vfat";
    options = [
      "fmask=0077"
      "dmask=0077"
    ];
  };

  swapDevices = [ ];

  hardware.graphics = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver
      intel-compute-runtime
      vpl-gpu-rt # Lunar Lake 비디오 가속을 위한 핵심 패키지
    ];
  };

  hardware.cpu.intel.updateMicrocode = true;

  services.thermald.enable = true; # 인텔 CPU 발열 및 전력 관리 보조
  services.fstrim.enable = true;

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