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

{
  options.modules.bluetooth.enable = lib.mkEnableOption "Enable Bluetooth";

  config = lib.mkIf config.modules.bluetooth.enable {
    environment.systemPackages = with pkgs; [ bluez ];

    # add compatibility layer
    systemd.services.bluetooth.serviceConfig.ExecStart = lib.mkForce [
      ""
      "${pkgs.bluez}/libexec/bluetooth/bluetoothd -f /etc/bluetooth/main.conf -C"
    ];

    hardware.bluetooth.enable = true;
    hardware.bluetooth.powerOnBoot = true;
    services.blueman.enable = true;
  };
}
