nixos-configs/devices/nos/modules/subtitles/subsync/default.nix
matt1432 a7b7966d52
All checks were successful
Discord / discord commits (push) Has been skipped
refactor: improve custom packages' versioning
2024-03-25 22:42:23 -04:00

53 lines
1.2 KiB
Nix

{
config,
pkgs,
pocketsphinx-src,
subsync-src,
...
}: 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;
};
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"];
};
};
}