mpv anime module

This commit is contained in:
xenofem 2023-03-03 23:12:20 -05:00
commit 2849204412

98
flake.nix Normal file
View file

@ -0,0 +1,98 @@
{
description = "MPV overlay with scripts and configuration for watching anime";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
mpvScript = { owner, repo, rev, sha256, scriptName }: pkgs.stdenvNoCC.mkDerivation {
pname = repo;
version = builtins.substring 0 6 rev;
src = pkgs.fetchFromGitHub {
inherit owner repo rev sha256;
};
dontBuild = true;
installPhase = ''
install -Dm644 ${scriptName} $out/share/mpv/scripts/${scriptName}
'';
passthru = { inherit scriptName; };
};
in rec {
packages.mpvScripts.sub-select = mpvScript {
owner = "CogentRedTester";
repo = "mpv-sub-select";
rev = "5d2fb7ab73fc0e36d44109e75c9be26bd42084e2";
sha256 = "0dyh2kyvivj81lrkyqhc3czmi9hqjkh7xg8dqjnnr3kh3yn62dpi";
scriptName = "sub-select.lua";
};
packages.mpvScripts.segment-linking = mpvScript {
owner = "CogentRedTester";
repo = "mpv-segment-linking";
rev = "bb0fdb7961859df57c64b42d75dbbd60a4024e97";
sha256 = "1ykl24p96wwka4fillrzni6i0xkk4s2l9zg1scqypcbs5w491qsj";
scriptName = "segment-linking.lua";
};
nixosModules.default = { ... }: {
nixpkgs.overlays = final: prev: {
mpv = prev.mpv.override {
scripts = with packages.mpvScripts; [
sub-select
segment-linking
];
};
};
# needed for mpv segment-linking plugin
environment.systemPackages = [
pkgs.mkvtoolnix
];
home-manager.sharedModules = [ ({ config, lib, ... }: {
config = lib.mkIf config.programs.mpv.enable {
xdg.configFile."mpv/script-opts/sub-select.json".text = builtins.toJSON [
{
alang = "j[ap]n?";
slang = [ "eng?" "und" ];
blacklist = [ "sign" ];
condition = "not sub.forced";
}
{
alang = "eng?";
slang = "forced";
}
{
alang = "eng?";
slang = "eng?";
whitelist = [ "sign" "song" ];
}
{
alang = [ "eng?" "no" ];
slang = "no";
}
{
alang = "*";
slang = "eng?";
condition = "not sub.forced";
}
{
alang = "*";
slang = "und";
condition = "not sub.forced";
}
{
alang = "*";
slang = "forced";
}
];
};
}) ];
};
}
);
}