{ lib, config, ... }:
with lib;
let
  cfg = config.modules.hardware.laptop;
in
{
  options.modules.hardware.laptop = {
    enable = mkEnableOption "Install Laptop utils";

    governor_battery = mkOption {
      type = types.str;
      default = "powersave";
    };
    turbo_battery = mkOption {
      type = types.enum ["always" "never" "auto"];
      default = "never";
    };
    governor_ac = mkOption {
      type = types.str;
      default = "schedutil";
    };
    turbo_ac = mkOption {
      type = types.enum ["always" "never" "auto"];
      default = "never";
    };
  };
  config = mkIf cfg.enable {

    # Wifi is installed on laptops
    networking.wireless.iwd.enable = true;

    # And cpufreq
    services.auto-cpufreq = {
      enable = true;
      settings = {
        battery = {
          governor = cfg.governor_battery;
          turbo = cfg.turbo_battery;
        };
        charger = {
          governor = cfg.governor_ac;
          turbo = cfg.turbo_ac;
        };
      };
    };
  };
}
