{
  config,
  pkgs,
  lib,
  ...
}: {
  # Unfree </3
  nixpkgs = {
    config = {
      allowUnfreePredicate = pkg:
        builtins.elem (lib.getName pkg) [
          "nvidia-x11"
          "nvidia-settings"
          "steam"
          "steam-original"
          "steam-run"
          "steamcmd"
        ];
    };
  };

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

  # environment.variables = {
  #   GBM_BACKEND = "nvidia-drm";
  #   LIBVA_DRIVER_NAME = "nvidia";
  #   __GLX_VENDOR_LIBRARY_NAME = "nvidia";
  # };

  services.picom = {
    enable = true;
    vSync = true;
    settings = {
      "unredir-if-possible" = true;
    };
  };

  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
    dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
  };

  hardware = {
    opengl = {
      # this fixes the "glXChooseVisual failed" bug, context: https://github.com/NixOS/nixpkgs/issues/47932
      enable = true;
      driSupport = true;
      driSupport32Bit = true;
    };

    # optionally enable 32bit pulseaudio support if pulseaudio is enabled
    pulseaudio.support32Bit = config.hardware.pulseaudio.enable;

    nvidia = {
      open = false;
      modesetting.enable = true;
      nvidiaSettings = true;
      forceFullCompositionPipeline = true;

      # powerManagement.enable = true;
      # prime = {
      #   reverseSync.enable = true;
      #   # offload = {
      #   #   enable = true;
      #   #   enableOffloadCmd = true;
      #   # };

      #   intelBusId = "PCI:0:2:0";
      #   nvidiaBusId = "PCI:1:0:0";
      # };
    };
    
    opengl.extraPackages = with pkgs; [nvidia-vaapi-driver];
  };
}
