From 916da890273af68bdea8caa9dfde8aac015a9234 Mon Sep 17 00:00:00 2001 From: Samuel Leathers Date: Wed, 23 Aug 2017 08:09:10 -0400 Subject: [PATCH 1/5] airsonic: init at 10.0.0 --- pkgs/servers/misc/airsonic/default.nix | 24 ++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 pkgs/servers/misc/airsonic/default.nix diff --git a/pkgs/servers/misc/airsonic/default.nix b/pkgs/servers/misc/airsonic/default.nix new file mode 100644 index 000000000000..d52153cbf4e6 --- /dev/null +++ b/pkgs/servers/misc/airsonic/default.nix @@ -0,0 +1,24 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "airsonic-${version}"; + version = "10.0.0"; + + src = fetchurl { + url = "https://github.com/airsonic/airsonic/releases/download/v${version}/airsonic.war"; + sha256 = "0ldqccdm7z25my0wmispbshnn26l50a61q2ig2yl0krx4lmhfams"; + }; + + buildCommand = '' + mkdir -p "$out/webapps" + cp "$src" "$out/webapps/airsonic.war" + ''; + + meta = with stdenv.lib; { + description = "Personal media streamer"; + homepage = https://airsonic.github.io; + license = stdenv.lib.licenses.gpl3; + platforms = platforms.all; + maintainers = with maintainers; [ disassembler ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 73aba9ab34df..b1080c92a4c1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -412,6 +412,8 @@ with pkgs; airfield = callPackage ../tools/networking/airfield { }; + airsonic = callPackage ../servers/misc/airsonic { }; + aj-snapshot = callPackage ../applications/audio/aj-snapshot { }; albert = libsForQt5.callPackage ../applications/misc/albert {}; From 85329b96e0998ea381aaa6021892aae7bdb93504 Mon Sep 17 00:00:00 2001 From: Samuel Leathers Date: Wed, 23 Aug 2017 08:09:48 -0400 Subject: [PATCH 2/5] nixos/airsonic: add module --- nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/airsonic.nix | 117 +++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 nixos/modules/services/misc/airsonic.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index b1efa10aecdc..881cafe05ad4 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -268,6 +268,7 @@ ./services/mail/rspamd.nix ./services/mail/rmilter.nix ./services/mail/nullmailer.nix + ./services/misc/airsonic.nix ./services/misc/apache-kafka.nix ./services/misc/autofs.nix ./services/misc/autorandr.nix diff --git a/nixos/modules/services/misc/airsonic.nix b/nixos/modules/services/misc/airsonic.nix new file mode 100644 index 000000000000..b0dc3d9ec462 --- /dev/null +++ b/nixos/modules/services/misc/airsonic.nix @@ -0,0 +1,117 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.airsonic; +in { + options = { + + services.airsonic = { + enable = mkEnableOption "Airsonic, the Free and Open Source media streaming server (fork of Subsonic and Libresonic)"; + + user = mkOption { + type = types.str; + default = "airsonic"; + description = "User account under which airsonic runs."; + }; + + home = mkOption { + type = types.path; + default = "/var/lib/airsonic"; + description = '' + The directory where Airsonic will create files. + Make sure it is writable. + ''; + }; + + listenAddress = mkOption { + type = types.string; + default = "127.0.0.1"; + description = '' + The host name or IP address on which to bind Airsonic. + Only relevant if you have multiple network interfaces and want + to make Airsonic available on only one of them. The default value + will bind Airsonic to all available network interfaces. + ''; + }; + + port = mkOption { + type = types.int; + default = 4040; + description = '' + The port on which Airsonic will listen for + incoming HTTP traffic. Set to 0 to disable. + ''; + }; + + contextPath = mkOption { + type = types.path; + default = "/"; + description = '' + The context path, i.e., the last part of the Airsonic + URL. Typically '/' or '/airsonic'. Default '/' + ''; + }; + + maxMemory = mkOption { + type = types.int; + default = 100; + description = '' + The memory limit (max Java heap size) in megabytes. + Default: 100 + ''; + }; + + transcoders = mkOption { + type = types.listOf types.path; + default = [ "${pkgs.ffmpeg.bin}/bin/ffmpeg" ]; + defaultText= [ "\${pkgs.ffmpeg.bin}/bin/ffmpeg" ]; + description = '' + List of paths to transcoder executables that should be accessible + from Airsonic. Symlinks will be created to each executable inside + ${cfg.home}/transcoders. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.airsonic = { + description = "Airsonic Media Server"; + after = [ "local-fs.target" "network.target" ]; + wantedBy = [ "multi-user.target" ]; + script = '' + ${pkgs.jre}/bin/java -Xmx${toString cfg.maxMemory}m \ + -Dairsonic.home=${cfg.home} \ + -Dserver.address=${cfg.listenAddress} \ + -Dserver.port=${toString cfg.port} \ + -Dairsonic.contextPath=${cfg.contextPath} \ + -Djava.awt.headless=true \ + -verbose:gc \ + -jar ${pkgs.airsonic}/webapps/airsonic.war + ''; + + preStart = '' + # Install transcoders. + ${pkgs.coreutils}/bin/rm -rf ${cfg.home}/transcode + ${pkgs.coreutils}/bin/mkdir -p ${cfg.home}/transcode + for exe in ${toString cfg.transcoders}; do + ${pkgs.coreutils}/bin/ln -sf "$exe" ${cfg.home}/transcode + done + ''; + serviceConfig = { + Restart = "always"; + User = "airsonic"; + UMask = "0022"; + }; + }; + + users.extraUsers.airsonic = { + description = "Airsonic service user"; + name = cfg.user; + home = cfg.home; + createHome = true; + }; + }; +} From 6905e59e25817d6d22550f3857a63d326e66c42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 25 Aug 2017 23:04:56 +0100 Subject: [PATCH 3/5] nixos/airsonic: change script to serviceConfig.ExecStart - shell invocation is not necessary here --- nixos/modules/services/misc/airsonic.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/misc/airsonic.nix b/nixos/modules/services/misc/airsonic.nix index b0dc3d9ec462..3ec22719720b 100644 --- a/nixos/modules/services/misc/airsonic.nix +++ b/nixos/modules/services/misc/airsonic.nix @@ -81,16 +81,6 @@ in { description = "Airsonic Media Server"; after = [ "local-fs.target" "network.target" ]; wantedBy = [ "multi-user.target" ]; - script = '' - ${pkgs.jre}/bin/java -Xmx${toString cfg.maxMemory}m \ - -Dairsonic.home=${cfg.home} \ - -Dserver.address=${cfg.listenAddress} \ - -Dserver.port=${toString cfg.port} \ - -Dairsonic.contextPath=${cfg.contextPath} \ - -Djava.awt.headless=true \ - -verbose:gc \ - -jar ${pkgs.airsonic}/webapps/airsonic.war - ''; preStart = '' # Install transcoders. @@ -101,6 +91,16 @@ in { done ''; serviceConfig = { + ExecStart = '' + ${pkgs.jre}/bin/java -Xmx${toString cfg.maxMemory}m \ + -Dairsonic.home=${cfg.home} \ + -Dserver.address=${cfg.listenAddress} \ + -Dserver.port=${toString cfg.port} \ + -Dairsonic.contextPath=${cfg.contextPath} \ + -Djava.awt.headless=true \ + -verbose:gc \ + -jar ${pkgs.airsonic}/webapps/airsonic.war + ''; Restart = "always"; User = "airsonic"; UMask = "0022"; From 3ba09a8e2c4e1adffbb518b23efae203bebb4577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 25 Aug 2017 23:05:51 +0100 Subject: [PATCH 4/5] nixos/airsonic: remove full-path commands from preStart systemd services are initialised with a default PATH. This path includes coreutils. --- nixos/modules/services/misc/airsonic.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/airsonic.nix b/nixos/modules/services/misc/airsonic.nix index 3ec22719720b..b92104787a56 100644 --- a/nixos/modules/services/misc/airsonic.nix +++ b/nixos/modules/services/misc/airsonic.nix @@ -84,10 +84,10 @@ in { preStart = '' # Install transcoders. - ${pkgs.coreutils}/bin/rm -rf ${cfg.home}/transcode - ${pkgs.coreutils}/bin/mkdir -p ${cfg.home}/transcode + rm -rf ${cfg.home}/transcode + mkdir -p ${cfg.home}/transcode for exe in ${toString cfg.transcoders}; do - ${pkgs.coreutils}/bin/ln -sf "$exe" ${cfg.home}/transcode + ln -sf "$exe" ${cfg.home}/transcode done ''; serviceConfig = { From 7b982fcb091a610e23647d6f47ceae3bfca9d402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 25 Aug 2017 23:13:19 +0100 Subject: [PATCH 5/5] airsonic: 10.0.0 -> 10.0.1 --- pkgs/servers/misc/airsonic/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/misc/airsonic/default.nix b/pkgs/servers/misc/airsonic/default.nix index d52153cbf4e6..57040f469479 100644 --- a/pkgs/servers/misc/airsonic/default.nix +++ b/pkgs/servers/misc/airsonic/default.nix @@ -2,11 +2,11 @@ stdenv.mkDerivation rec { name = "airsonic-${version}"; - version = "10.0.0"; + version = "10.0.1"; src = fetchurl { url = "https://github.com/airsonic/airsonic/releases/download/v${version}/airsonic.war"; - sha256 = "0ldqccdm7z25my0wmispbshnn26l50a61q2ig2yl0krx4lmhfams"; + sha256 = "1qky8dz49200f6100ivkn5g7i0hzkv3gpq2r0cj6z53s8d1ayblc"; }; buildCommand = ''