2023-03-03 23:12:20 -05:00
|
|
|
{
|
|
|
|
description = "MPV overlay with scripts and configuration for watching anime";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2023-03-04 00:08:57 -05:00
|
|
|
outputs = { self, nixpkgs, utils }: let
|
|
|
|
packages = utils.lib.eachDefaultSystem (system: let
|
2023-03-03 23:12:20 -05:00
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2023-04-23 02:19:36 -04:00
|
|
|
mpvScript = { owner, repo, rev, sha256, scriptName }: pkgs.stdenvNoCC.mkDerivation {
|
2023-03-03 23:12:20 -05:00
|
|
|
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; };
|
|
|
|
};
|
2023-03-04 00:08:57 -05:00
|
|
|
in {
|
|
|
|
packages.sub-select = mpvScript {
|
2023-03-03 23:12:20 -05:00
|
|
|
owner = "CogentRedTester";
|
|
|
|
repo = "mpv-sub-select";
|
|
|
|
rev = "5d2fb7ab73fc0e36d44109e75c9be26bd42084e2";
|
|
|
|
sha256 = "0dyh2kyvivj81lrkyqhc3czmi9hqjkh7xg8dqjnnr3kh3yn62dpi";
|
|
|
|
scriptName = "sub-select.lua";
|
|
|
|
};
|
|
|
|
|
2023-03-04 00:08:57 -05:00
|
|
|
packages.segment-linking = mpvScript {
|
2023-03-03 23:12:20 -05:00
|
|
|
owner = "CogentRedTester";
|
|
|
|
repo = "mpv-segment-linking";
|
|
|
|
rev = "bb0fdb7961859df57c64b42d75dbbd60a4024e97";
|
|
|
|
sha256 = "1ykl24p96wwka4fillrzni6i0xkk4s2l9zg1scqypcbs5w491qsj";
|
|
|
|
scriptName = "segment-linking.lua";
|
|
|
|
};
|
2023-03-04 00:08:57 -05:00
|
|
|
});
|
|
|
|
in
|
|
|
|
packages // rec {
|
|
|
|
overlays.default = final: prev: let
|
|
|
|
newScripts = packages.packages.${prev.system};
|
2023-04-23 02:19:19 -04:00
|
|
|
in {
|
|
|
|
mpv = prev.mpv.override { scripts = builtins.attrValues newScripts; };
|
2023-03-04 00:08:57 -05:00
|
|
|
mpvScripts = prev.mpvScripts // newScripts;
|
|
|
|
};
|
2023-03-03 23:12:20 -05:00
|
|
|
|
2023-03-04 00:08:57 -05:00
|
|
|
nixosModules.default = { pkgs, lib, ... }: {
|
|
|
|
nixpkgs.overlays = [ overlays.default ];
|
2023-03-03 23:12:20 -05:00
|
|
|
|
|
|
|
# needed for mpv segment-linking plugin
|
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.mkvtoolnix
|
|
|
|
];
|
|
|
|
|
2023-04-23 02:19:36 -04:00
|
|
|
home-manager.sharedModules = [ ({ config, ... }: {
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}) ];
|
2023-03-03 23:12:20 -05:00
|
|
|
};
|
2023-03-04 00:08:57 -05:00
|
|
|
};
|
2023-03-03 23:12:20 -05:00
|
|
|
}
|