{ config, pkgs, inputs, ... }:

{

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

services.pipewire = {
  enable = true;
  alsa.enable = true;
  pulse.enable = true;
  wireplumber.enable = true;
};
services.displayManager.gdm.enable = false;
services.displayManager.sddm.enable = true;

  boot = {
    initrd.luks.devices."luks-cbf20b12-90f7-4fbb-95d3-1320eece4d89".device = "/dev/disk/by-uuid/cbf20b12-90f7-4fbb-95d3-1320eece4d89";
    kernelParams = [
      "nvidia_drm.modeset=1"
      "nvidia_drm.fbdev=1"
      "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
      "module_blacklist=amdgpu"
    ];
  };

  #fileSystems."/run/media/admin/08cabc7a-9a6e-4c21-8a07-6663af77b705" = {
  #  device = "/dev/08cabc7a-9a6e-4c21-8a07-6663af77b705";
  #  fsType = "ext4";
  #  options = ["rw,nosuid,nodev,relatime,errors=remount-ro"];
 # };

  networking = {
    hostName = "nixos-desktop";
    interfaces.enp42s0 = {
      wakeOnLan.enable = true;
      ipv4.addresses = [
        {
          address = "192.168.30.40";
          prefixLength = 24;
        }
      ];
    };
    defaultGateway = "192.168.30.1";
    nameservers = [ "192.168.0.1" "1.1.1.1" ];
  };

  services = {
    xserver.videoDrivers = [ "nvidia" ];
  };

  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = true;
    powerManagement.finegrained = false;
    open = true;
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

  # this fixes the sleep/wake issue FUCK NVIDIA
#  systemd.services."systemd-suspend" = {
#    serviceConfig = {
#      Environment = ''"SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false"'';
#    };
#  };

  # fixes hardware accel on nvidia open FUCK NVIDIA
  hardware.graphics.extraPackages = [
    pkgs.nvidia-vaapi-driver
  ];

  systemd.user.services.reset-gnome-idle-on-resume = {
  description = "Reset GNOME idle timer after resume";
  after = [ "suspend.target" ];
  wantedBy = [ "suspend.target" ];
  environment = {
    DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/1000/bus";
  };
  script = ''
    sleep 3
    # Tell gnome-session we have user activity
    ${pkgs.dbus}/bin/dbus-send \
      --session \
      --dest=org.gnome.Mutter.IdleMonitor \
      /org/gnome/Mutter/IdleMonitor/Core \
      org.gnome.Mutter.IdleMonitor.ResetIdleTime
  '';
  serviceConfig = {
    Type = "oneshot";
    User = "admin";
  };
};

  environment.variables = {
    NVD_BACKEND = "direct";
    LIBVA_DRIVER_NAME = "nvidia";
  };

  # cachyos kernel
  # nixpkgs.overlays = [ inputs.nix-cachyos-kernel.overlays.pinned ];
  # boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest;
  # nix.settings.substituters = [ "https://attic.xuyh0120.win/lantian" ];
  # nix.settings.trusted-public-keys = [ "lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc=" ];

  system.stateVersion = "24.11";
}
