summaryrefslogtreecommitdiff
path: root/user-profiles/mpv/default.nix
blob: 620be49d629d8aa84d42a2971cb8b32e80bc7e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{ config, lib, userName, pkgs, sources, ... }:
{
  home-manager.users.${userName} = {
    programs.mpv = {
      enable = true;
      bindings = {
        # "CTRL+n" = "af toggle \"lavfi=[dynaudnorm=f=100:g=31:s=20.0]\"";
      };
      config = {
        ytdl = true;
        subs-with-matching-audio = false;
        audio-display = false;
        osd-font = "Fira Sans";
        sub-font = "Fira Sans";
        # vo = "gpu";
        hwdec = "auto";
        force-window = "yes";
        # af = "lavfi=[dynaudnorm=f=100:g=31:s=20.0]";
        script-opts = lib.concatStringsSep "," [
          "osc-layout=topbar"
          "vidscale=no"
          "deadzonesize=0.9"
          "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp"
          "chapterskip-skip=sponsor;intro;endcard;interact"
          "chapterskip-categories=sponsor>%[SponsorBlock%]: .*Sponsor.*;intro>%[SponsorBlock%]: .*Intro Animation.*;endcard>%[SponsorBlock%]: .*Endcards.*;interact>%[SponsorBlock%]: .*Interaction Reminder.*"
          "sub_select-config=${pkgs.writeTextDir "sub-select.json" (builtins.toJSON [
            {
              alang = "*";
              slang = "forced";
            }
            {
              alang = ["jpn" "ja"];
              slang = "eng?";
              blacklist = [ "sign" ];
            }
            {
              alang = ["jpn" "ja"];
              slang = "und";
              blacklist = [ "sign" ];
            }
            {
              alang = ["eng?" "deu?"];
              slang = "no";
            }
            {
              alang = "*";
              slang = "eng?";
            }
            {
              alang = "*";
              slang = "und";
            }
          ])}"
        ];
      };
      scripts = [
        (pkgs.stdenv.mkDerivation (sources.mpv-reload // rec {
          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName}
          '';

          passthru.scriptName = "reload.lua";
        }))
        (pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec {
          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName}
          '';

          passthru.scriptName = "createchapter.lua";
        }))
        (pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec {
          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName}
          '';

          passthru.scriptName = "autosave.lua";
        }))
        (pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec {
          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName}
          '';

          nativeBuildInputs = with pkgs; [ pkg-config glib mpv ffmpeg.dev ];

          passthru.scriptName = "mpris.so";
        }))
        (pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec {
          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName}
          '';

          passthru.scriptName = "chapterskip.lua";
        }))
        (pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec {
          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName}
          '';

          passthru.scriptName = "sub-select.lua";
        }))
        (pkgs.stdenv.mkDerivation (sources.mpv-youtube-quality // rec {
          patches = [
            (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/31.patch"; hash = "sha256-2aTTkW48uRe8XC1ZQ8J5T9sUmZ5F3YAoYCMxqEs2AY8="; })
            (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/20.patch"; hash = "sha256-X5BwDsxziYbeiQvrBt8+IS+6oH1i0LvaaYtugL790gg="; })
          ];

          installPhase = ''
            install -d $out/share/mpv/scripts
            install -m 0644 youtube-quality.lua $out/share/mpv/scripts/${passthru.scriptName}
          '';

          passthru.scriptName = "youtube-quality.lua";
        }))
      ];
    };

    xdg.configFile."mpv/youtube-dl".source = "${pkgs.yt-dlp}/bin/yt-dlp";
  };
}