61 lines
1.5 KiB
Nix
61 lines
1.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with pkgs;
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.mopidy;
|
|
|
|
mopidyEnv = buildEnv {
|
|
name = "mopidy-with-extensions-${mopidy.version}";
|
|
paths = closePropagation cfg.extensionPackages;
|
|
pathsToLink = [ "/${mopidyPackages.python.sitePackages}" ];
|
|
buildInputs = [ makeWrapper ];
|
|
postBuild = ''
|
|
makeWrapper ${mopidy}/bin/mopidy $out/bin/mopidy \
|
|
--prefix PYTHONPATH : $out/${mopidyPackages.python.sitePackages}
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
services.mopidy = {
|
|
enable = mkEnableOption "Mopidy, a music player daemon";
|
|
|
|
extensionPackages = mkOption {
|
|
default = [ ];
|
|
type = types.listOf types.package;
|
|
example = literalExpression "[ pkgs.mopidy-spotify ]";
|
|
description = ''
|
|
Mopidy extensions that should be loaded by the service.
|
|
'';
|
|
};
|
|
|
|
settings = mkOption {
|
|
default = { };
|
|
type = with types; attrsOf (attrsOf (oneOf [ str int bool ]));
|
|
description = ''
|
|
The settings that Mopidy should use.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
xdg.configFile."mopidy/mopidy.conf".text = lib.generators.toINI { } cfg.settings;
|
|
|
|
home.packages = [ mopidyEnv ];
|
|
|
|
systemd.user.services.mopidy = {
|
|
Unit = {
|
|
Description = "mopidy music player daemon";
|
|
After = [ "network.target" "sound.target" ];
|
|
};
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
Service = {
|
|
ExecStart = "${mopidyEnv}/bin/mopidy";
|
|
};
|
|
};
|
|
};
|
|
}
|