git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #8629 from telotortium/subsonic

subsonic: init at 5.2.1

commit4f2b22aff05a11b014a59dbf4505e49c6baa0271 authorArseniy Seroka <jagajaga@users.noreply.github.com> dateTue 7 Jul 2015, 01:09 (11 years ago) parentb363927f64a5dd
5 files changed+196
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/misc/subsonic.nix+157 pkgs/servers/misc/subsonic/default.nix+34 pkgs/top-level/all-packages.nix+2
nixos/modules/misc/ids.nix+2
@@ -225,6 +225,7 @@
225225 uwsgi = 201;
226226 gitit = 202;
227227 riemanntools = 203;
228+ subsonic = 204;
228229
229230 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
230231
@@ -428,6 +429,7 @@
428429 uwsgi = 201;
429430 gitit = 202;
430431 riemanntools = 203;
432+ subsonic = 204;
431433
432434 # When adding a gid, make sure it doesn't match an existing
433435 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -218,6 +218,7 @@
218218 ./services/misc/ripple-data-api.nix
219219 ./services/misc/rogue.nix
220220 ./services/misc/siproxd.nix
221+ ./services/misc/subsonic.nix
221222 ./services/misc/svnserve.nix
222223 ./services/misc/synergy.nix
223224 ./services/misc/uhub.nix
nixos/modules/services/misc/subsonic.nixnew file+157
@@ -0,0 +1,157 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.subsonic;
7+ homeDir = "/var/subsonic";
8+
9+in
10+{
11+ options = {
12+ services.subsonic = {
13+ enable = mkEnableOption "Subsonic daemon";
14+
15+ home = mkOption {
16+ type = types.path;
17+ default = "${homeDir}";
18+ description = ''
19+ The directory where Subsonic will create files.
20+ Make sure it is writable.
21+ '';
22+ };
23+
24+ host = mkOption {
25+ type = types.string;
26+ default = "0.0.0.0";
27+ description = ''
28+ The host name or IP address on which to bind Subsonic.
29+ Only relevant if you have multiple network interfaces and want
30+ to make Subsonic available on only one of them. The default value
31+ will bind Subsonic to all available network interfaces.
32+ '';
33+ };
34+
35+ port = mkOption {
36+ type = types.int;
37+ default = 4040;
38+ description = ''
39+ The port on which Subsonic will listen for
40+ incoming HTTP traffic. Set to 0 to disable.
41+ '';
42+ };
43+
44+ httpsPort = mkOption {
45+ type = types.int;
46+ default = 0;
47+ description = ''
48+ The port on which Subsonic will listen for
49+ incoming HTTPS traffic. Set to 0 to disable.
50+ '';
51+ };
52+
53+ contextPath = mkOption {
54+ type = types.path;
55+ default = "/";
56+ description = ''
57+ The context path, i.e., the last part of the Subsonic
58+ URL. Typically '/' or '/subsonic'. Default '/'
59+ '';
60+ };
61+
62+ maxMemory = mkOption {
63+ type = types.int;
64+ default = 100;
65+ description = ''
66+ The memory limit (max Java heap size) in megabytes.
67+ Default: 100
68+ '';
69+ };
70+
71+ defaultMusicFolder = mkOption {
72+ type = types.path;
73+ default = "/var/music";
74+ description = ''
75+ Configure Subsonic to use this folder for music. This option
76+ only has effect the first time Subsonic is started.
77+ '';
78+ };
79+
80+ defaultPodcastFolder = mkOption {
81+ type = types.path;
82+ default = "/var/music/Podcast";
83+ description = ''
84+ Configure Subsonic to use this folder for Podcasts. This option
85+ only has effect the first time Subsonic is started.
86+ '';
87+ };
88+
89+ defaultPlaylistFolder = mkOption {
90+ type = types.path;
91+ default = "/var/playlists";
92+ description = ''
93+ Configure Subsonic to use this folder for playlists. This option
94+ only has effect the first time Subsonic is started.
95+ '';
96+ };
97+
98+ transcoders = mkOption {
99+ type = types.listOf types.path;
100+ default = [ "${pkgs.ffmpeg}/bin/ffmpeg" ];
101+ description = ''
102+ List of paths to transcoder executables that should be accessible
103+ from Subsonic. Symlinks will be created to each executable inside
104+ ${cfg.home}/transcoders.
105+ '';
106+ };
107+ };
108+ };
109+
110+ config = mkIf cfg.enable {
111+ systemd.services.subsonic = {
112+ description = "Personal media streamer";
113+ after = [ "local-fs.target" "network.target" ];
114+ wantedBy = [ "multi-user.target" ];
115+ serviceConfig = {
116+ ExecStart = ''
117+ ${pkgs.jre}/bin/java -Xmx${toString cfg.maxMemory}m \
118+ -Dsubsonic.home=${cfg.home} \
119+ -Dsubsonic.host=${cfg.host} \
120+ -Dsubsonic.port=${toString cfg.port} \
121+ -Dsubsonic.httpsPort=${toString cfg.httpsPort} \
122+ -Dsubsonic.contextPath=${cfg.contextPath} \
123+ -Dsubsonic.defaultMusicFolder=${cfg.defaultMusicFolder} \
124+ -Dsubsonic.defaultPodcastFolder=${cfg.defaultPodcastFolder} \
125+ -Dsubsonic.defaultPlaylistFolder=${cfg.defaultPlaylistFolder} \
126+ -Djava.awt.headless=true \
127+ -verbose:gc \
128+ -jar ${pkgs.subsonic}/subsonic-booter-jar-with-dependencies.jar
129+ '';
130+ # Install transcoders.
131+ ExecStartPre = ''
132+ ${pkgs.coreutils}/bin/rm -rf ${cfg.home}/transcode ; \
133+ ${pkgs.coreutils}/bin/mkdir -p ${cfg.home}/transcode ; \
134+ ${pkgs.bash}/bin/bash -c ' \
135+ for exe in "$@"; do \
136+ ${pkgs.coreutils}/bin/ln -sf "$exe" ${cfg.home}/transcode; \
137+ done' IGNORED_FIRST_ARG ${toString cfg.transcoders}
138+ '';
139+ # Needed for Subsonic to find subsonic.war.
140+ WorkingDirectory = "${pkgs.subsonic}";
141+ Restart = "always";
142+ User = "subsonic";
143+ UMask = "0022";
144+ };
145+ };
146+
147+ users.extraUsers.subsonic = {
148+ description = "Subsonic daemon user";
149+ home = homeDir;
150+ createHome = true;
151+ group = "subsonic";
152+ uid = config.ids.uids.subsonic;
153+ };
154+
155+ users.extraGroups.subsonic.gid = config.ids.gids.subsonic;
156+ };
157+}
pkgs/servers/misc/subsonic/default.nixnew file+34
@@ -0,0 +1,34 @@
1+{ stdenv, fetchurl, jre }:
2+
3+let version = "5.2.1"; in
4+
5+stdenv.mkDerivation rec {
6+ name = "subsonic-${version}";
7+ inherit version;
8+
9+ src = fetchurl {
10+ url = "mirror://sourceforge/subsonic/subsonic-${version}-standalone.tar.gz";
11+ sha256 = "523fa8357c961c1ae742a15f0ceaabdd41fcba9137c29d244957922af90ee791";
12+ };
13+
14+ inherit jre;
15+
16+ # Create temporary directory to extract tarball into to satisfy Nix's need
17+ # for a directory to be created in the unpack phase.
18+ unpackPhase = ''
19+ mkdir ${name}
20+ tar -C ${name} -xzf $src
21+ '';
22+ installPhase = ''
23+ mkdir $out
24+ cp -r ${name}/* $out
25+ '';
26+
27+ meta = {
28+ homepage = http://subsonic.org;
29+ description = "Personal media streamer";
30+ license = stdenv.lib.licenses.gpl3;
31+ };
32+
33+ phases = ["unpackPhase" "installPhase"];
34+}
pkgs/top-level/all-packages.nix+2
@@ -3006,6 +3006,8 @@ let
30063006
30073007 su = shadow.su;
30083008
3009+ subsonic = callPackage ../servers/misc/subsonic { };
3010+
30093011 surfraw = callPackage ../tools/networking/surfraw { };
30103012
30113013 swec = callPackage ../tools/networking/swec {