nixos-configs/devices/nos/modules/subtitles/subsync/default.nix

54 lines
1.2 KiB
Nix
Raw Normal View History

2024-03-25 19:54:40 -04:00
{
config,
pkgs,
pocketsphinx-src,
subsync-src,
2024-03-25 19:54:40 -04:00
...
}: let
inherit (config.vars) mainUser;
sphinxbase = pkgs.callPackage ./sphinxbase.nix {};
pocketsphinx = pkgs.callPackage ./pocketsphinx.nix {
inherit sphinxbase pocketsphinx-src;
};
subsync = pkgs.callPackage ./subsync.nix {
inherit sphinxbase pocketsphinx subsync-src;
};
2024-03-25 19:54:40 -04:00
in {
systemd = {
services.subsync-job = {
serviceConfig = {
Type = "oneshot";
User = mainUser;
Group = config.users.users.${mainUser}.group;
};
path = with pkgs; [
findutils
subsync
(writeShellApplication {
name = "sync-sub";
runtimeInputs = [subsync];
text = ''
# TODO: sync on a specific file
# $1 = file path
'';
})
];
script = ''
find /data/anime -name '*.srt' -exec sync-sub "{}" \;
find /data/movies -name '*.srt' -exec sync-sub "{}" \;
find /data/tv -name '*.srt' -exec sync-sub "{}" \;
'';
};
timers.subsync-job = {
wantedBy = ["timers.target"];
partOf = ["subsync-job.service"];
timerConfig.OnCalendar = ["0:00:00"];
};
};
}