nixconfig/modules/c2cscrape.nix
2026-01-23 02:26:50 -08:00

63 lines
1.4 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.c2cscrape;
c2cscrapePkg = pkgs.python3Packages.callPackage ../pkgs/c2cscrape/default.nix {
qbittorrentApi = pkgs.python3Packages.qbittorrent-api;
pythonDotenv = pkgs.python3Packages.python-dotenv;
};
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";
};
environmentFile = lib.mkOption {
type = lib.types.path;
description = "Path to an .env file ";
};
};
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;
Environment = "PYTHONUNBUFFERED=1";
EnvironmentFile = cfg.environmentFile;
};
};
systemd.timers.c2cscrape = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
RandomizedDelaySec = "5m";
};
};
};
}