current
 1{den, ...}: {
 2  den.aspects.desktop.includes = [den.aspects.desktop._.pipewire];
 3
 4  den.aspects.desktop.provides.pipewire.nixos = {pkgs, ...}: {
 5    environment.systemPackages = with pkgs; [
 6      pulseaudio # provides `pactl`, which is required by some apps(e.g. sonic-pi)
 7    ];
 8
 9    # PipeWire is a new low-level multimedia framework.
10    # It aims to offer capture and playback for both audio and video with minimal latency.
11    # It support for PulseAudio-, JACK-, ALSA- and GStreamer-based applications.
12    # PipeWire has a great bluetooth support, it can be a good alternative to PulseAudio.
13    #     https://nixos.wiki/wiki/PipeWire
14    services.pipewire = {
15      enable = true;
16      # package = pkgs.pipewire;
17      alsa.enable = true;
18      alsa.support32Bit = true;
19      pulse.enable = true;
20      # If you want to use JACK applications, uncomment this
21      jack.enable = true;
22      wireplumber.enable = true;
23    };
24    # rtkit is optional but recommended
25    security.rtkit.enable = true;
26    # Disable pulseaudio, it conflicts with pipewire too.
27    services.pulseaudio.enable = false;
28
29    services.pipewire.extraConfig.pipewire."99-fix-lagging" = {
30      "context.properties" = {
31        "default.clock.rate" = 48000;
32        "default.clock.quantum" = 512;
33        "default.clock.min-quantum" = 512;
34        "default.clock.max-quantum" = 512;
35      };
36    };
37  };
38}