1 { config, lib, pkgs, ... }:
7 uid = config.ids.uids.mopidy;
8 gid = config.ids.gids.mopidy;
9 cfg = config.services.mopidy;
11 mopidyConf = writeText "mopidy.conf" cfg.configuration;
13 mopidyEnv = buildEnv {
14 name = "mopidy-with-extensions-${mopidy.version}";
15 paths = closePropagation cfg.extensionPackages;
16 pathsToLink = [ "/${mopidyPackages.python.sitePackages}" ];
17 nativeBuildInputs = [ makeWrapper ];
19 makeWrapper ${mopidy}/bin/mopidy $out/bin/mopidy \
20 --prefix PYTHONPATH : $out/${mopidyPackages.python.sitePackages}
29 enable = mkEnableOption "Mopidy, a music player daemon";
32 default = "/var/lib/mopidy";
35 The directory where Mopidy stores its state.
39 extensionPackages = mkOption {
41 type = types.listOf types.package;
42 example = literalExpression "[ pkgs.mopidy-spotify ]";
44 Mopidy extensions that should be loaded by the service.
48 configuration = mkOption {
52 The configuration that Mopidy should use.
56 extraConfigFiles = mkOption {
58 type = types.listOf types.str;
60 Extra config file read by Mopidy when the service starts.
61 Later files in the list overrides earlier configuration.
71 config = mkIf cfg.enable {
73 systemd.tmpfiles.settings."10-mopidy".${cfg.dataDir}.d = {
78 systemd.services.mopidy = {
79 wantedBy = [ "multi-user.target" ];
80 after = [ "network-online.target" "sound.target" ];
81 wants = [ "network-online.target" ];
82 description = "mopidy music player daemon";
84 ExecStart = "${mopidyEnv}/bin/mopidy --config ${concatStringsSep ":" ([mopidyConf] ++ cfg.extraConfigFiles)}";
89 systemd.services.mopidy-scan = {
90 description = "mopidy local files scanner";
92 ExecStart = "${mopidyEnv}/bin/mopidy --config ${concatStringsSep ":" ([mopidyConf] ++ cfg.extraConfigFiles)} local scan";
98 users.users.mopidy = {
101 extraGroups = [ "audio" ];
102 description = "Mopidy daemon user";
106 users.groups.mopidy.gid = gid;