-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
Init gerbera package and reuse mediatomb service #82429
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,23 +6,27 @@ let | |
|
||
gid = config.ids.gids.mediatomb; | ||
cfg = config.services.mediatomb; | ||
name = cfg.package.pname; | ||
pkg = cfg.package; | ||
|
||
mtConf = pkgs.writeText "config.xml" '' | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd"> | ||
<interface>${cfg.interface}</interface> | ||
<server> | ||
<ui enabled="yes" show-tooltips="yes"> | ||
<accounts enabled="no" session-timeout="30"> | ||
<account user="mediatomb" password="mediatomb"/> | ||
<account user="${name}" password="${name}"/> | ||
</accounts> | ||
</ui> | ||
<name>${cfg.serverName}</name> | ||
<udn>uuid:${cfg.uuid}</udn> | ||
<home>${cfg.dataDir}</home> | ||
<webroot>${pkgs.mediatomb}/share/mediatomb/web</webroot> | ||
<interface>${cfg.interface}</interface> | ||
<webroot>${pkg}/share/${name}/web</webroot> | ||
<storage> | ||
<sqlite3 enabled="yes"> | ||
<database-file>mediatomb.db</database-file> | ||
<database-file>${name}.db</database-file> | ||
</sqlite3> | ||
</storage> | ||
<protocolInfo extend="${if cfg.ps3Support then "yes" else "no"}"/> | ||
|
@@ -48,10 +52,10 @@ let | |
</server> | ||
<import hidden-files="no"> | ||
<scripting script-charset="UTF-8"> | ||
<common-script>${pkgs.mediatomb}/share/mediatomb/js/common.js</common-script> | ||
<playlist-script>${pkgs.mediatomb}/share/mediatomb/js/playlists.js</playlist-script> | ||
<common-script>${pkg}/share/${name}/js/common.js</common-script> | ||
<playlist-script>${pkg}/share/${name}/js/playlists.js</playlist-script> | ||
<virtual-layout type="builtin"> | ||
<import-script>${pkgs.mediatomb}/share/mediatomb/js/import.js</import-script> | ||
<import-script>${pkg}/share/${name}/js/import.js</import-script> | ||
</virtual-layout> | ||
</scripting> | ||
<mappings> | ||
|
@@ -164,15 +168,24 @@ in { | |
|
||
serverName = mkOption { | ||
type = types.str; | ||
default = "mediatomb"; | ||
default = "Gerbera (Mediatomb)"; | ||
description = '' | ||
How to identify the server on the network. | ||
''; | ||
}; | ||
|
||
package = mkOption { | ||
type = types.package; | ||
example = literalExample "pkgs.mediatomb"; | ||
default = pkgs.gerbera; | ||
description = '' | ||
Underlying package to be used with the module (default: pkgs.gerbera). | ||
''; | ||
}; | ||
|
||
ps3Support = mkOption { | ||
type = types.bool; | ||
default = false; | ||
default = true; | ||
description = '' | ||
Whether to enable ps3 specific tweaks. | ||
WARNING: incompatible with DSM 320 support. | ||
|
@@ -206,20 +219,20 @@ in { | |
|
||
dataDir = mkOption { | ||
type = types.path; | ||
default = "/var/lib/mediatomb"; | ||
default = "/var/lib/" + name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will cause existing installations to mysteriously break. Either leaving the default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, well this was the intention since it has to be done sooner or later. I'll add it to the release notes to ease the transition. |
||
description = '' | ||
The directory where mediatomb stores its state, data, etc. | ||
The directory where ${name} stores its state, data, etc. | ||
''; | ||
}; | ||
|
||
user = mkOption { | ||
default = "mediatomb"; | ||
description = "User account under which mediatomb runs."; | ||
description = "User account under which ${name} runs."; | ||
}; | ||
|
||
group = mkOption { | ||
default = "mediatomb"; | ||
description = "Group account under which mediatomb runs."; | ||
description = "Group account under which ${name} runs."; | ||
}; | ||
|
||
port = mkOption { | ||
|
@@ -247,7 +260,7 @@ in { | |
type = types.bool; | ||
default = false; | ||
description = '' | ||
Allow mediatomb to create and use its own config file inside ${cfg.dataDir}. | ||
Allow ${name} to create and use its own config file inside ${cfg.dataDir}. | ||
''; | ||
}; | ||
}; | ||
|
@@ -257,12 +270,12 @@ in { | |
###### implementation | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.mediatomb = { | ||
description = "MediaTomb media Server"; | ||
systemd.services."${name}"= { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the module is called |
||
description = "${cfg.serverName} media Server"; | ||
after = [ "network.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
path = [ pkgs.mediatomb ]; | ||
serviceConfig.ExecStart = "${pkgs.mediatomb}/bin/mediatomb -p ${toString cfg.port} ${if cfg.interface!="" then "-e ${cfg.interface}" else ""} ${if cfg.customCfg then "" else "-c ${mtConf}"} -m ${cfg.dataDir}"; | ||
path = [ pkg ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this line actually required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I gather it's not since the command line specifies the full path to the binary... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As expected, it works without it ;) |
||
serviceConfig.ExecStart = "${pkg}/bin/${name} -p ${toString cfg.port} ${if cfg.interface!="" then "-e ${cfg.interface}" else ""} ${if cfg.customCfg then "" else "-c ${mtConf}"} -m ${cfg.dataDir}"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
serviceConfig.User = "${cfg.user}"; | ||
}; | ||
|
||
|
@@ -280,7 +293,7 @@ in { | |
}; | ||
}; | ||
|
||
networking.firewall = { | ||
networking.firewall.interfaces."${cfg.interface}" = { | ||
allowedUDPPorts = [ 1900 cfg.port ]; | ||
allowedTCPPorts = [ cfg.port ]; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ stdenv, lib, fetchFromGitHub | ||
, sqlite, expat | ||
, libuuid, libupnp, pugixml | ||
, cmake, pkgconfig | ||
, avcodecSupport ? false, libav ? null | ||
, curlSupport ? true, curl ? null | ||
, exifSupport ? true, libexif ? null | ||
, exiv2Support ? false, exiv2 ? null | ||
, ffmpegthumbnailerSupport ? true, ffmpegthumbnailer ? null | ||
, inotifySupport ? true, inotify-tools ? null | ||
, jsSupport ? true, duktape ? null | ||
, lastfmSupport ? false, liblastfm ? null | ||
, magicSupport ? true, file ? null | ||
, matroskaSupport ? true, libmatroska ? null, libebml ? null | ||
, mysqlSupport ? false, mysql ? null | ||
, systemdSupport ? false, systemd ? null | ||
aanderse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
, taglibSupport ? true, taglib ? null | ||
, testSupport ? false, gmock ? null | ||
}: | ||
|
||
assert avcodecSupport -> libav != null; | ||
assert curlSupport -> curl != null; | ||
assert exifSupport -> libexif != null; | ||
assert exiv2Support -> exiv2 != null; | ||
assert ffmpegthumbnailerSupport -> ffmpegthumbnailer != null; | ||
assert inotifySupport -> inotify-tools != null; | ||
assert jsSupport -> duktape != null; | ||
assert lastfmSupport -> liblastfm != null; | ||
assert magicSupport -> file != null; | ||
assert matroskaSupport -> libmatroska != null && libebml != null; | ||
assert mysqlSupport -> mysql != null; | ||
assert taglibSupport -> taglib != null; | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "gerbera"; | ||
version = "1.4.0"; | ||
|
||
doCheck = testSupport; | ||
|
||
src = fetchFromGitHub { | ||
owner = pname; | ||
repo = pname; | ||
rev = "v" + version; | ||
sha256 = "Ad9K3ZDLI7I1B0Ht7HJpw9/8wVvLXYEhmi60zK5cufQ="; | ||
}; | ||
|
||
buildInputs = | ||
let | ||
libupnpReuse = libupnp.overrideAttrs (attrs: { | ||
configureFlags = "--enable-reuseaddr"; | ||
}); | ||
in | ||
with lib; [ | ||
cmake pkgconfig | ||
libuuid libupnpReuse | ||
sqlite expat | ||
] | ||
++ optional avcodecSupport libav | ||
++ optional curlSupport curl | ||
++ optional exifSupport libexif | ||
++ optional exiv2Support exiv2 | ||
++ optional ffmpegthumbnailerSupport ffmpegthumbnailer | ||
++ optional inotifySupport inotify-tools | ||
++ optional jsSupport duktape | ||
++ optional lastfmSupport liblastfm | ||
++ optional magicSupport file | ||
++ optionals matroskaSupport [ libmatroska libebml ] | ||
++ optional mysqlSupport mysql | ||
++ optional systemdSupport systemd | ||
++ optional taglibSupport taglib | ||
++ optional testSupport gmock | ||
; | ||
|
||
cmakeFlags = | ||
let | ||
onOff = b: if b then "ON" else "OFF"; | ||
flag = n: b: "-D"+n+"="+onOff b; | ||
in | ||
with lib; [ | ||
(flag "WITH_AVCODEC" avcodecSupport) | ||
(flag "WITH_CURL" curlSupport) | ||
(flag "WITH_EXIF" exifSupport) | ||
(flag "WITH_EXIV2" exiv2Support) | ||
(flag "WITH_FFMPEGTHUMBNAILER" ffmpegthumbnailerSupport) | ||
(flag "WITH_JS" jsSupport) | ||
(flag "WITH_LASTFM" lastfmSupport) | ||
(flag "WITH_MAGIC" magicSupport) | ||
(flag "WITH_MATROSKA" matroskaSupport) | ||
(flag "WITH_MYSQL" mysqlSupport) | ||
(flag "WITH_SYSTEMD" systemdSupport) | ||
(flag "WITH_TESTS" testSupport) | ||
]; | ||
|
||
meta = with stdenv.lib; { | ||
homepage = "http://gerbera.io"; | ||
description = "UPnP Media Server for 2020"; | ||
license = licenses.gpl2; | ||
maintainers = with maintainers; [ edwtjo ]; | ||
platforms = platforms.linux; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the wide range of options available it might be more valuable to show an example with an
override
.