helm/modules/hardware/audio.nix
Henrik Lissner a75c64d04a
Rewrite to use flakes
This puts a hard dependency on 20.09, but that's to be expected.
2020-10-11 01:31:33 -04:00

32 lines
989 B
Nix

{ options, config, lib, pkgs, ... }:
with lib;
with lib.my;
let cfg = config.modules.hardware.audio;
in {
options.modules.hardware.audio = {
enable = mkBoolOpt false;
};
config = mkIf cfg.enable {
sound.enable = true;
hardware.pulseaudio.enable = true;
# HACK Prevents ~/.esd_auth files by disabling the esound protocol module
# for pulseaudio, which I likely don't need. Is there a better way?
hardware.pulseaudio.configFile =
let inherit (pkgs) runCommand pulseaudio;
paConfigFile =
runCommand "disablePulseaudioEsoundModule"
{ buildInputs = [ pulseaudio ]; } ''
mkdir "$out"
cp ${pulseaudio}/etc/pulse/default.pa "$out/default.pa"
sed -i -e 's|load-module module-esound-protocol-unix|# ...|' "$out/default.pa"
'';
in mkIf config.hardware.pulseaudio.enable
"${paConfigFile}/default.pa";
user.extraGroups = [ "audio" ];
};
}