{ 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; ytdl-format = lib.concatStringsSep "/" [ "bestvideo[width<=2560][height<=1440][fps<=60][protocol!=http_dash_segments]+bestaudio[protocol!=http_dash_segments]" "best[width<=2560][height<=1440][fps<=60][protocol!=http_dash_segments]" "best[protocol!=http_dash_segments]" ]; ytdl-raw-options = lib.concatStringsSep "," [ "netrc=" "mark-watched=" "cookies=${config.home-manager.users.${userName}.home.homeDirectory}/Downloads/cookies.txt" ]; 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 ]; }; }