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