2018-12-08 10:18:26 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.vdr;
|
|
|
|
libDir = "/var/lib/vdr";
|
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.vdr = {
|
2019-04-20 03:41:48 +02:00
|
|
|
enable = mkEnableOption "VDR. Please put config into ${libDir}";
|
2018-12-08 10:18:26 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.vdr;
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression "pkgs.vdr";
|
|
|
|
example = literalExpression "pkgs.wrapVdr.override { plugins = with pkgs.vdrPlugins; [ hello ]; }";
|
2018-12-08 10:18:26 +01:00
|
|
|
description = "Package to use.";
|
|
|
|
};
|
|
|
|
|
|
|
|
videoDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/srv/vdr/video";
|
2018-12-22 15:13:35 +01:00
|
|
|
description = "Recording directory";
|
2018-12-08 10:18:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraArguments = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
description = "Additional command line arguments to pass to VDR.";
|
|
|
|
};
|
2018-12-26 22:10:04 +01:00
|
|
|
|
2019-04-20 03:41:48 +02:00
|
|
|
enableLirc = mkEnableOption "LIRC";
|
2018-12-08 10:18:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2018-12-26 22:10:04 +01:00
|
|
|
config = mkIf cfg.enable (mkMerge [{
|
2018-12-22 15:13:35 +01:00
|
|
|
systemd.tmpfiles.rules = [
|
2018-12-23 18:54:13 +01:00
|
|
|
"d ${cfg.videoDir} 0755 vdr vdr -"
|
2018-12-22 15:13:35 +01:00
|
|
|
"Z ${cfg.videoDir} - vdr vdr -"
|
|
|
|
];
|
2018-12-08 10:18:26 +01:00
|
|
|
|
|
|
|
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;
|
2019-10-12 22:25:28 +02:00
|
|
|
isSystemUser = true;
|
2018-12-08 10:18:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.vdr = {};
|
2018-12-26 22:10:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf cfg.enableLirc {
|
|
|
|
services.lirc.enable = true;
|
|
|
|
users.users.vdr.extraGroups = [ "lirc" ];
|
|
|
|
services.vdr.extraArguments = [
|
2019-01-05 13:22:39 +01:00
|
|
|
"--lirc=${config.passthru.lirc.socket}"
|
2018-12-26 22:10:04 +01:00
|
|
|
];
|
|
|
|
})]);
|
2018-12-08 10:18:26 +01:00
|
|
|
}
|