summaryrefslogtreecommitdiffstats
path: root/hosts/nepsis/audio-linux.nix
blob: 845440eb20401f24a3508fa9a26d96dbf5e70fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  config,
  pkgs,
  username,
  ...
}: {
  # Whether to enable the RealtimeKit system service, which hands out realtime scheduling priority to user processes on demand. For example, PulseAudio and PipeWire use this to acquire realtime priority.
  security.rtkit.enable = true;

  services.pipewire = {
    enable = true;
    audio.enable = true;
    pulse.enable = true;
    alsa.enable = true;
    # Required for services.mpd to find it
    # systemWide = true;
    wireplumber.enable = true;
  };
  services.pulseaudio.enable = false;

  systemd.user.services.mpd = {
    description = "Music Player Daemon";
    wantedBy = ["default.target"];
    serviceConfig = {
      ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon ${../../dotfiles/mpd/mpd.conf}";
      Restart = "on-failure";
    };
  };

  # THIS DOES NOT WORK.
  # # Requires pipewire in systemWide mode
  # # https://discourse.nixos.org/t/pipewire-host-not-found-and-is-inactive/41533/2
  # services.mpd = {
  #   enable = true;
  #   user = username;
  #   settings = {
  #     music_directory = "/home/${username}/Music";
  #     playlist_directory = "/home/${username}/Music/playlists";
  #     # Old Config
  #     # music_directory    "~/Music"
  #     # playlist_directory "~/Music/playlists"
  #     # db_file            "~/.local/share/mpd/database"
  #     # state_file         "~/.local/share/mpd/state"
  #     # log_file           "syslog"
  #     # auto_update = true;
  #     # restore_paused = true;
  #
  #     audio_output = [
  #       {
  #         type = "pipewire";
  #         name = "PipeWire Output";
  #       }
  #     ];
  #   };
  # };
  # add to pipewire group to see the audio devices: https://search.nixos.org/options?channel=unstable&query=services.pipewire&type=options
  # systemd.services.mpd.serviceConfig.SupplementaryGroups = ["pipewire"];
}