From dce30b4aa66537205edc5c51a15b2918ddb020bd Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Mon, 31 Jan 2022 22:34:32 -0500 Subject: [PATCH] Add mopidy --- applications/media.nix | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/applications/media.nix b/applications/media.nix index 32f207c..f8cd698 100644 --- a/applications/media.nix +++ b/applications/media.nix @@ -1,7 +1,22 @@ # Media players and other applications -{ config, pkgs, unstable, ... }: +{ config, pkgs, lib, unstable, ... }: +let + mopidyEnv = pkgs.buildEnv { + name = "mopidy-daemon-environment"; + paths = with pkgs; [ + mopidy-mpd + mopidy-iris + mopidy-scrobbler + ]; + pathsToLink = [ "/${pkgs.mopidyPackages.python.sitePackages}" ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + makeWrapper ${pkgs.mopidy}/bin/mopidy $out/bin/mopidy \ + --prefix PYTHONPATH : $out/${pkgs.mopidyPackages.python.sitePackages} + ''; + }; +in { - # imports = [ ../../sensitive/mopidy.nix ]; environment.systemPackages = with pkgs; [ # Spotify spotify @@ -13,6 +28,8 @@ unstable.obs-studio # Soulseek client nicotine-plus + # Mopidy + extensions + mopidy ]; # Mount music directory @@ -26,4 +43,24 @@ }; enable = true; }; + + # Start mopidy as a user service, for sanity + systemd.user.services.mopidy = { + description = "Mopidy music server"; + serviceConfig = { + ExecStart = "${mopidyEnv}/bin/mopidy"; + }; + wants = [ "rclone-music.service" ]; + enable = true; + }; + # Same for the scanning service + systemd.user.services.mopidy-scan = { + description = "Mopidy files local scanner"; + serviceConfig = { + ExecStart = "${mopidyEnv}/bin/mopidy local scan"; + Type = "oneshot"; + }; + wants = [ "rclone-music.service" ]; + }; + }