From d939ce585c611c00ca44145a74acab04c20619ad Mon Sep 17 00:00:00 2001 From: winston Date: Sat, 11 May 2024 00:26:54 +0200 Subject: [PATCH] mopidy: make scan service depend on `mopidy-local` --- modules/services/mopidy.nix | 4 +++- .../modules/services/mopidy/basic-configuration.nix | 3 ++- tests/modules/services/mopidy/default.nix | 6 +++++- tests/modules/services/mopidy/mopidy-scan.nix | 13 +++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/modules/services/mopidy/mopidy-scan.nix diff --git a/modules/services/mopidy.nix b/modules/services/mopidy.nix index 37642a290..b02708578 100644 --- a/modules/services/mopidy.nix +++ b/modules/services/mopidy.nix @@ -48,6 +48,8 @@ let configFilePaths = concatStringsSep ":" ([ "${config.xdg.configHome}/mopidy/mopidy.conf" ] ++ cfg.extraConfigFiles); + hasMopidyLocal = builtins.elem pkgs.mopidy-local cfg.extensionPackages; + in { meta.maintainers = [ hm.maintainers.foo-dogsquared ]; @@ -133,7 +135,7 @@ in { Install.WantedBy = [ "default.target" ]; }; - systemd.user.services.mopidy-scan = { + systemd.user.services.mopidy-scan = mkIf hasMopidyLocal { Unit = { Description = "mopidy local files scanner"; Documentation = [ "https://mopidy.com/" ]; diff --git a/tests/modules/services/mopidy/basic-configuration.nix b/tests/modules/services/mopidy/basic-configuration.nix index 418bfde1f..2bffbd681 100644 --- a/tests/modules/services/mopidy/basic-configuration.nix +++ b/tests/modules/services/mopidy/basic-configuration.nix @@ -3,6 +3,7 @@ { services.mopidy = { enable = true; + extensionPackages = [ ]; settings = { file = { enabled = true; @@ -29,7 +30,7 @@ nmt.script = '' assertFileExists home-files/.config/systemd/user/mopidy.service - assertFileExists home-files/.config/systemd/user/mopidy-scan.service + assertPathNotExists home-files/.config/systemd/user/mopidy-scan.service assertFileExists home-files/.config/mopidy/mopidy.conf assertFileContent home-files/.config/mopidy/mopidy.conf \ diff --git a/tests/modules/services/mopidy/default.nix b/tests/modules/services/mopidy/default.nix index 2f2c33d23..6d71e1f54 100644 --- a/tests/modules/services/mopidy/default.nix +++ b/tests/modules/services/mopidy/default.nix @@ -1 +1,5 @@ -{ mopidy-basic-configuration = ./basic-configuration.nix; } +{ + mopidy-basic-configuration = ./basic-configuration.nix; + mopidy-scan = ./mopidy-scan.nix; +} + diff --git a/tests/modules/services/mopidy/mopidy-scan.nix b/tests/modules/services/mopidy/mopidy-scan.nix new file mode 100644 index 000000000..58a035a6a --- /dev/null +++ b/tests/modules/services/mopidy/mopidy-scan.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + services.mopidy = { + enable = true; + extensionPackages = [ pkgs.mopidy-local ]; + }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/mopidy.service + assertFileExists home-files/.config/systemd/user/mopidy-scan.service + ''; +}