{ config, lib, pkgs, inputs, ... }: with pkgs; let # HACK Replace youtube-dl with yt-dlp in mopidy-youtube mopidy-youtube-yt_dlp = mopidy-youtube.overrideAttrs (old: rec { propagatedBuildInputs = old.propagatedBuildInputs ++ [ python3.pkgs.yt-dlp ]; }); latest-mopidy-somafm = mopidy-somafm.overrideAttrs (old: rec { src = python3Packages.fetchPypi { version = "2.0.2"; pname = "Mopidy-SomaFM"; sha256 = "DC0emxkoWfjGHih2C8nINBFByf521Xf+3Ks4JRxNPLM="; }; }); soundcloud_token = builtins.readFile ../secrets/soundcloud_token; latest-mopidy-soundcloud = mopidy-soundcloud.overrideAttrs (old: rec { src = fetchFromGitHub { owner = "mopidy"; repo = "mopidy-soundcloud"; rev = "fc766b0bf17feb4fc989029b92a315a10ff453ee"; sha256 = "sha256-LftBbfs5KqqkhFQVZRh/AQKQQ+18x8RapRU1mTB7FD8="; }; propagatedBuildInputs = old.propagatedBuildInputs ++ [ python3.pkgs.beautifulsoup4 ]; }); in { # Configure pipewire as sound server services.pipewire = { enable = true; alsa = { enable = true; support32Bit = true; }; pulse.enable = true; wireplumber.enable = true; config.pipewire-pulse = let defaultConf = lib.importJSON "${inputs.nixpkgs}/nixos/modules/services/desktops/pipewire/daemon/pipewire-pulse.conf.json"; in lib.recursiveUpdate defaultConf { "pulse.properties" = { "server.address" = [ "unix:native" "tcp:127.0.0.1:4713" ]; }; }; }; security.rtkit.enable = true; # Set up Mopidy services.mopidy = { enable = true; extensionPackages = [ mopidy-mpd mopidy-local mopidy-youtube-yt_dlp mopidy-bandcamp latest-mopidy-somafm latest-mopidy-soundcloud python310Packages.ytmusicapi ]; configuration = '' [audio] output = pulsesink server=127.0.0.1 [local] media_dir = /home/coolneng/Music directories = Album Artists local:directory?type=artist&role=albumartist Albums local:directory?type=album Artists local:directory?type=artist Genres local:directory?type=genre excluded_file_extensions = .directory .html .jpeg .jpg .log .nfo .png .txt scan_timeout = 3000 [mpd] zeroconf = "" [m3u] playlists_dir = /home/coolneng/.config/mpd/playlists base_dir = /home/coolneng/Music [youtube] allow_cache = true search_results = 50 youtube_dl_package = yt_dlp musicapi_enabled = true [somafm] encoding = aac quality = highest [soundcloud] auth_token = ${soundcloud_token} explore_songs = 100 ''; }; }