How to make MPV scripts work?

The NixOS wiki suggests this configuration: https://wiki.nixos.org/wiki/MPV

  environment.systemPackages = with pkgs; [
    ( mpv.override { scripts = [
      mpvScripts.uosc
      mpvScripts.sponsorblock
    ]; } )

However that gives that outputs error: function 'anonymous lambda' called with unexpected argument 'scripts'. I tried the following to make my scripts work but they’re not loaded into mpv:

  environment.systemPackages = with pkgs; [
    (mpv-unwrapped.override {
      ffmpeg = ffmpeg-full;
    })
    mpvScripts.modernz
    mpvScripts.thumbfast
  ]
1 Like
      ( pkgs.mpv.override { scripts = [
      pkgs.mpvScripts.uosc
      pkgs.mpvScripts.sponsorblock
      ]; } )

Doesn’t thow a nix error for me. (I don’t know if they got installed correct.)

I’m wondering how I could do both: a custom ffmpeg package and scripts.

(pkgs.mpv.override { scripts = [ ... ]; mpv-unwrapped = pkgs.mpv-unwrapped.override { ... }; })

Thats just mpv unwrapped with extra steps

No it isn’t. It’s overriding both the wrapper and the underlying unwrapped package it depends on simultaneously. You need to override the wrapper to set your own scripts, and you need to override the underlying unwrapped package to use ffmpeg-full. This is how you do both.

1 Like

To give a bit more context, “wrapped” in nixpkgs context refers to a custom package that contains all the environment variables and runtime arguments and so on that are passed to the underlying program.

pkgs.mpv-unwrapped is the direct build of the upstream mpv code itself, while pkgs.mpv is nixpkgs’ own package that sets some environment variables to include things like your config files, scripts, etc. Changing a buildtime dependency requires changing the unwrapped package, while changing the scripts requires changing the wrapper package.

1 Like

Thanks that worked:

    (pkgs.mpv.override {
      scripts = [
        pkgs.mpvScripts.modernz
        pkgs.mpvScripts.thumbfast
      ];
      mpv-unwrapped = pkgs.mpv-unwrapped.override {
        ffmpeg = ffmpeg-full;
      };
    })
1 Like