summaryrefslogtreecommitdiff
path: root/user-profiles/mpv/default.nix
blob: 5c4012cba810322a5fad758725a9089a06adf5bf (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
{ config, lib, userName, pkgs, ... }:
{
  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;
      sub = false;
      osd-font = "DejaVu 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"
      ];
    };
    scripts = let
        reload = pkgs.stdenv.mkDerivation rec {
          version = "2b8a719f";
          pname = "reload";
          name = "${pname}-${version}";

          src = pkgs.fetchFromGitHub {
            owner = "4e6";
            repo = "mpv-reload";
            rev = "2b8a719fe166d6d42b5f1dd64761f97997b54a86";
            sha256 = "19ycvnwzf8vgv0g63d4k1ll6hlfrd92is9gl8hzfic7w32ycphbg";
          };

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

          passthru.scriptName = "reload.lua";
        };
        autosave = pkgs.stdenv.mkDerivation rec {
          version = "744c3ee6";
          pname = "autosave";
          name = "${pname}-${version}.lua";

          src = pkgs.fetchzip {
            url = "https://gist.github.com/CyberShadow/2f71a97fb85ed42146f6d9f522bc34ef/archive/744c3ee61d2f0a8e9bb4e308dec6897215ae4704.zip";
            hash = "sha256-yxA8wgzdS7SyKLoNTWN87ShsBfPKUflbOu4Y0jS2G3I=";
            # url = "https://gist.github.com/Hakkin/5489e511bd6c8068a0fc09304c9c5a82/archive/7a19f7cdb6dd0b1c6878b41e13b244e2503c15fc.zip";
            # sha256 = "0bv9wjrqm2ragd7rp8vw768bja2ghascwlljd6rzzf2ybi10fxs2";
          };

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

          passthru.scriptName = "autosave.lua";
        };
        mpris = pkgs.stdenv.mkDerivation rec {
          version = "0.4";
          pname = "mpv-mpris";
          name = "${pname}-${version}.so";

          src = pkgs.fetchFromGitHub {
            owner = "hoyon";
            repo = "mpv-mpris";
            rev = version;
            sha256 = "1fr3jvja8s2gdpx8qyk9r17977flms3qpm8zci62nd9r5wjdvr5i";
          };

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

          nativeBuildInputs = with pkgs; [ pkgconfig glib mpv ];

          passthru.scriptName = "mpris.so";
        };
      in [ reload
           autosave
           mpris
         ];
  };
}