Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Lightweight Music Server" application + service #147408

Closed
wants to merge 2 commits into from

Conversation

arthurl
Copy link
Contributor

@arthurl arthurl commented Nov 25, 2021

Follow up of #147206

Motivation for this change

It's a nice efficient music streaming server, especially suitable for resource constrained devices / servers. See https://github.com/epoupon/lms.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
    • armv7l-linux
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 25, 2021
@arthurl arthurl requested a review from aanderse November 25, 2021 20:09
@arthurl
Copy link
Contributor Author

arthurl commented Nov 25, 2021

As mentioned previously, the evaluation fails if settingsFormat = pkgs.formats.toml {}; was changed to settingsFormat = pkgs.formats.ini {};.

--show-trace gives:

error: while evaluating the attribute 'config.system.build.toplevel' at /etc/nixpkgs/nixos/modules/system/activation/top-level.nix:293:5:
while evaluating 'foldr' at /etc/nixpkgs/lib/lists.nix:52:20, called from /etc/nixpkgs/nixos/modules/system/activation/top-level.nix:128:12:
while evaluating 'fold'' at /etc/nixpkgs/lib/lists.nix:55:15, called from /etc/nixpkgs/lib/lists.nix:59:8:
while evaluating 'showWarnings' at /etc/nixpkgs/lib/trivial.nix:311:28, called from /etc/nixpkgs/nixos/modules/system/activation/top-level.nix:125:10:
while evaluating 'foldr' at /etc/nixpkgs/lib/lists.nix:52:20, called from /etc/nixpkgs/lib/trivial.nix:311:33:
while evaluating 'fold'' at /etc/nixpkgs/lib/lists.nix:55:15, called from /etc/nixpkgs/lib/lists.nix:59:8:
while evaluating the attribute 'warnings' at undefined position:
while evaluating 'g' at /etc/nixpkgs/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /etc/nixpkgs/lib/modules.nix:140:72, called from /etc/nixpkgs/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /etc/nixpkgs/lib/modules.nix:525:9:
while evaluating the option `warnings':
while evaluating the attribute 'mergedValue' at /etc/nixpkgs/lib/modules.nix:557:5:
while evaluating the attribute 'values' at /etc/nixpkgs/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /etc/nixpkgs/lib/modules.nix:650:7:
while evaluating anonymous function at /etc/nixpkgs/lib/modules.nix:537:28, called from /etc/nixpkgs/lib/modules.nix:537:17:
while evaluating definitions from `/etc/nixpkgs/nixos/modules/system/boot/systemd.nix':
while evaluating 'dischargeProperties' at /etc/nixpkgs/lib/modules.nix:609:25, called from /etc/nixpkgs/lib/modules.nix:538:137:
while evaluating the attribute 'value' at /etc/nixpkgs/lib/modules.nix:392:44:
while evaluating anonymous function at /etc/nixpkgs/lib/attrsets.nix:256:10, called from undefined position:
while evaluating anonymous function at /etc/nixpkgs/nixos/modules/system/boot/systemd.nix:905:16, called from /etc/nixpkgs/lib/attrsets.nix:256:16:
while evaluating 'optional' at /etc/nixpkgs/lib/lists.nix:254:20, called from /etc/nixpkgs/nixos/modules/system/boot/systemd.nix:912:16:
while evaluating the attribute 'serviceConfig.Type' at undefined position:
while evaluating 'g' at /etc/nixpkgs/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /etc/nixpkgs/lib/modules.nix:140:72, called from /etc/nixpkgs/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /etc/nixpkgs/lib/modules.nix:525:9:
while evaluating the option `systemd.services.lms.serviceConfig':
while evaluating the attribute 'mergedValue' at /etc/nixpkgs/lib/modules.nix:557:5:
while evaluating 'merge' at /etc/nixpkgs/lib/types.nix:386:20, called from /etc/nixpkgs/lib/modules.nix:559:59:
while evaluating 'filterAttrs' at /etc/nixpkgs/lib/attrsets.nix:124:23, called from /etc/nixpkgs/lib/types.nix:387:35:
while evaluating anonymous function at /etc/nixpkgs/lib/attrsets.nix:125:29, called from /etc/nixpkgs/lib/attrsets.nix:125:18:
while evaluating anonymous function at /etc/nixpkgs/lib/types.nix:387:51, called from /etc/nixpkgs/lib/attrsets.nix:125:62:
while evaluating the attribute 'ExecStart' at /etc/nixpkgs/lib/attrsets.nix:366:7:
while evaluating anonymous function at /etc/nixpkgs/lib/types.nix:387:86, called from /etc/nixpkgs/lib/attrsets.nix:366:15:
while evaluating the attribute 'optionalValue' at /etc/nixpkgs/lib/modules.nix:569:5:
while evaluating the attribute 'values' at /etc/nixpkgs/lib/modules.nix:551:9:
while evaluating the attribute 'values' at /etc/nixpkgs/lib/modules.nix:650:7:
while evaluating anonymous function at /etc/nixpkgs/lib/modules.nix:537:28, called from /etc/nixpkgs/lib/modules.nix:537:17:
while evaluating definitions from `/etc/nixpkgs/nixos/modules/services/misc/lms.nix':
while evaluating 'dischargeProperties' at /etc/nixpkgs/lib/modules.nix:609:25, called from /etc/nixpkgs/lib/modules.nix:538:137:
while evaluating the attribute 'value' at /etc/nixpkgs/lib/types.nix:391:60:
while evaluating the attribute 'text' of the derivation 'lms.conf' at /etc/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating 'toINI' at /etc/nixpkgs/lib/generators.nix:118:6, called from /etc/nixpkgs/pkgs/pkgs-lib/formats.nix:104:31:
while evaluating 'mapAttrsToStringsSep' at /etc/nixpkgs/lib/generators.nix:121:44, called from /etc/nixpkgs/lib/generators.nix:129:7:
while evaluating anonymous function at /etc/nixpkgs/lib/attrsets.nix:256:10, called from undefined position:
while evaluating 'mkSection' at /etc/nixpkgs/lib/generators.nix:124:31, called from /etc/nixpkgs/lib/attrsets.nix:256:16:
while evaluating anonymous function at /etc/nixpkgs/lib/generators.nix:88:6, called from /etc/nixpkgs/lib/generators.nix:126:14:
while evaluating 'mapAttrsToList' at /etc/nixpkgs/lib/attrsets.nix:255:23, called from /etc/nixpkgs/lib/generators.nix:88:52:
value is a boolean while a set was expected, at /etc/nixpkgs/lib/attrsets.nix:256:39

@arthurl
Copy link
Contributor Author

arthurl commented Nov 25, 2021

It doesn't matter here since the config file here is just a trivial set of key value pairs, of types int / bool / string. So either of toml or ini will work just fine. I just don't see why the ini format should fail.

@arthurl arthurl force-pushed the lightweight-music-server-PR branch 2 times, most recently from 01d4d83 to d60c16a Compare November 25, 2021 20:46
@aanderse
Copy link
Member

It doesn't matter here since the config file here is just a trivial set of key value pairs, of types int / bool / string. So either of toml or ini will work just fine. I just don't see why the ini format should fail.

The ini format requires a top level section.

I'll try to get back to this and review it tonight!

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module looks great! 👍 Someone else will come along and review the package shortly, I'm sure. Ping me if you don't hear anything back in the next few days.

@arthurl arthurl force-pushed the lightweight-music-server-PR branch 2 times, most recently from 2388de2 to f87515b Compare November 27, 2021 09:48
@arthurl
Copy link
Contributor Author

arthurl commented Nov 27, 2021

The module looks great! 👍 Someone else will come along and review the package shortly, I'm sure. Ping me if you don't hear anything back in the next few days.

Thanks!

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 labels Nov 27, 2021
@arthurl arthurl force-pushed the lightweight-music-server-PR branch from f87515b to aa4477e Compare November 30, 2021 19:39
Comment on lines +22 to +29
# Docs not needed
doxygen = null;
# Graphics libraries not needed
glew = null; libharu = null; pango = null; graphicsmagick = null;
# LMS uses only sqlite
firebird = null; libmysqlclient = null; postgresql = null;
# Qt not used
qt48Full = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really hacky and ? null should be avoided as much as possible. Can we do this different?

Copy link
Contributor Author

@arthurl arthurl Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what better way there is. 1) The wt derivation (in development/libraries/wt/default.nix) does not provide a nicer mechanism to remove components and 2) I'm don't think that the wt derivation should be expanded, given that wt simply does not build the optional components if it doesn't find the required dependencies, and that cutting out optional dependencies is likely only useful on a system that isn't served by a binary cache (e.g. armv7l, on which those dependencies are broken half the time). Having the caller pass in null seems like a robust and minimal way to include or drop those optional portions.

Or, are you against providing the "useMinimalWt" option at all? I'm happy to remove that and keep it in my overlays; I included it because I thought others might find it useful.

Comment on lines +51 to +72
patches = [
(writeText "hardcode-dependency-paths.patch" ''
diff --git a/src/libs/av/impl/Transcoder.cpp b/src/libs/av/impl/Transcoder.cpp
index 7efa044..16a6e4c 100644
--- a/src/libs/av/impl/Transcoder.cpp
+++ b/src/libs/av/impl/Transcoder.cpp
@@ -38,7 +38,7 @@ static std::filesystem::path ffmpegPath;
void
Transcoder::init()
{
- ffmpegPath = Service<IConfig>::get()->getPath("ffmpeg-file", "/usr/bin/ffmpeg");
+ ffmpegPath = Service<IConfig>::get()->getPath("ffmpeg-file", "${ffmpeg.bin}/bin/ffmpeg");
if (!std::filesystem::exists(ffmpegPath))
throw Exception {"File '" + ffmpegPath.string() + "' does not exist!"};
}
diff --git a/src/lms/main.cpp b/src/lms/main.cpp
index 98c0cec..b60e26a 100644
--- a/src/lms/main.cpp
+++ b/src/lms/main.cpp
@@ -53,7 +53,7 @@ generateWtConfig(std::string execPath)
const std::filesystem::path wtConfigPath {Service<IConfig>::get()->getPath("working-dir") / "wt_config.xml"};
const std::filesystem::path wtLogFilePath {Service<IConfig>::get()->getPath("log-file", "/var/log/lms.log")};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write that into a file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not possible, because I need a reference to the ffmpeg and wt paths (which is the whole point of the patch).

Or am I missing something..?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add: the author of lms did not provide for a command line option to set those paths, so the usual solution of writing a wrapper shell script won't work here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be cleaner to write the diff into a file with placeholders for the parts you need to modify and then use sed or something to fix them up at configure time. I think that's what Sandro meant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's possible, but seems way uglier than simply inlining the patch?

@arthurl arthurl force-pushed the lightweight-music-server-PR branch 2 times, most recently from 2ad8660 to aa4477e Compare November 30, 2021 20:57
@arthurl
Copy link
Contributor Author

arthurl commented Dec 2, 2021

@aanderse hi Aaron, could use some of your help here to move things along. Thanks!

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aanderse hi Aaron, could use some of your help here to move things along. Thanks!

Certainly. Let me try my best here...

Written in C++, it has a low memory footprint and even comes with a
recommendation engine.
'';
homepage = https://github.com/epoupon/lms;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homepage = https://github.com/epoupon/lms;
downloadPage = "https://github.com/epoupon/lms";
maintainers = with maintainers; [ arthur ];
license = licenses.gpl3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpl3 was deprecated a little while ago: please choose gpl3Plus or gpl3Only.

Comment on lines +55 to +65
--- a/src/libs/av/impl/Transcoder.cpp
+++ b/src/libs/av/impl/Transcoder.cpp
@@ -38,7 +38,7 @@ static std::filesystem::path ffmpegPath;
void
Transcoder::init()
{
- ffmpegPath = Service<IConfig>::get()->getPath("ffmpeg-file", "/usr/bin/ffmpeg");
+ ffmpegPath = Service<IConfig>::get()->getPath("ffmpeg-file", "${ffmpeg.bin}/bin/ffmpeg");
if (!std::filesystem::exists(ffmpegPath))
throw Exception {"File '" + ffmpegPath.string() + "' does not exist!"};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/epoupon/lms/blob/835e705e09176797ce9f910640ac091c80b5f717/conf/lms.conf#L8 we could do this in the module instead:

services.lms.settings.ffmpeg-file = "${pkgs.ffmpeg_4.bin}/bin/ffmpeg";

Or is the issue that you want to be able to use this software without a configuration file?

Comment on lines +74 to +75
- const std::filesystem::path wtResourcesPath {Service<IConfig>::get()->getPath("wt-resources", "/usr/share/Wt/resources")};
+ const std::filesystem::path wtResourcesPath {Service<IConfig>::get()->getPath("wt-resources", "${wt-lms}/share/Wt/resources")};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is everyone opposed to:

postPatch = ''
  substituteInPlace src/lms/main.cpp \
    --replace "/usr/share/Wt/resources" "${wt-lms}/share/Wt/resources" \
    --replace "/usr/bin/ffmpeg" "${ffmpeg_4.bin}/bin/ffmpeg"
'';

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there is a bit of a worry that it might accidentally match other lines than the ones in this patch? But then again those paths would never be correct on NixOS you have a fair point there.

Then again less patching is better so if we can get away with only a config tweak I'd just leave it entirely unpatched. Seems like the config file has an entry for the wt-resources dir too.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 19, 2022
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@mksafavi
Copy link
Contributor

I was wondering why this PR never got merged. I read the comments but didn't understand the final status.
Should I make a new PR for this as it is a couple of years old?
I've made a "minimal" working package for it.

@mksafavi mksafavi mentioned this pull request Apr 19, 2024
13 tasks
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@Scrumplex
Copy link
Member

As #305308 was merged, this can be closed

@Scrumplex Scrumplex closed this Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants