From 5ea57eaea62b61d5960e1fbf50e5499dfd7ef751 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 20 Nov 2022 23:14:51 +0100 Subject: [PATCH] audio: enable security.rtkit for pipewire This should avoid stuttering audio when CPU is busy --- modules/audio/default.nix | 78 ++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/modules/audio/default.nix b/modules/audio/default.nix index be18e0fe..f6d52e71 100644 --- a/modules/audio/default.nix +++ b/modules/audio/default.nix @@ -1,11 +1,14 @@ -{ lib, config, pkgs, ... }: -with lib; -let +{ + 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 -{ +in { options.pub-solar.audio = { enable = mkEnableOption "Life in highs and lows"; mopidy.enable = mkEnableOption "Life with mopidy"; @@ -20,40 +23,49 @@ in }; config = mkIf cfg.enable { - users.users = pkgs.lib.setAttrByPath [ psCfg.user.name ] { - extraGroups = [ "audio" ]; + users.users = pkgs.lib.setAttrByPath [psCfg.user.name] { + extraGroups = ["audio"]; }; - 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 - ] ++ (if cfg.spotify.enable then [ pkgs.spotify-tui ] else [ ]); - xdg.configFile."vimpc/vimpcrc".source = ./.config/vimpc/vimpcrc; - systemd.user.services.easyeffects = import ./easyeffects.service.nix pkgs; + 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 + ] + ++ ( + if cfg.spotify.enable + then [pkgs.spotify-tui] + else [] + ); + xdg.configFile."vimpc/vimpcrc".source = ./.config/vimpc/vimpcrc; + systemd.user.services.easyeffects = import ./easyeffects.service.nix pkgs; - services.spotifyd = mkIf cfg.spotify.enable { - enable = true; - settings = { - global = { - username = cfg.spotify.username; - password_cmd = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus ${pkgs.libsecret}/bin/secret-tool lookup spotify password"; - bitrate = 320; - volume_normalisation = true; - no_audio_cache = false; - max_cache_size = 1000000000; + services.spotifyd = mkIf cfg.spotify.enable { + enable = true; + settings = { + global = { + username = cfg.spotify.username; + password_cmd = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus ${pkgs.libsecret}/bin/secret-tool lookup spotify password"; + bitrate = 320; + volume_normalisation = true; + no_audio_cache = false; + max_cache_size = 1000000000; + }; }; }; }; - }; + # rtkit is optional but recommended + security.rtkit.enable = true; # Enable sound using pipewire-pulse services.pipewire = { enable = true; @@ -63,7 +75,7 @@ in config.pipewire = { context.default.clock = { - allowed-rates = [ 44100 48000 88200 96000 ]; + allowed-rates = [44100 48000 88200 96000]; rate = 44100; }; };