about summary refs log tree commit diff
path: root/nixos/modules/services/hardware
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-12-23 16:19:27 +0100
committerGitHub <noreply@github.com>2018-12-23 16:19:27 +0100
commit633bc1d09b5ac464b2ae037bcc59167b4e31a7b1 (patch)
treed238523bba9956a6e155427b2b7bb63935c8aa7b /nixos/modules/services/hardware
parentdb5399b18834397a18552679d6e934968b558d0b (diff)
parent45986ec5873c978725ed482dc9a35e215ebb0438 (diff)
downloadnixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.tar
nixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.tar.gz
nixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.tar.bz2
nixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.tar.lz
nixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.tar.xz
nixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.tar.zst
nixlib-633bc1d09b5ac464b2ae037bcc59167b4e31a7b1.zip
Merge pull request #52686 from Mic92/vdr
vdr: revisited version of https://github.com/NixOS/nixpkgs/pull/32050
Diffstat (limited to 'nixos/modules/services/hardware')
-rw-r--r--nixos/modules/services/hardware/vdr.nix71
1 files changed, 71 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/vdr.nix b/nixos/modules/services/hardware/vdr.nix
new file mode 100644
index 000000000000..b0ecb944b5e3
--- /dev/null
+++ b/nixos/modules/services/hardware/vdr.nix
@@ -0,0 +1,71 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.vdr;
+  libDir = "/var/lib/vdr";
+in {
+
+  ###### interface
+
+  options = {
+
+    services.vdr = {
+      enable = mkEnableOption "enable VDR. Please put config into ${libDir}.";
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.vdr;
+        defaultText = "pkgs.vdr";
+        example = literalExample "pkgs.wrapVdr.override { plugins = with pkgs.vdrPlugins; [ hello ]; }";
+        description = "Package to use.";
+      };
+
+      videoDir = mkOption {
+        type = types.path;
+        default = "/srv/vdr/video";
+        description = "Recording directory";
+      };
+
+      extraArguments = mkOption {
+        type = types.listOf types.str;
+        default = [];
+        description = "Additional command line arguments to pass to VDR.";
+      };
+    };
+  };
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+    systemd.tmpfiles.rules = [
+      "d ${cfg.videoDir} 0755 vdr vdr 0"
+      "Z ${cfg.videoDir} - vdr vdr -"
+    ];
+
+    systemd.services.vdr = {
+      description = "VDR";
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        ExecStart = ''
+          ${cfg.package}/bin/vdr \
+            --video="${cfg.videoDir}" \
+            --config="${libDir}" \
+            ${escapeShellArgs cfg.extraArguments}
+        '';
+        User = "vdr";
+        CacheDirectory = "vdr";
+        StateDirectory = "vdr";
+        Restart = "on-failure";
+      };
+    };
+
+    users.users.vdr = {
+      group = "vdr";
+      home = libDir;
+    };
+
+    users.groups.vdr = {};
+  };
+}