nixconfig/modules/c2cscrape.nix
2025-11-21 03:48:21 -08:00

50 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.c2cscrape;
# Import the package relative to this file
c2cscrapePkg = pkgs.callPackage ../pkgs/c2cscrape/default.nix { };
in
{
options.services.c2cscrape = {
enable = lib.mkEnableOption "C2C Scraper Service";
dataDir = lib.mkOption {
type = lib.types.Path;
default = "/var/lib/c2cscrape";
description = "Directory where episodes will be saved.";
};
user = lib.mkOption {
type = lib.types.Str;
default = "c2cscrape";
description = "user to run as";
};
};
config = lib.mkIf cfg.enable {
# 1. The Service
systemd.services.c2cscrape = {
description = "Coast 2 Coast Scraper Service";
unitConfig.RequiresMountsFor = cfg.dataDir;
serviceConfig = {
Type = "oneshot";
ExecStart = "${c2cscrapePkg}/bin/c2cscrape";
User = cfg.user;
WorkingDirectory = cfg.dataDir;
};
};
systemd.timers.c2cscrape = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
RandomizedDelaySec = "5m";
};
};
};
}