Overriding a Wrapped Derivation's Arguments

Hi all,

I’m trying to enable CD audio support in mpv package but am having no luck at all. Looking at the default.nix for the package, it seems that there is a flag to enable it in the arguments:

{ config
, lib
, stdenv

(... omitting for brevity ...)

, cddaSupport ? false
  , libcdio
  , libcdio-paranoia

(...)
}

So I attempted to add an override in my configuration.nix to enable this:

{
  nixpkgs.overlays =
  [( self: super:
      {
          # MPV cd support
          mpv = super.mpv.override { cddaSupport = true; };
      }
  )];

  environment.systemPackages = with pkgs; [
    (...)
    mpv
  ]
}

However, I am met with the following:

[root@comp:~]# nixos-rebuild switch
building Nix...
building the system configuration...
error: 'wrapper' at /nix/store/1xn5ig5ds4x9s3h6fr683rhj3k9srqvh-nixos-21.11.333896.a640d8394f3/nixos/pkgs/applications/video/mpv/wrapper.nix:14:13 called with unexpected argument 'cddaSupport', at /nix/store/1xn5ig5ds4x9s3h6fr683rhj3k9srqvh-nixos-21.11.333896.a640d8394f3/nixos/lib/customisation.nix:69:16
(use '--show-trace' to show detailed location information)

It seems that the wrapper is throwing a wrench in things and isn’t propagating my override to the package like I would expect. I’m not super familiar with the internals of nixpkgs (not yet anyways), so there’s the possibility that I’m going about this wrong.

Any help would be appreciated. I’m running NixOS 21.11 and Nix 2.3.16.

mpv is a wrapped derivation, so override effects the wrapper’s parameters. This can be seen in the repl:

nix-repl> mpv.override.__functionArgs
{ extraMakeWrapperArgs = true; extraUmpvWrapperArgs = true; scripts = true; youtubeSupport = true; }

What you could do is override the unwrapped derivation and then wrap it again:

wrapMpv (mpv.unwrapped.override { cddaSupport = true; }) {}

That makes total sense. Here’s what I ended up with for the record:

{
  nixpkgs.overlays =
  [( self: super:
    {
      # MPV cd support
      mpv = super.wrapMpv (super.mpv.unwrapped.override { cddaSupport = true; }) {};
    }
  )];
}

Works perfectly, thank you for the help!