.hive/modules/hardware/sound.nix

59 lines
1.7 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
cfg = config.hive.sound;
in {
options = {
hive.sound = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable sound with pipewire.";
};
noisetorch = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable Noisetorch for noise cancellation.";
};
noisetorch-threshold = lib.mkOption {
type = lib.types.int;
default = -1;
description = "Set the noise cancellation threshold for Noisetorch.";
};
};
};
config = lib.mkIf cfg.enable {
# Enable sound with pipewire.
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
programs.noisetorch.enable = cfg.noisetorch;
systemd.user.services.noisetorch-autoload = lib.mkIf cfg.noisetorch {
description = "Automatically load Noisetorch on user login";
after = ["pipewire.service"];
requires = ["pipewire.service"];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.noisetorch}/bin/noisetorch -i -t ${toString cfg.noisetorch-threshold}";
ExecStop = "${pkgs.noisetorch}/bin/noisetorch -u";
RemainAfterExit = true;
};
wantedBy = ["default.target"];
};
};
}