summary refs log tree commit diff
path: root/nixos/modules/services/networking/tvheadend.nix
diff options
context:
space:
mode:
authorSimon Vandel Sillesen <simon.vandel@gmail.com>2015-06-20 20:33:57 +0000
committerSimon Vandel Sillesen <simon.vandel@gmail.com>2015-06-24 13:22:09 +0000
commit9dab1a840cced57bd86c9f006dc44b21699d6660 (patch)
treea79bc4e40eef76349493a042ead1f339d9315529 /nixos/modules/services/networking/tvheadend.nix
parent5ee8b66a68f8855e113df21562b415aeb567e8b9 (diff)
downloadnixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.tar
nixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.tar.gz
nixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.tar.bz2
nixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.tar.lz
nixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.tar.xz
nixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.tar.zst
nixlib-9dab1a840cced57bd86c9f006dc44b21699d6660.zip
tvheadend: init at 4.0.4
Diffstat (limited to 'nixos/modules/services/networking/tvheadend.nix')
-rw-r--r--nixos/modules/services/networking/tvheadend.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/tvheadend.nix b/nixos/modules/services/networking/tvheadend.nix
new file mode 100644
index 000000000000..cdd8747ba898
--- /dev/null
+++ b/nixos/modules/services/networking/tvheadend.nix
@@ -0,0 +1,61 @@
+{ config, coreutils, lib, pkgs, ... }:
+
+with lib;
+
+let cfg     = config.services.tvheadend;
+    pidFile = "${config.users.extraUsers.tvheadend.home}/tvheadend.pid";
+in
+
+{
+  options = {
+    services.tvheadend = {
+      enable = mkEnableOption "Tvheadend";
+      httpPort = mkOption {
+        type        = types.int;
+        default     = 9981;
+        description = "Port to bind HTTP to.";
+      };
+
+      htspPort = mkOption {
+        type        = types.int;
+        default     = 9982;
+        description = "Port to bind HTSP to.";
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    users.extraUsers.tvheadend = {
+      description = "Tvheadend Service user";
+      home        = "/var/lib/tvheadend";
+      createHome  = true;
+      uid         = config.ids.uids.tvheadend;
+    };
+
+    systemd.services.tvheadend = {
+      description = "Tvheadend TV streaming server";
+      wantedBy    = [ "multi-user.target" ];
+      after       = [ "network.target" ];
+
+      serviceConfig = {
+        Type         = "forking";
+        PIDFile      = pidFile;
+        Restart      = "always";
+        RestartSec   = 5;
+        User         = "tvheadend";
+        Group        = "video";
+        ExecStart    = ''
+                       ${pkgs.tvheadend}/bin/tvheadend \
+                       --http_port ${toString cfg.httpPort} \
+                       --htsp_port ${toString cfg.htspPort} \
+                       -f \
+                       -C \
+                       -p ${pidFile} \
+                       -u tvheadend \
+                       -g video
+                       '';
+        ExecStop     = "${pkgs.coreutils}/bin/rm ${pidFile}";
+      };
+    };
+  };
+}