mpv: fix issue #1725 and add tests (#1726)

Closes issue #1725.

This allows mpv module to be customized with support for more advanced
features than the `programs.mpv.scripts` current support. For example,
with this change now this is possible:

```nix
{
  programs.mpv.package = (pkgs.wrapMpv (pkgs.mpv-unwrapped.override {
    vapoursynthSupport = true;
  }) {
    extraMakeWrapperArgs = [
      "--prefix" "LD_LIBRARY_PATH" ":" "${pkgs.vapoursynth-mvtools}/lib/vapoursynth"
    ];
  });
}

```

Since `programs.mpv.package` doesn't necessary reflect the final
derivation anymore (see #1524), we introduce `programs.mpv.finalPackage`
that has the resulting derivation.

This includes 2 tests:
- One to check if everything is alright with mpv
- Other to validate our assertion that package and scripts can't be
  passed both at the same time

* docs: document recent mpv module changes

* mpv: add thiagokokada as maintainer
This commit is contained in:
Thiago Kenji Okada 2021-01-21 20:10:12 -03:00 committed by GitHub
parent 5280360d6c
commit 2c0e3f61da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 143 additions and 4 deletions

View file

@ -0,0 +1,4 @@
{
mpv-example-settings = ./mpv-example-settings.nix;
mpv-invalid-settings = ./mpv-invalid-settings.nix;
}

View file

@ -0,0 +1,3 @@
Alt+0 set window-scale 0.5
WHEEL_DOWN seek -10
WHEEL_UP seek 10

View file

@ -0,0 +1,13 @@
profile=%6%gpu-hq
cache-default=%7%4000000
force-window=%3%yes
ytdl-format=%19%bestvideo+bestaudio
[fast]
vo=%5%vdpau
[protocol.dvd]
alang=%2%en
profile-desc=%26%profile for dvd:// streams

View file

@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
{
config = {
programs.mpv = {
enable = true;
package = pkgs.mpvDummy;
bindings = {
WHEEL_UP = "seek 10";
WHEEL_DOWN = "seek -10";
"Alt+0" = "set window-scale 0.5";
};
config = {
force-window = true;
ytdl-format = "bestvideo+bestaudio";
cache-default = 4000000;
};
profiles = {
fast = { vo = "vdpau"; };
"protocol.dvd" = {
profile-desc = "profile for dvd:// streams";
alang = "en";
};
};
defaultProfiles = [ "gpu-hq" ];
};
nixpkgs.overlays = [
(self: super: { mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; })
];
nmt.script = ''
assertFileContent \
home-files/.config/mpv/mpv.conf \
${./mpv-example-settings-expected-config}
assertFileContent \
home-files/.config/mpv/input.conf \
${./mpv-example-settings-expected-bindings}
'';
};
}

View file

@ -0,0 +1 @@
["The programs.mpv \"package\" option is mutually exclusive with \"scripts\" option."]

View file

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
{
config = {
programs.mpv = {
enable = true;
package = pkgs.mpvDummy;
scripts = [ pkgs.mpvScript ];
};
nixpkgs.overlays = [
(self: super: {
mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out";
mpvScript =
pkgs.runCommandLocal "mpvScript" { scriptName = "something"; }
"mkdir $out";
})
];
home.file.result.text = builtins.toJSON
(map (a: a.message) (lib.filter (a: !a.assertion) config.assertions));
nmt.script = ''
assertFileContent \
home-files/result \
${./mpv-invalid-settings-expected.json}
'';
};
}