Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpv-with-scripts and wrapMpv are confusing #100771

Closed
jktjkt opened this issue Oct 16, 2020 · 2 comments
Closed

mpv-with-scripts and wrapMpv are confusing #100771

jktjkt opened this issue Oct 16, 2020 · 2 comments
Labels
0.kind: bug Something is broken

Comments

@jktjkt
Copy link
Contributor

jktjkt commented Oct 16, 2020

Describe the bug
The wiki says that this is how I'm supposed to add scripts to my mpv binary:

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

That does not work:

  • if I name my derivation mpv, then I get a binary mpv in my $PATH, not a shell script,
  • if I name my derivation mpv-with-scripts, then I get a wrapper, but that wrapper doesn't wrap any scripts.

If I use an overlay like this:

self: super:
let
  lib = self.pkgs.lib;
  stdenv = self.pkgs.stdenv;
in rec {
  mpv = super.wrapMpv super.mpv-unwrapped {
    scripts = [
      super.mpvScripts.mpris
    ];
  };
}

...I get a infinite recursion. The only way that I was able to come up with (thanks to @lukebfox on IRC) was by naming the package differently, such as:

self: super:
let
  lib = self.pkgs.lib;
  stdenv = self.pkgs.stdenv;
in rec {
  mpv_jkt = super.wrapMpv super.mpv-unwrapped {
    scripts = [
      super.mpvScripts.mpris
    ];
  };
}

Cc: @doronbehar @AndersonTorres because of #88620.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.8.14, NixOS, 21.03pre246543.24c9b05ac53 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.7`
 - channels(root): `"nixos-21.03pre246543.24c9b05ac53"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@jktjkt jktjkt added the 0.kind: bug Something is broken label Oct 16, 2020
@lukebfox
Copy link
Member

The mpvScripts.mpris derivation depends on pkgs.mpv. When one makes an mpv overlay addings mpris as a script, nix fails when evaluating the reference to mpv in mpris' buildInputs. As mpris is only script with mpv dependency maybe it was missed in translation to new wrapper style? Should probably be mpv-unwrapped now.

Quickfix for those trying to use mpv with mpris.

self: super: {
  mpvScripts.mpris = super.mpvScripts.mpris.override {
    mpv = self.mpv-unwrapped;
  };
  mpv = super.wrapMpv super.mpv-unwrapped {
    scripts = [ self.mpvScripts.mpris ];
  };
}

@doronbehar
Copy link
Contributor

@jktjkt the wiki is outdated. Sorry for your bad experience. mpvScripts.mpris indeed was defined bad. #100779 should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants