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

@ -50,7 +50,7 @@ let
renderOptions { profile = concatStringsSep "," profiles; };
mpvPackage = if cfg.scripts == [ ] then
pkgs.mpv
cfg.package
else
pkgs.wrapMpv pkgs.mpv-unwrapped { scripts = cfg.scripts; };
@ -60,8 +60,19 @@ in {
enable = mkEnableOption "mpv";
package = mkOption {
type = types.package;
default = pkgs.mpv;
example = literalExample
"pkgs.wrapMpv (pkgs.mpv-unwrapped.override { vapoursynthSupport = true; }) { youtubeSupport = true; }";
description = ''
Package providing mpv.
'';
};
finalPackage = mkOption {
type = types.package;
readOnly = true;
visible = false;
description = ''
Resulting mpv package.
'';
@ -91,7 +102,7 @@ in {
example = literalExample ''
{
profile = "gpu-hq";
force-window = "yes";
force-window = true;
ytdl-format = "bestvideo+bestaudio";
cache-default = 4000000;
}
@ -153,9 +164,16 @@ in {
};
config = mkIf cfg.enable (mkMerge [
{
assertions = [{
assertion = (cfg.scripts == [ ]) || (cfg.package == pkgs.mpv);
message = ''
The programs.mpv "package" option is mutually exclusive with "scripts" option.'';
}];
}
{
home.packages = [ mpvPackage ];
programs.mpv.package = mpvPackage;
programs.mpv.finalPackage = mpvPackage;
}
(mkIf (cfg.config != { } || cfg.profiles != { }) {
xdg.configFile."mpv/mpv.conf".text = ''
@ -170,5 +188,5 @@ in {
})
]);
meta.maintainers = with maintainers; [ tadeokondrak ];
meta.maintainers = with maintainers; [ tadeokondrak thiagokokada ];
}