summary refs log tree commit diff
diff options
context:
space:
mode:
authorrembo10 <rembo10@users.noreply.github.com>2018-09-16 21:47:47 +0200
committerrembo10 <rembo10@users.noreply.github.com>2018-09-16 21:48:18 +0200
commit8d1ad4317c9a90724effa4a72bf18f1e7c0847e4 (patch)
tree1958e8ebcef9ed0fc2edad069573263d9267421e
parent5e474d1c6fbe7c28e6ce02f7cf63d85cfd3e956f (diff)
downloadnixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.tar
nixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.tar.gz
nixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.tar.bz2
nixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.tar.lz
nixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.tar.xz
nixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.tar.zst
nixpkgs-8d1ad4317c9a90724effa4a72bf18f1e7c0847e4.zip
headphones: init at 0.5.19
-rw-r--r--nixos/modules/misc/ids.nix4
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/headphones.nix87
-rw-r--r--pkgs/servers/headphones/default.nix33
-rw-r--r--pkgs/top-level/all-packages.nix2
5 files changed, 125 insertions, 2 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index aafeb997c32..c65291cf97e 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -290,7 +290,7 @@
       riak-cs = 263;
       infinoted = 264;
       # keystone = 265; # unused, removed 2017-12-13
-      # glance = 266; # unused, removed 2017-12-13
+      headphones = 266;
       couchpotato = 267;
       gogs = 268;
       pdns-recursor = 269;
@@ -580,7 +580,7 @@
       riak-cs = 263;
       infinoted = 264;
       # keystone = 265; # unused, removed 2017-12-13
-      # glance = 266; # unused, removed 2017-12-13
+      headphones = 266;
       couchpotato = 267;
       gogs = 268;
       kresd = 270;
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index f51a30aec2e..b5afb5b1553 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -357,6 +357,7 @@
   ./services/misc/gogs.nix
   ./services/misc/gollum.nix
   ./services/misc/gpsd.nix
+  ./services/misc/headphones.nix
   ./services/misc/home-assistant.nix
   ./services/misc/ihaskell.nix
   ./services/misc/irkerd.nix
diff --git a/nixos/modules/services/misc/headphones.nix b/nixos/modules/services/misc/headphones.nix
new file mode 100644
index 00000000000..4a77045be28
--- /dev/null
+++ b/nixos/modules/services/misc/headphones.nix
@@ -0,0 +1,87 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  name = "headphones";
+
+  cfg = config.services.headphones;
+
+in
+
+{
+
+  ###### interface
+
+  options = {
+    services.headphones = {
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = "Whether to enable the headphones server.";
+      };
+      dataDir = mkOption {
+        type = types.path;
+        default = "/var/lib/${name}";
+        description = "Path where to store data files.";
+      };
+      configFile = mkOption {
+        type = types.path;
+        default = "${cfg.dataDir}/config.ini";
+        description = "Path to config file.";
+      };
+      host = mkOption {
+        type = types.str;
+        default = "localhost";
+        description = "Host to listen on.";
+      };
+      port = mkOption {
+        type = types.ints.u16;
+        default = 8181;
+        description = "Port to bind to.";
+      };
+      user = mkOption {
+        type = types.str;
+        default = name;
+        description = "User to run the service as";
+      };
+      group = mkOption {
+        type = types.str;
+        default = name;
+        description = "Group to run the service as";
+      };
+    };
+  };
+
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+
+    users.users = optionalAttrs (cfg.user == name) (singleton {
+      name = name;
+      uid = config.ids.uids.headphones;
+      group = cfg.group;
+      description = "headphones user";
+      home = cfg.dataDir;
+      createHome = true;
+    });
+
+    users.groups = optionalAttrs (cfg.group == name) (singleton {
+      name = name;
+      gid = config.ids.gids.headphones;
+    });
+
+    systemd.services.headphones = {
+        description = "Headphones Server";
+        wantedBy    = [ "multi-user.target" ];
+        after = [ "network.target" ];
+        serviceConfig = {
+          User = cfg.user;
+          Group = cfg.group;
+          ExecStart = "${pkgs.headphones}/bin/headphones --datadir ${cfg.dataDir} --config ${cfg.configFile} --host ${cfg.host} --port ${toString cfg.port}";
+        };
+    };
+  };
+}
diff --git a/pkgs/servers/headphones/default.nix b/pkgs/servers/headphones/default.nix
new file mode 100644
index 00000000000..eff1155fc20
--- /dev/null
+++ b/pkgs/servers/headphones/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, python2, makeWrapper }:
+
+python2.pkgs.buildPythonApplication rec {
+  name = "headphones-${version}";
+  version = "0.5.19";
+
+  src = fetchFromGitHub {
+    owner = "rembo10";
+    repo = "headphones";
+    rev = "v${version}";
+    sha256 = "0z39gyan3ksdhnjxxs7byamrzmrk8cn15g300iqigzvgidff1lq0";
+  };
+
+  dontBuild = true;
+  doCheck = false;
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ python2 ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -R {data,headphones,lib,Headphones.py} $out/
+
+    makeWrapper $out/Headphones.py $out/bin/headphones
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Automatic music downloader for SABnzbd";
+    license     = licenses.gpl3;
+    homepage    = https:/github.com/rembo10/headphones;
+    maintainers = with stdenv.lib.maintainers; [ rembo10 ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 493f0d8ae6e..cc3d2e9b2ad 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -13075,6 +13075,8 @@ with pkgs;
 
   hbase = callPackage ../servers/hbase {};
 
+  headphones = callPackage ../servers/headphones {};
+
   hiawatha = callPackage ../servers/http/hiawatha {};
 
   home-assistant = callPackage ../servers/home-assistant { };