{
  lib,
  config,
  ...
}: let
  inherit (lib) mkEnableOption mkIf;
  cfg = config.horseman.hardware.audio;
in {
  options = {
    horseman.hardware.audio = {
      enable = mkEnableOption "Audio options";
    };
  };

  config = mkIf cfg.enable {
    services.pulseaudio.enable = false;
    services.jack = {
      jackd.enable = false;
      alsa.enable = true;
      loopback.enable = false;
    };
    users.extraUsers.horseman.extraGroups = ["jackaudio"];
  };
}
