{ pkgs, ... }:
{
  # support power features such as suspend to ram
  powerManagement.enable = true;
  # tune power saving options on boot
  powerManagement.powertop.enable = true;
  # thermald proactively prevents overheating on intel CPUs and works well with other tools
  services.thermald.enable = true;
  # power-profile-daemon for power management
  services.power-profiles-daemon.enable = true;
  # manage fans for macbook devices
  services.mbpfan.enable = true;

  # better performance than the actual intel driver
  services.xserver.videoDrivers = [ "modesetting" ];

  # needed for our broadcom/brcm 4377b chip to work
  hardware.firmware = with pkgs; [
    my.apple-firmware
  ];

  # handle suspend issues (fuck you broadcom!)
  powerManagement.powerDownCommands = ''
    ${pkgs.kmod}/bin/modprobe -r brcmfmac_wcc
    ${pkgs.kmod}/bin/modprobe -r brcmfmac
    ${pkgs.kmod}/bin/modprobe -r hci_bcm4377
  '';
  powerManagement.resumeCommands = ''
    ${pkgs.kmod}/bin/modprobe hci_bcm4377
    ${pkgs.kmod}/bin/modprobe brcmfmac
    ${pkgs.kmod}/bin/modprobe brcmfmac_wcc
  '';

  # VA-API
  hardware.graphics = {
    extraPackages = with pkgs; [
      intel-media-driver
      intel-vaapi-driver
      libvdpau-va-gl
    ];

    extraPackages32 = with pkgs.pkgsi686Linux; [
      intel-media-driver
      intel-vaapi-driver
      libvdpau-va-gl
    ];
  };

  environment.variables = {
    LIBVA_DRIVER_NAME= "iHD";
    VDPAU_DRIVER = "va_gl";
    # VA-API on firefox
    MOZ_DISABLE_RDD_SANDBOX = "1";
  };

  environment.systemPackages = with pkgs; [ intel-gpu-tools ];

  boot.kernelParams = [
    # enable the i915 sandybridge framebuffer compression (475mw savings)
    "i915.i915_enable_fbc=1"
    "i915.fastboot=1"
    "i915.enable_gvt=1"
  ];
}