69 lines
2.1 KiB
Nix
69 lines
2.1 KiB
Nix
{ lib, config, pkgs, ... }:
|
|
with lib;
|
|
let
|
|
psCfg = config.pub-solar;
|
|
cfg = config.pub-solar.audio;
|
|
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
|
|
in
|
|
{
|
|
options.pub-solar.audio = {
|
|
enable = mkEnableOption "Life in highs and lows";
|
|
mopidy.enable = mkEnableOption "Life with mopidy";
|
|
bluetooth.enable = mkEnableOption "Life with bluetooth";
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] {
|
|
home.packages = [
|
|
# easyeffects, e.g. for microphone noise filtering
|
|
easyeffects
|
|
mu
|
|
pavucontrol
|
|
pa_applet
|
|
playerctl
|
|
# Needed for pactl cmd, until pw-cli is more mature (vol up/down hotkeys?)
|
|
pulseaudio
|
|
vimpc
|
|
];
|
|
xdg.configFile."vimpc/vimpcrc".source = ./.config/vimpc/vimpcrc;
|
|
systemd.user.services.easyeffects = import ./easyeffects.service.nix pkgs;
|
|
};
|
|
|
|
# Enable sound using pipewire-pulse
|
|
services.pipewire = {
|
|
enable = true;
|
|
alsa.enable = true;
|
|
alsa.support32Bit = true;
|
|
pulse.enable = true;
|
|
|
|
config.pipewire = {
|
|
context.default.clock = {
|
|
allowed-rates = [ 44100 48000 88200 96000 ];
|
|
rate = 44100;
|
|
};
|
|
};
|
|
config.pipewire-pulse = builtins.fromJSON (builtins.readFile ./pipewire-pulse.conf.json);
|
|
};
|
|
|
|
# Bluetooth configuration using wireplumber
|
|
# https://nixos.wiki/wiki/PipeWire#Bluetooth_Configuration
|
|
environment.etc = mkIf cfg.bluetooth.enable {
|
|
"wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
|
|
bluez_monitor.properties = {
|
|
["bluez5.enable-sbc-xq"] = true,
|
|
["bluez5.enable-msbc"] = true,
|
|
["bluez5.enable-hw-volume"] = true,
|
|
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
|
|
}
|
|
'';
|
|
};
|
|
|
|
# Enable bluetooth
|
|
hardware.bluetooth.enable = mkIf cfg.bluetooth.enable true;
|
|
services.blueman.enable = mkIf cfg.bluetooth.enable true;
|
|
|
|
# Enable audio server & client
|
|
services.mopidy = mkIf cfg.mopidy.enable ((import ./mopidy.nix) pkgs);
|
|
};
|
|
}
|