1
1
Fork 0
nixos/options/custom/services/piped.nix
Myned ab485dec35
nix: format with alejandra
Signed-off-by: Myned <dev@bjork.tech>
2024-09-12 20:50:53 -05:00

47 lines
1.2 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib; let
curl = "${pkgs.curl}/bin/curl";
docker = "${pkgs.docker}/bin/docker";
parallel = "${pkgs.parallel}/bin/parallel";
cfg = config.custom.services.piped;
in {
options.custom.services.piped.enable = mkOption {default = false;};
config = mkIf cfg.enable {
# https://wiki.nixos.org/wiki/Systemd/timers
# Manually fetch channels in background
# TODO: Remove when fixed upstream
# https://github.com/TeamPiped/Piped/issues/1130
systemd = {
services."fetch-channels" = {
script = ''
${docker} compose --file /docker/piped/docker-compose.yml exec postgres \
psql \
--username piped \
--dbname piped \
--tuples-only \
--no-align \
--quiet \
--command 'SELECT DISTINCT(channel) FROM users_subscribed' | \
${parallel} ${curl} --silent --output /dev/null 'https://pipedapi.bjork.tech/channel/{}'
'';
};
timers."fetch-channels" = {
wantedBy = ["timers.target"];
timerConfig = {
OnBootSec = "1h";
OnUnitActiveSec = "1h";
};
};
};
};
}