1 { config, lib, pkgs, ... }:
3 cfg = config.services.vdr;
6 mkEnableOption mkPackageOption mkOption types mkIf optional;
12 enable = mkEnableOption "VDR, a video disk recorder";
14 package = mkPackageOption pkgs "vdr" {
15 example = "wrapVdr.override { plugins = with pkgs.vdrPlugins; [ hello ]; }";
20 default = "/srv/vdr/video";
21 description = "Recording directory";
24 extraArguments = mkOption {
25 type = types.listOf types.str;
27 description = "Additional command line arguments to pass to VDR.";
30 enableLirc = mkEnableOption "LIRC";
36 User under which the VDR service runs.
44 Group under which the VDRvdr service runs.
51 config = mkIf cfg.enable {
53 systemd.tmpfiles.rules = [
54 "d ${cfg.videoDir} 0755 ${cfg.user} ${cfg.group} -"
55 "Z ${cfg.videoDir} - ${cfg.user} ${cfg.group} -"
58 systemd.services.vdr = {
60 wantedBy = [ "multi-user.target" ];
61 wants = optional cfg.enableLirc "lircd.service";
62 after = [ "network.target" ]
63 ++ optional cfg.enableLirc "lircd.service";
68 "--video=${cfg.videoDir}"
70 ++ optional cfg.enableLirc "--lirc=${config.passthru.lirc.socket}"
71 ++ cfg.extraArguments;
73 "${cfg.package}/bin/vdr ${lib.escapeShellArgs args}";
76 CacheDirectory = "vdr";
77 StateDirectory = "vdr";
78 RuntimeDirectory = "vdr";
79 Restart = "on-failure";
83 environment.systemPackages = [ cfg.package ];
85 users.users = mkIf (cfg.user == "vdr") {
94 ++ optional cfg.enableLirc "lirc";
98 users.groups = mkIf (cfg.group == "vdr") { vdr = { }; };