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 = {
|
2022-08-28 19:18:44 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "VDR. Please put config into ${libDir}");
|
2018-12-08 09:18:26 +00:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.vdr;
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression "pkgs.vdr";
|
|
|
|
example = literalExpression "pkgs.wrapVdr.override { plugins = with pkgs.vdrPlugins; [ hello ]; }";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Package to use.";
|
2018-12-08 09:18:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
videoDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/srv/vdr/video";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Recording directory";
|
2018-12-08 09:18:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraArguments = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Additional command line arguments to pass to VDR.";
|
2018-12-08 09:18:26 +00:00
|
|
|
};
|
2018-12-26 21:10:04 +00:00
|
|
|
|
2022-08-28 19:18:44 +00:00
|
|
|
enableLirc = mkEnableOption (lib.mdDoc "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
|
|
|
}
|