MPV: Difference between revisions

From NixOS Wiki
imported>Samuelgrf
Finding packages using nix search is better than relying on shell completion, which doesn't always work.
imported>Samuelgrf
Edit examples to use overlays, since packageOverrides are deprecated.
Line 6: Line 6:
{{ic|mpv-with-scripts}} is a wrapper for the {{ic|mpv}} binary which adds {{ic|--script<nowiki>=</nowiki>}} arguments according to the scripts the wrapper was built with.
{{ic|mpv-with-scripts}} is a wrapper for the {{ic|mpv}} binary which adds {{ic|--script<nowiki>=</nowiki>}} arguments according to the scripts the wrapper was built with.


If you'd like to add scripts to your {{ic|mpv}} wrapper, you'll need to override the package in {{ic|~/.config/nixpkgs/config.nix}}:
If you'd like to add scripts to your {{ic|mpv}} wrapper, you'll need to create an overlay in {{ic|~/.config/nixpkgs/config.nix}} or {{ic|/etc/nixos/configuration.nix}} (if you are using NixOS):


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
nixpkgs.overlays = [
   packageOverrides = pkgs: with pkgs; rec {
   (self: super: {
     mpv-with-scripts = pkgs.mpv-with-scripts.override {
     mpv = super.mpv-with-scripts.override {
       scripts = [pkgs.mpvScripts.<your choice>];
       scripts = [ self.mpvScripts.<your choice> ];
     };
     };
   };
   })
}
];
</syntaxhighlight>
</syntaxhighlight>


Line 26: Line 26:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
{
   packageOverrides = pkgs: with pkgs; rec {
   nixpkgs.overlays = [
    mpv-with-scripts = pkgs.mpv-with-scripts.override {
    (self: super: {
      scripts = [pkgs.mpvScripts.mpris];
      mpv = super.mpv-with-scripts.override {
     };
        scripts = [ self.mpvScripts.mpris ];
   };
      };
     })
   ];
}
}
</syntaxhighlight>
</syntaxhighlight>

Revision as of 11:10, 4 July 2020

There are 2 packages that provide an mpv executable:

  • mpv
  • mpv-with-scripts

mpv-with-scripts is a wrapper for the mpv binary which adds --script= arguments according to the scripts the wrapper was built with.

If you'd like to add scripts to your mpv wrapper, you'll need to create an overlay in ~/.config/nixpkgs/config.nix or /etc/nixos/configuration.nix (if you are using NixOS):

nixpkgs.overlays = [
  (self: super: {
    mpv = super.mpv-with-scripts.override {
      scripts = [ self.mpvScripts.<your choice> ];
    };
  })
];

All of the scripts for MPV can be found under the mpvScripts attribute. You can search for them by running nix search mpvScripts. The scripts are defined in the following Nixpkgs directory:

pkgs/applications/video/mpv/scripts

So for example, for adding the MPRIS MPV script, use the following in your ~/.config/nixpkgs/config.nix:

{
  nixpkgs.overlays = [
    (self: super: {
      mpv = super.mpv-with-scripts.override {
        scripts = [ self.mpvScripts.mpris ];
      };
    })
  ];
}