{ config, pkgs, lib, ... }:

{
  imports = [
    ./hardware-configuration.nix
    ../default.nix
  ];

  stitchyconf = {
    artPkgs.enable = true;
  };

  services.logind.powerKey = "ignore";
  services.logind.powerKeyLongPress = "poweroff";
  networking = {
    hostName = "lappy";
    networkmanager.enable = true;
  };
  time.timeZone = "America/Lost_Angeles";

  services.syncthing = {
    enable = true;
    user = "stitchynyan";
    openDefaultPorts = true;
    databaseDir = "/home/stitchynyan/.local/share/syncthing";
    dataDir = "/home/stitchynyan";
  };

  boot.kernelParams = [
    #"i915.enable_guc=7"
    "intel_iommu=on"
    "iommu=pt"
    "kernel.yama.ptrace_scope=0"
  ];

  virtualisation = {
    docker.enable = true;
    libvirtd.enable = true;
    waydroid.enable = true;
  };
  hardware.bluetooth.enable = true;
  hardware.bluetooth.settings.General.Experimental = true;
  hardware.graphics = {
    enable = true;
    enable32Bit= true;
    extraPackages = lib.attrVals [
      "intel-compute-runtime"
      "intel-media-driver"
    ] pkgs;
  };

  systemd.extraConfig = "AllowedCPUs=8-15";

  services.tlp = {
      enable = true;
      settings = {

        CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
        CPU_HWP_DYN_BOOST_ON_BAT = false;
        CPU_SCALING_GOVERNOR_ON_BAT = "schedutil";

        CPU_MIN_PERF_ON_AC = 0;
        CPU_MAX_PERF_ON_AC = 100;
        CPU_MIN_PERF_ON_BAT = 0;
        CPU_MAX_PERF_ON_BAT = 50;

        INTEL_GPU_MAX_FREQ_ON_BAT = 800;
        INTEL_GPU_BOOST_FREQ_ON_BAT = 1000;

        NMI_WATCHDOG = false;
        PCIE_ASPM_ON_AC = "default";
        PCIE_ASPM_ON_BAT = "powersupersave";
        PLATFORM_PROFILE_ON_BAT = "low-power";
        RUNTIME_PM_ON_BAT = "auto";
        WOL_DISABLE = true;
        SCHED_POWERSAVE_ON_BAT = true;

        USB_AUTOSUSPEND = true;

        TLP_DEFAULT_MODE = "BAT";
        TLP_PERSISTENT_DEFAULT = 1;

        #Optional helps save long term battery health
        START_CHARGE_THRESH_BAT0 = 40; # 40 and bellow it starts to charge
        STOP_CHARGE_THRESH_BAT0 = 90; # 80 and above it stops charging
      };
  };

  # Read the Docs before Changing
  system.stateVersion = "23.05";
}